ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Bar Chart and Line chart with Dual y Axis and Labels as Date Value
Posted by Parvesh Jain on Mar-06-2012 20:07
I am trying to draw Bar Chart with Line chart overlay it. Also it should be on Dual y-axis. For line chart i have lots of data points (around 300-400) and Barchart will have few data points 10-15. X-axis is a date and both charts will be sharing the axis.

Do u have any example to draw this, when i am trying the dualyaxis.java sample program, it is taking Labels as string (not date) and not able to adjust the x-asix labels display.

Also i want to know if better approach might to use Financial chart for bigger dataset and show 10-15 items as Events. But i am not sure if i can represent events as a bar in financial chart.

Regards
Parvesh

  Re: Bar Chart and Line chart with Dual y Axis and Labels as Date Value
Posted by Peter Kwan on Mar-07-2012 03:27
Hi Parvesh,

In the most general case, you can provide x-coordinates for the data points and the bars to ChartDirector. For example:

BarLayer layer0 = c.addBarLayer(myBarData, ....);
layer0.setXData(xCoordinatesForBars);

LineLayer layer1 = c.addBarLayer(myDataPoints, ....);
layer1.setXData(xCoordinatesForDataPoints);
layer1.setUseYAxis2();

//You may modify the date/time formatting to fit your needs
c.xAxis().setDateScale3("{value|mmm dd/yyyy}");

The above code allows the number of bars and number of data points to be different. It supports bars that can be arbitrarily spaced (as opposed to evenly spaced), and the same for data points.

Note that because the bars are arbitrarily spaced, the bar width cannot be automatically determined. (For example, if you have 11 bars randomly distributed within 30 days, it is hard to know if the bar width should cover 1 day, 2 days, 1 hour or other duration.) ChartDirector will automatically guess the bar width, but it may not be what you need. In this case, please use layer0.setBarWidth to explicitly set the bar width based on the nature of your application.

Hope this can help.

Regards
Peter Kwan

  Re: Bar Chart and Line chart with Dual y Axis and Labels as Date Value
Posted by Parvesh Jain on Mar-07-2012 13:19
Thanks Peter

Your solution worked.