piechart.lzx
<library>
<include href="../styles/chartstyle.lzx"/>
<include href="../common/dataseries.lzx"/>
<include href="../common/viewspoolmanager.lzx"/>
<include href="../common/virtualdrawview.lzx"/>
<include href="../common/datalabel.lzx"/>
<include href="../common/chart.lzx"/>
<include href="../common/legend.lzx"/>
<include href="piepiece.lzx"/>
<include href="piechartplotarea.lzx"/>
<class name="piechart" extends="chart">
<method name="init">
plotarea = this.getNodeOfClass("piechartplotarea");
_datalabelpool = this.createLabelViewspool();
super.init();
</method>
<method name="renderPlotArea">
super.renderPlotArea();
plotarea.clear();
var topseries = this.getDataSeries();
//var numSeries = topseries.getNumDataSeries();
var numSeries = 1;
for(var i = 0; i < numSeries; i++)
{
var leafseries = topseries.getDataSeries(i);
//FIXME!!(LHCR, 5/06/2005): Read hard coded data columns - 'x', 'y'
if(leafseries.getDataColumn("x") != null){
var xseries = leafseries.getDataColumn("x").values;
} else {
var xseries = null;
}
if(leafseries.getDataColumn("y") != null){
var yseries = leafseries.getDataColumn("y").values;
} else {
var yseries = null;
}
var tooltipseries;// = leafseries.getDataColumn(this.datatipColumn).values;
plotarea.renderSeries(xseries, yseries, tooltipseries);
}
if ( this.datalabelEnabled ){
this.renderDataLabels();
}
</method>
<method name="renderDataLabels">
_datalabelpool.reclaimAll();
var arrPiePieces = this.plotarea.arrPiePieces;
var topseries = this.getDataSeries();
var leafseries = topseries.getDataSeries(0);
//FIXME!!(LHCR, 5/06/2005): Read hard coded data columns - 'x', 'y'
if(leafseries.getDataColumn(this.datalabelColumn) != null){
var yseries = leafseries.getDataColumn(this.datalabelColumn).values;
} else {
var yseries = null;
}
for(var i = 0; i < arrPiePieces.length; i++){
piePiece = arrPiePieces[i];
var lbl = _datalabelpool.getView();
var ldatastyle = piePiece.style;
lbl.setAttribute('style', ldatastyle.label);
lbl.render(yseries[i]);
piePiece.renderLabel(lbl);
}
</method>
<piechartplotarea name="plotarea" x="50" y="20" width="500" height="300"/>
<doc>
<tag name="shortdesc">
<text>
The piechart component allows for the creation of a pie chart using series data.
</text>
</tag>
<text>
<warning>This component is of Beta quality and is subject to change.</warning>
<p>The following is a piechart that uses series data.</p>
<example title="Simple piechart">
<canvas height="400" width="400">
<dataset name="baseball"
src="resources/pie-data.xml"/>
<piechart id="chart1" width="500" height="500" dataPointsEnabled="true"
datalabelEnabled="true" datalabelColumn="y" style="defaultchartstyle">
<dataseries datapath="baseball:/records">
<datacolumn name="x" columndatapath="record/@year"
datatype="number"/>
<dataseries label="wins">
<datacolumn name="y" columndatapath="record/@wins"
datatype="number"/>
</dataseries>
<datacolumn name="tooltip" columndatapath="record">
<method name="processData" args="v">
return "year: " + v.attributes.year + " wins: " +
v.attributes.wins;
</method>
</datacolumn>
</dataseries>
<strokestyle name="pieslicestyle" strokeColor="0x000000" strokeWidth="2"
strokeType="dotted" />
<legend name="legendbox" legendFontsize="14" initstage="late"
legendborder="false">
<handler name="onitemmouseover" args="item">
var piepiece = parent.plotarea.arrPiePieces[item.identifier];
piepiece.renderInnerWedge();
</handler>
<handler name="onitemmouseout" args="item">
var piepiece = parent.plotarea.arrPiePieces[item.identifier];
piepiece.renderWedge();
</handler>
</legend>
</piechart>
</canvas>
</example>
</text>
</doc>
</class>
</library>
Cross References
Includes
Classes