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

Message ListMessage List     Post MessagePost Message

  Logarithmic scale
Posted by Tony on Nov-24-2020 16:43

How to set x-axis and y-axis as Logarithmic scale?
Attached is the example.
IEEE picture check.png

  Re: Logarithmic scale
Posted by Tony on Nov-24-2020 16:48

OS: Windows7
C# and C++ Programming Language

  Re: Logarithmic scale
Posted by Peter Kwan on Nov-25-2020 14:04
Hi Tony,

You can use Axis.setLogScale. See:

The setLogScale will ensure the axis is log scale. By default, ChartDirector will automatically determine the actual scale based on your data. For example, if your data are from 3 to 80, ChartDirector may choose 1, 10, 100 as the ticks. If it is from 25 to 45, ChartDirector may choose 20, 30, 40, 50 as the ticks, which would be unevenly spaced on a log scale axis.

If you want the exact axis scale as shown in your image even with no data on the chart, you can set the scale with your code:

c.xAxis().setLogScale(1, 3000, 10, Chart.LinearTick);
c.yAxis().setLogScale(0.1, 100, 10, Chart.LinearTick);
// Append a '%' character for the y-axis label

The Chart.LinearTick above is to tell ChartDirector to use 2, 3, 4, .... as the minor ticks. If this parameter is empty, there will be no minor tick. If this parameter is Chart.LogTick, the miChart.LogTick, the minor ticks will be 2, 5, as 1, 2, 5, 10 is roughly equally spaced on a log scale axis.

I notice your chart has no grid lines. To hide the grid lines, you can set their colors to transparent, like:

c.getPlotArea().setGridColor(Chart.Transparent, Chart.Transparent);

The above code is in C#. The C++ code is the same except with a change in syntax. (The member access operator will change from "." to "->" and the namespace qualification will change from "." to "::".)

Peter Kwan

  Re: Logarithmic scale
Posted by Tony on Nov-25-2020 17:56
Thank you Peter.