Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
higgins1b #1
dynamically creating pie chart
I have a format that we use to create pie charts and i would like to create a
tool to generate the chart in the format we want just by passing 3 gradients of
each color to use. My pie chart calls a function on initialise that is
supposed to generate the colors for the pie chart. I have one chart hardcoded
with all values in my one mxml that works, but when I try to generate the chart
using actionscript I get a large black circle. When I go through the inspect
tags of both applications they look identical to me. Can someone shed some
light on this please.... Here is my code.......
My MXML:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
width="100%" height="100%"
initialize="srv.send()"
xmlns="*">
<Inspect/>
<mx:Script>
<![CDATA[
var myArray:Array =
[[255,52479,51],[39168,65280,13056],[16776960,16777062,16763904],[6684672,167116
80,3342336]];
]]>
</mx:Script>
<mx:Script source="buildChart.as"/>
<mx:HTTPService id="srv" url="regionsummary.xml"/>
<mx:Model id="results">{srv.result.data.region}</mx:Model>
<mx:PieChart id="chart" initialize="buildChart(myArray)"
dataProvider="{results}" showDataTips="true" width="100%" height="100%">
<mx:series>
<mx:Array>
<mx:PieSeries field="revenue" labelPosition="inside">
<mx:fills>
<mx:Array>
</mx:Array>
</mx:fills>
</mx:PieSeries>
</mx:Array>
</mx:series>
</mx:PieChart>
</mx:Application>
My AS:
function buildChart(myColors:Array)
{
var arrayLength:Number=myColors.length;
var myRatios:Array;
var calcRatios:Array;
var myAlphas:Array;
var i:Number = 0;
var n:Number = 0;
var myFills:Array;
while (i<=arrayLength-1)
{
var _entries = new Array();
var gstops = new Object();
gstops.colors=myColors;
calcRatios=[0,127.5,255];
gstops.ratios=calcRatios;
myAlphas=[100,100,100];
gstops.alphas=myAlphas;
myRatios=[20,100,0];
var entriesLength:Number=myRatios.length;
for(n=0;n<entriesLength;n++)
{
var entries = new Object();
entries.color=myColors[n];
entries.ratio=myRatios[n];
entries.alpha=myAlphas[n];
_entries.push(entries);
}
var Matrix = new Object();
Matrix.r=0
Matrix.h=544
Matrix.w=544
Matrix.y=4
Matrix.x=342
Matrix.matrixType="box"
this.chart.series[0].fills.push({gstops: gstops, _entries: _entries,
matrix: Matrix});
i++;
}
}
higgins1b Guest
-
Dynamically changing chart labels
HI I'm after an how too really, point me in the right direction is possible. I have a new dashboard app, monitoring a server, last part is load... -
How do I dynamically add a series to a chart? flex 1.5
I have a problem where I'm trying to add a series to a line chart and it just doesn't work correctly. Here's a test fiel that i created to test... -
Dynamically / Programmically create chart ColumnSeries
Hi, I want to dynamically create the chart column series in a column chart. If example, according to the selection in a ComboBox, I need to populate... -
Creating A Pie Chart
I'm trying to create a Pie Chart. The whole of the Pie Chart will be the total number of surveys, TOTAL. I would then like to cut out the... -
components for dynamically displaying data chart or graph in ASP
Hello, I tried to find some components I can use to dynamically generate chart or graph from database in ASP. It seems to me that only some...



Reply With Quote

