Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I display data from 2 lists in a single barchart component

Status
Not open for further replies.

ColdFusionKing

Programmer
Dec 5, 2002
145
GB
Hello Everybody,

I'm new to flash. I'm using the flash barchart component, which gets the values from a cfc via remoting. See the below code. It magically works.

var theData = new DataProviderClass();
var items = new Array();
for (var i = 0; i < list_temp.length; i++) {
items = {bytes: &quot;&quot;, value: list_temp};
}

for (var i = 0; i < items.length; i++) {
theData.addItem(items);
}

myChart.setDataProvider(theData);

In the code above I'm looping through the list (list_temp - ex: 100,200,300,400,500) and pushing its contents in a array (items). Looping through the array and pushing the values to the top of the chart's data provider and finally setting the instance of the chart component with the data.

So all this works fine. I want to now pass another list of data to the same chart. So I want the chart to display the data from two lists. I don't know how to do this and need your help.

Basically I want my graph to represent the sales figures in the current month and sales figures in the last month. If possible display the sales figures in two different colors. I hope this is making sense. Please help

Allan
 
I'm working on a bandwidth reporting interface. The interface uses a webservice which returns the number of bytes sent and received every five minutes in the span of one hour. I then create two lists to hold the bytes sent and received (lBytesSent, lBytesReceived). I now want to represent this information in a bar chart. I would really appreciate your help

- Allan
 
i have never user this component so the following is best guess

var theData = new DataProviderClass();
var items = new Array();
for (var i = 0; i < list_temp.length; i++) {
items = {bytes: &quot;&quot;, value1: list_temp, value2: list_temp};
}

for (var i = 0; i < items.length; i++) {
theData.addItem(items);
}

myChart.setDataProvider(theData);

 
another stab in the dark


var theData = new DataProviderClass();
var items = new Array();
for (var i = 0; i < list_temp.length; i++) {
var value1 = eval(&quot;list_temp.value1&quot;+i);
var value2 = eval(&quot;lisr_temp.value2&quot;+i);
var DataProvider = { value1:value1,value2:value2};
thedata.addItem(DataProvider);

}

myChart.setDataProvider(theData);

 
Thanks for that Bill. However it does not work. I would like to see it work but I've come up with a temporary solution. The code below displays the graph/barchart in two barchart components. If you can

list_tempBtReceived = lTotalBytesReceived.split(&quot;,&quot;);
list_tempBtSent = lTotalBytesSent.split(&quot;,&quot;);
var theDataReceived = new DataProviderClass();
var theDateSent = new DataProviderClass();
var itemsReceived = new Array();
var itemsSent = new Array();

for (var i = 0; i < list_tempBtReceived.length; i++) {
itemsReceived = {bytes: &quot;&quot;, value: list_tempBtReceived};
}

for (var i = 0; i < itemsReceived.length; i++) {
theDataReceived.addItem(itemsReceived);
}

myChart.setDataProvider(theDataReceived);

for (var i = 0; i < list_tempBtSent.length; i++) {
itemsSent = {bytes: &quot;&quot;, value: list_tempBtSent};
}

for (var i = 0; i < itemsSent.length; i++) {
theDateSent.addItem(itemsSent);
}

myChart1.setDataProvider(theDateSent);

I want to either display the data in a stacked bar chart or a clustered bar chart. For a quick example go to and click on the charting components link under the products category.
 
I have never used a bar chart component, but I've done what you are trying to do by drawing the bar chart dynamically. It might be a little more work, but all I do for mine is read my values into arrays and then do for loops through them. It wouldn't be hard to print your date received and date sent values in bars next to each other, but there is more work involved in drawing the graph, axes, axes labels, legend, etc. It could be done though. Let me know if you feel like giving it a shot.
 
well I want to give it a bash and would appreciate your help. I'm new to action script and if you could provide me with the code, that would be really useful.

Cheers
Allan
 
It might be a little work, but you can take a look and see what you think. Let me go in and comment my code a little better. Send me an email at bjewell79@hotmail.com.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top