Multiple series with data-bound chart?

P

Peter Kenyon

Hi all,

I am using the following JavaScript code to display a bar graph bound to an
ADO recordset.
This graph is meant to have 4 series based on the fields Actual, Budget,
ActualYTD and BudgetYTD. However, the code below only creates the last
series - the first three seem to get "overwritten".
Can anybody tell me what I need to do to create more than one series?

Thanks,

Peter



var c = ChartSpace.Constants;

ChartSpace.Clear();
ChartSpace.DataSource = rs;

ChartSpace.DisplayFieldButtons = false;
ChartSpace.HasChartSpaceLegend = true;
ChartSpace.HasChartSpaceTitle = true;
ChartSpace.ChartSpaceTitle.Caption = "Sales plan for " +
RepName.innerText;

ChartSpace.PlotAllAggregates = c.chPlotAggregatesSeries;
ChartSpace.SetData(c.chDimCategories, 0, "MthDate");

ChartSpace.SetData(c.chDimValues, 0, "Actual");
ChartSpace.SetData(c.chDimValues, 0, "Budget");
ChartSpace.SetData(c.chDimValues, 0, "ActualYTD");
ChartSpace.SetData(c.chDimValues, 0, "BudgetYTD");
 
J

Jim Hubbard

Peter Kenyon said:
Hi all,

I am using the following JavaScript code to display a bar graph bound to an
ADO recordset.
This graph is meant to have 4 series based on the fields Actual, Budget,
ActualYTD and BudgetYTD. However, the code below only creates the last
series - the first three seem to get "overwritten".
Can anybody tell me what I need to do to create more than one series?

Thanks,

Peter



var c = ChartSpace.Constants;

ChartSpace.Clear();
ChartSpace.DataSource = rs;

ChartSpace.DisplayFieldButtons = false;
ChartSpace.HasChartSpaceLegend = true;
ChartSpace.HasChartSpaceTitle = true;
ChartSpace.ChartSpaceTitle.Caption = "Sales plan for " +
RepName.innerText;

ChartSpace.PlotAllAggregates = c.chPlotAggregatesSeries;
ChartSpace.SetData(c.chDimCategories, 0, "MthDate");

ChartSpace.SetData(c.chDimValues, 0, "Actual");
ChartSpace.SetData(c.chDimValues, 0, "Budget");
ChartSpace.SetData(c.chDimValues, 0, "ActualYTD");
ChartSpace.SetData(c.chDimValues, 0, "BudgetYTD");

Change your code to the following....

ChartSpace.SetData(c.chDimValues, 0, Array("Actual", "Budget",
"ActualYTD", "BudgetYTD"));

Or, simply pass in a variant array that has your series in it (this MUST
be a VARIANT array). If myArray(0) = "Actual" and myArray(1) = "Budget" and
myArray(2) = "ActualYTD" and myArray(3) = "BudgetYTD" then your code could
be shortened to....

ChartSpace.SetData(c.chDimValues, 0, myArray);

Jim Hubbard
 
P

Peter Kenyon

Change your code to the following....
ChartSpace.SetData(c.chDimValues, 0, Array("Actual", "Budget",
"ActualYTD", "BudgetYTD"));

Or, simply pass in a variant array that has your series in it (this MUST
be a VARIANT array). If myArray(0) = "Actual" and myArray(1) = "Budget" and
myArray(2) = "ActualYTD" and myArray(3) = "BudgetYTD" then your code could
be shortened to....

ChartSpace.SetData(c.chDimValues, 0, myArray);

Jim Hubbard

Thanks Jim. The example works in VBScript but in JavaScript for some reason.
No matter how I code it, it doesn't seem to accept a JavaScript array. They
must be implemented differently to VBScript.

Peter
 
J

Jim Hubbard

I'm not that familiar with JavaScript....but the array MUST be a variant
array in VB and VBScript. Is there an equivalent data type in JavaScript?
 
C

Christopher M. Balz

I offer a JavaScript function grapher written in Web-standard,
abstracted JavaScript that you might be interested in at:

http://www.bigwebmaster.com/1519.html

It's two years old, extensible, and has stood the test of time. Live
demo and Javascriptdoc available from that page.

- CB

Alvin Bruney said:
int[] i for array of integers if i remember correctlly or int i[].

Jim Hubbard said:
I'm not that familiar with JavaScript....but the array MUST be a variant
array in VB and VBScript. Is there an equivalent data type in JavaScript?


(this
MUST "Budget"
and
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top