|
How to add line in a Chart? |
Posted by Xie yp on Jun-25-2013 16:33 |
|
There has a chart (3-5 lines), then I want click a button, add another line, how to do ? |
Re: How to add line in a Chart? |
Posted by Peter Kwan on Jun-26-2013 03:53 |
|
Hi Xie yp,
To add a line to a chart, simply redraw the chart with the added line.
There is a sample code in ChartDirector called "Interactive Financial Chart", in which the user can add or remove lines by clicking on the checkboxes or selecting from the some drop down list boxes. May be you can use this sample code as a reference.
In brief, the code structure is quite simple. The exact code depends on your programming language and framework, but it should be like (in C#/Java):
void drawChart()
{
XYChart c = new XYChart(.........);
......
//add some lines
c.addLineLayer(.....);
c.addLineLayer(.....);
c.addLineLayer(.....);
c.addLineLayer(.....);
if (needToAddSpecialLine)
c.addLineLayer(.........);
......
}
Then when the button is pressed, you can set "needToAddSpecialLine = true;" and call "drawChart()" again.
Hope this can help.
Regards
Peter Kwan |
|