Hi, all; I'm making my first attempt with the charts, and it turns out my data is such that I need to use a dataFunction first thing. To summarize my problem, the chart is making itself big enough that it looks like it can "see" my data, but it has no lines on it. The legend has the right number of items with the correct names. I figure I'm missing something stupid and obvious.
Here is my data, set in an init function:
attemptsXML =
<attempts>
<attempt date ="8/8/2008" hasSATScores="true"
name="Diagnostic Assessment" inspecting="false">
<subjects>
<subject name="Writing" adjustedScore="90"
satScore="700">
<kCat name="Usage" adjustedScore="85" />
<kCat name="Sentence Corrections"
adjustedScore="95" />
<kCat name="Proof Reading Paragraphs"
adjustedScore="90" />
</subject>
<subject name="Math" adjustedScore="70"
satScore="650">
<kCat name="Basics of Mathematics"
adjustedScore="85" />
<kCat name="Mathematical Relationships"
adjustedScore="50" />
<kCat name="Algebra I and II"
adjustedScore="60" />
<kCat name="Geometry and Measurement"
adjustedScore="80" />
<kCat name="Combinatorics and probability"
adjustedScore="70" />
</subject>
<subject name="Reading" adjustedScore="50"
satScore="550">
<kCat name="Sentence completions"
adjustedScore="60" />
<kCat name="Paragraph reading comprehension"
adjustedScore="30" />
</subject>
</subjects>
</attempt>
<attempt date ="8/9/2008" hasSATScores="true"
name="Diagnostic Test 1" inspecting="true">
<subjects>
<subject name="Writing" adjustedScore="20"
satScore="300">
<kCat name="Usage" adjustedScore="15" />
<kCat name="Sentence Corrections"
adjustedScore="30" />
<kCat name="Proof Reading Paragraphs"
adjustedScore="27" />
</subject>
<subject name="Math" adjustedScore="50"
satScore="400">
<kCat name="Basics of Mathematics"
adjustedScore="60" />
<kCat name="Mathematical Relationships"
adjustedScore="40" />
<kCat name="Algebra I and II"
adjustedScore="50" />
<kCat name="Geometry and Measurement"
adjustedScore="45" />
<kCat name="Combinatorics and probability"
adjustedScore="55" />
</subject>
<subject name="Reading" adjustedScore="10"
satScore="270">
<kCat name="Sentence completions"
adjustedScore="8" />
<kCat name="Paragraph reading comprehension"
adjustedScore="12" />
</subject>
</subjects>
</attempt>
<attempt date ="8/10/2008" hasSATScores="true"
name="Diagnostic Test 2" inspecting="true">
<subjects>
<subject name="Writing" adjustedScore="90"
satScore="700">
<kCat name="Usage" adjustedScore="85" />
<kCat name="Sentence Corrections"
adjustedScore="95" />
<kCat name="Proof Reading Paragraphs"
adjustedScore="90" />
</subject>
<subject name="Math" adjustedScore="70"
satScore="650">
<kCat name="Basics of Mathematics"
adjustedScore="85" />
<kCat name="Mathematical Relationships"
adjustedScore="50" />
<kCat name="Algebra I and II"
adjustedScore="60" />
<kCat name="Geometry and Measurement"
adjustedScore="80" />
<kCat name="Combinatorics and probability"
adjustedScore="70" />
</subject>
<subject name="Reading" adjustedScore="50"
satScore="550">
<kCat name="Sentence completions"
adjustedScore="60" />
<kCat name="Paragraph reading comprehension"
adjustedScore="30" />
</subject>
</subjects>
</attempt>
</attempts>
This is hard-coded now, but will be pushed in through
ExternalInterface later, so I'm assigning the dataprovider in as3
code.
Here is my dataFunction:
private function historyData(series:Series, item:Object,
fieldName:String):Object{
var xmlItem:XML=item as XML;
if (fieldName=='yValue'){
trace(series.displayName, fieldName,
xmlItem.child('subjects').child('subject').(attribute('name')
==series.displayName).attribute('satScore'));
return int(xmlItem.child
('subjects').child('subject').(attribute('name')
==series.displayName).attribute('satScore'));
} else if (fieldName=='xValue'){
trace(series.displayName, fieldName,
xmlItem.attribute('date'));
return xmlItem.attribute('date');
}
//not sure what other fields would come
asking, but just in case
return null;
}
Traces out:
Writing yValue 700
Writing yValue 300
Writing yValue 700
Writing xValue 8/8/2008
Writing xValue 8/9/2008
Writing xValue 8/10/2008
Math yValue 650
Math yValue 400
Math yValue 650
Math xValue 8/8/2008
Math xValue 8/9/2008
Math xValue 8/10/2008
Reading yValue 550
Reading yValue 270
Reading yValue 550
Reading xValue 8/8/2008
Reading xValue 8/9/2008
Reading xValue 8/10/2008
Here is my MXML
<mx:LineChart id="attemptHistory" visible="false" showDataTips="true">
<!--axis setup-->
<mx:verticalAxis>
<mx:LinearAxis
id="historyVertical" displayName="Score" />
</mx:verticalAxis>
<mx:horizontalAxis>
<mx:CategoryAxis
id="historyHorizontal" categoryField="date" displayName="Date
Completed" />
</mx:horizontalAxis>
<mx:verticalAxisRenderers>
<mx:AxisRenderer
id="hvRenderer"
axis="{historyVertical}"
tickPlacement="outside"
tickLength="8"
/>
</mx:verticalAxisRenderers>
<mx:horizontalAxisRenderers>
<mx:AxisRenderer
id="hhRenderer"
axis="{historyHorizontal}"
tickPlacement="outside"
tickLength="8"
/>
</mx:horizontalAxisRenderers>
<!--grid lines setup-->
<mx:backgroundElements>
<mx:GridLines
id="historyGridLines"
y="-.5"
direction="horizontal"
verticalShowOrigin="false"
horizontalShowOrigin="true"
/>
</mx:backgroundElements>
<!--######### the series #########-->
<mx:series>
<mx:LineSeries
id="writingSeries" dataFunction="historyData" displayName="Writing" />
<mx:LineSeries
id="mathSeries" dataFunction="historyData" displayName="Math" />
<mx:LineSeries
id="readingSeries" dataFunction="historyData" displayName="Reading" />
</mx:series>
</mx:LineChart>
Thanks in advance!
-Amy

