Hi icm63,
If the y-axis scale is automatically determined by ChartDirector, it will try to configure the y-axis so that it includes all data points on the chart.
For Bollinger Band, by its definition, it can reach zero and even negative values. For log scale, when the value approaches zero, the logarithm will tend to negative infinity. Since it is not possible to extend the axis to negative infinity, ChartDirector will truncate the scale to 0.01.
You can use Axis.setLogScale to set the lower limit to some other values. For example:
'Assume this is the main price chart
Dim m As XYChart = c.addMainChart(240)
'Set the lower limit to 0.2. The upper limit is not set, so ChartDirector
'will automatically determine the maximum scale.
m.yAxis().setLogScale(0.2, Chart.NoValue)
If you want the axis scale to be the same as the chart with no Bollinger Band, you can first draw the chart with no Bollinger Band, and then ask ChartDirector what is the axis scale:
... draw the chart as usual ...
c.layout()
Dim minValue As Double = m.yAxis().getMinValue()
Dim maxValue As Double = m.yAxis().getMaxValue()
Then when you want the second chart with Bollinger Band, you can set the log axis scale as minValue - maxValue.
m.setLogScale(minValue, maxValue)
I think you can draw the two charts with the same code. You just need to add a flag so that the code knows if it needs to draw the Bollinger Band.
Best Regards
Peter Kwan |