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

Message ListMessage List     Post MessagePost Message

  Regarding Major grid
Posted by Yogesh on May-08-2011 22:56
Hi Peter,

I have 2 question.

1. I am using Finance chart. i want my to chart display Major grid but in dash line fashion.
i searched the solution on this forum and i modified it as following code:

FinanceChart m = new FinanceChart(_chartWidth);

m.setPlotAreaStyle(AColor.BLACK,
                m.dashLineColor(AColor.GRAY, Chart.DashLine),
                m.dashLineColor(AColor.GRAY, Chart.DashLine),Chart.Transparent,
Chart.Transparent);

but it seems its not working for me.

2. For the same chart i want to have only 5 grid lines to be seen at any given point of time
even after zooming

i used the following code :

mainChart.xAxis().setTickDensity(noOfPoints / 5);
            mainChart.yAxis2().setTickDensity(5);

but it seems its not working

am i missing something.

i can provide you more code if the above is not sufficient.

  Re: Regarding Major grid
Posted by Peter Kwan on May-10-2011 02:42
Hi Yogesh,

1. Unluckily, there is a limitation in FinanceChart that you cannot use FinanceChart.setPlotAreaStyle for any color that is only valid in a particular BaseChart object. These includes all colors created dynamically by the BaseChart including dashLineColor.

For these type of colors, you would need to assign them directly to the XYChart object, using the XYChart object itself to create the colors. It is like:

mainChart.getPlotArea().setGridColors(
mainChart.dashLineColor(AColor.GRAY, Chart.DashLine), mainChart.dashLineColor(AColor.GRAY, Chart.DashLine);

Note that the dashLineColor above is created using the mainChart and applies to the mainChart.

If your FinanceChart contains other indicator charts, you would need to perform the above for the indicator charts too.

2. For having only 5 grid lines to be seen at any given point, note that it may be impossible or has many complications in many cases. For example, what happen if you only have 3 visible candlesticks? What happen if you have 7 visible candlesticks? (If you put one grid line per two per candlesticks, you will end up with 4 grid lines. If you put one grid line per candlestick, you will end up with 7 grid lines.)

My suggestion is to use the FinanceChart.setDateLabelSpacing to suggest a label spacing to ChartDirector. ChartDirector will try to put grid lines so that the labels are close to or equal to the suggested spacing (but not smaller than the suggested spacing).

The mainChart.setTickDensity does not work as expect because it applies only for auto-scaled axis. In a FinanceChart, the scale is label based and is determined by the timeStamps array. ChartDirector merely picks the labels to display, but not the axis scale (unlike the y-axis, which ChartDirector does pick the scale). The FinanceChart object will pick the labels to display based FinanceChart.setDateLabelSpacing.

Hope this can help.

Regards
Peter Kwan