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

Message ListMessage List     Post MessagePost Message

  Need some code sample to produce similar chart as attached.
Posted by ET on Jun-11-2014 17:01
Attachments:
Hi Peter,

Could you provide some example to produce similar chart as attached in C# ASP.Net?
Thanks in advance.
image003.png

  Re: Need some code sample to produce similar chart as attached.
Posted by Peter Kwan on Jun-12-2014 04:31
Attachments:
Hi ET,

You may  start from the "Data Table (1)" sample code and add a bar layer and a mark line. I
have attached an example I modified from "Data Table (1)" for your reference.

Hope this can help.

Regards
Peter Kwan
datatable.aspx
datatable.aspx

5.59 Kb

  Re: Need some code sample to produce similar chart as attached.
Posted by ET on Jun-16-2014 10:58
Hi Peter,

Thanks for your help. The codes works. I have additional request as follow:

1) How I can set the % on y-axis to be always 100%?
2) How to ensure the y-axis add mark always visible if my all my data point if above the
defaulted value set?

Thanks.

  Re: Need some code sample to produce similar chart as attached.
Posted by Peter Kwan on Jun-16-2014 18:51
Hi ET,

(1) You may set the y-axis scale using Axis.setLinearScale. For example:

c.yAxis().setLinearScale(60, 100, 10);
c.yAxis().setLabelFormat("{value}%");

(2) If the axis scale is set by your code (eg. using Axis.setLinearScale above), you can set
the axis scale to contain your mark line. In this way, the mark line will always be visible.

If your mark line is using an axis that is auto-scaled by ChartDirector, by default,
ChartDirector will scale the axis based on the data values in all the data layers. To ensure
the mark line is within the axis scale, you may add a transparent data layer with the data
value of the mark line. For example:

// make sure the right y-axis contains markValue
c.addLineLayer(new double[] { markValue }, Chart.Transparent).setUseYAxis2();
c.yAxis2().addMark(markValue, 0xff0000);

Hope this can help.

Regards
Peter Kwan