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

Message ListMessage List     Post MessagePost Message

  Disappearing ticks
Posted by KeithB on Feb-26-2024 23:49
Attachments:
When I put in data that is completely negative, the Autoscale does a good job putting it in Quadrant III and putting in the grid.



But when I set the scale:
ChartXY.xAxis().setLinearScale((double)numMaxX.Value, 0, -1, -1);

The grid marks disappear.
auto.jpg
setscale.jpg

  Re: Disappearing ticks
Posted by Peter Kwan on Feb-27-2024 02:55
Hi KeithB,

Have you tried:

ChartXY.xAxis().setLinearScale((double)numMaxX.Value, 0, 1, 1);

From your screenshot, it seems numMaxX.Value equals to -10. So the tick is from -10 to 0. It is an increasing sequence like -10, -9, -8, ..... Each number is larger than the previous number by 1, so the tick increment should be 1.

Best Regards
Peter Kwan

  Re: Disappearing ticks
Posted by KeithB on Feb-27-2024 22:59
Attachments:
Thanks, but there are still some questions. Your fix only works for the Y axis:
// For the automatic axis labels, set the minimum spacing to 80/40 pixels for the x/y
// axis.
if (numXTicks.Value == 0)
{
    ChartXY.xAxis().setTickDensity(80, 40);
}
else
{
    ChartXY.xAxis().setTickDensity((int)numXTicks.Value);
}

if (numYTicks.Value == 0)
{
    ChartXY.yAxis().setTickDensity(40, 20);
}
else
{
    ChartXY.yAxis().setTickDensity((int)numYTicks.Value);
}


if (numMaxY.Value == 0)
{
    ChartXY.yAxis().setLinearScale3();
}
else
{
    if (checkBox1.CheckState == CheckState.Unchecked)
    {
        ChartXY.yAxis().setLinearScale(0, (double)numMaxY.Value);
    }
    else
    {
        ChartXY.yAxis().setLinearScale((double)numMaxY.Value, 0, 1, 1);
    }

}



if (numMaxX.Value == 0)
{
    ChartXY.xAxis().setLinearScale3();
}
else
{
    if (checkBox1.CheckState == CheckState.Unchecked)
    {
        ChartXY.xAxis().setLinearScale(0, (double)numMaxX.Value);
    }
    else
    {
        ChartXY.xAxis().setLinearScale((double)numMaxX.Value, 0, 1, 1);
    }

}
ticks.jpg

  Re: Disappearing ticks
Posted by KeithB on Feb-27-2024 23:01
Ah, that should have been only works for the *X* axis
And the check box for the code tells us we are in negative (Quadrant III) mode.

  Re: Disappearing ticks
Posted by Peter Kwan on Feb-28-2024 00:20
Hi KeithB,

Sorry, I am not sure what is the issue.

As the checkbox is checked, I think the y-axis is configured using:

ChartXY.yAxis().setLinearScale((double)numMaxY.Value, 0, 1, 1);

So the bottom end of the axis should be numMaxY.Value, which is -1, and the top end should be 0. The tick increment is 1, which means the axis should contain just -1 and 0.

The chart seems to be exactly as expected based on your code.

Would you mind to clarify which line of code is configuring the y-axis labels, and what do do the code to do?

Best Regards
Peter Kwan

  Re: Disappearing ticks
Posted by KeithB on Feb-28-2024 01:41
I would like to set the max value of the YAxis and automagically get a reasonable number of grid lines according to the Tick Density, which I don't understand at all.

What is the interaction between tick density and the Tick Increment?

I assumed that the max's set the max level on the chart, and the tick density set the number of increments.

  Re: Disappearing ticks
Posted by KeithB on Feb-28-2024 01:47
To be a bit more clear, for the positive chart I can just set the maxs and mins and the intervals follow:
ChartXY.yAxis().setLinearScale(0, (double)numMaxY.Value);

But if I do that with the negative chart, the grids disappear.

(oops, I just tried it and it was fine. What I did not do was try:
ChartXY.xAxis().setLinearScale((double)numMaxX.Value, 0);

with the mins and maxs inverted, but no ticks. Nevermind!)

  Re: Disappearing ticks
Posted by Peter Kwan on Feb-28-2024 13:29
Hi KeithB,

If you provide the min/max values but no tick increment, ChartDirector will automatically choose a reasonable tick increment. If the code provide the tick increment, ChartDirector will use the provided tick increment.

Best Regards
Peter Kwan

  Re: Disappearing ticks
Posted by KeithB on Feb-29-2024 05:56
Thanks.
Is there a way to get "Engineering units" on the graph.

For example, if I would plot what I have above at very low currents, the number of decimal points push the title over and off the visible display.

Is there a way to instead of displaying "0.000010" it could display 10 u (or micro)?

  Re: Disappearing ticks
Posted by Peter Kwan on Feb-29-2024 14:27
Hi KeithB,

Yes, you can use Axis.setLabelFormat to set the y-axis format to something like:

//Display the y-axis value multiplied by 1000000, followed by the letter u.
c.yAxis().setLabelFormat("{={value}*1000000}u");

In practice, you can use "if" statements to apply different formats based on the maximum value of your data. An alternative method to "if" statements is to use Axis.setFormatCondition, which is useful if the maximum axis value is hard to predict by examining the data (such as when the chart is zoomable by the user).

Best Regards
Peter Kwan

  Re: Disappearing ticks
Posted by KeithB on Feb-29-2024 23:31
Thanks. That should do it, though I was hoping that you would have done the work for me. 8^) You certainly have spoiled us!