Grid lines incorrect on logarithmic scale?
Posted: Mon Aug 29, 2005 6:17 pm
I am using TeeChart ver. 2 (2.0.1992.14012), and I am trying to display the grid lines for a vertical logarithmic scale. What I noticed is that the spacing on the grid lines doesn't seem to look correct. That is, there is too much space between grid lines towards the top of the next decade of logarithmic units.
Is this a known problem, or am I just not understanding something?
I displayed the grid lines by setting the grid to visible with a count of 9 in the design editor. This was set under the Chart->Axes->Minor->Grid... dialog.
As a slight bit of background, I took and modified some of the code from the "All Features -> Axes -> Custom logarithmic axis" example and tried to draw the lines myself. This code draws the grid marks with what seems the correct amount of space between them.
Is this a known problem, or am I just not understanding something?
I displayed the grid lines by setting the grid to visible with a count of 9 in the design editor. This was set under the Chart->Axes->Minor->Grid... dialog.
As a slight bit of background, I took and modified some of the code from the "All Features -> Axes -> Custom logarithmic axis" example and tried to draw the lines myself. This code draws the grid marks with what seems the correct amount of space between them.
Code: Select all
private void historicalBoxPlots_BeforeDrawAxes(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
// get rectangle occupied by chart
Rectangle chartRect = g.Chart.ChartRect;
// get axis and use same pen style as minor grid
Axis leftAxis = g.Chart.Axes.Left;
g.Pen.Style = leftAxis.MinorGrid.Style;
g.Pen.Color = leftAxis.MinorGrid.Color;
// get start and end position for minor line
int start = chartRect.Left - leftAxis.MinorTicks.Length;
int end = chartRect.Right;
double currentPos = 0;
// hardcoded the decades to simplify code
for(int i = 1; i <= 3; i++)
{
// loop to draw minor grid lines
for(int k = 2; k <= 9; k++)
{
currentPos = Math.Log10(k) * Math.Pow(10, i);
int tickPos = leftAxis.CalcPosValue(currentPos);
g.Line(start, tickPos, end, tickPos); // horizontal minor tick marks
}
}
}