Page 1 of 1

viewxy - how to enable logarithmic x axis?

Posted: Tue Mar 14, 2017 8:36 pm
by greggorob64
Hello.

I have a chart with multiple SampleDataSeries (shown below)

I'm hoping to have the option to enable a logarithmic X axis. However, I can't seem to get the log axis to get enabled. It keeps looking normal.

What am I missing?

Thanks!

Here's the code I'm using

Code: Select all

            var xAxis = thisChart.ViewXY.XAxes[0];

            xAxis.ScaleType = ScaleType.Logarithmic;
            xAxis.LogLabelsType = LogLabelsType.Log10Exponential;
            xAxis.LogBase = 10;
Image

Re: viewxy - how to enable logarithmic x axis?

Posted: Wed Mar 15, 2017 3:02 pm
by ArctionKestutis
Hello,

You do everything correctly it should work. Actually, I just tested on our Demo app (WinForms with property grid) - and see no problem (with SampleDataSeries as well).
If it is still an issue we would need to know version you using and more complete test app.

All the best.

Re: viewxy - how to enable logarithmic x axis?

Posted: Thu Mar 16, 2017 6:27 am
by ArctionPasi
Please check you have set xAxis.ScrollMode = None. In real-time scrolling modes, log X axis can't be used.

Re: viewxy - how to enable logarithmic x axis?

Posted: Thu Mar 16, 2017 12:32 pm
by greggorob64
Still no luck.

Here is pretty much all of the code that initializes an axis:

Code: Select all

   var axisX = thisChart.ViewXY.XAxes[0];

            axisX.Title.MouseInteraction = false;
            axisX.FormatValueLabel += XAxis_FormatValueLabel;

            axisX.ValueType = AxisValueType.Number;
            axisX.AutoFormatLabels = false;

            axisX.MouseInteraction = false;
            axisX.MouseScaling = false;
            axisX.MouseScrolling = false;
            axisX.ScrollMode = XAxisScrollMode.None;
            axisX.RangeChanged += thisAxis_XRangeChanged;

            axisX.ScaleType = ScaleType.Logarithmic;
            axisX.LogLabelsType = LogLabelsType.Log10Exponential;
            axisX.LogBase = 10;

            // Set colors, no logic
            AxisXStyleUpdate();

Could it be that I'm using SampleDataSeries?

Re: viewxy - how to enable logarithmic x axis?

Posted: Thu Mar 16, 2017 2:43 pm
by ArctionPasi
Hi Greg,

series type doesn't have anything to do with it.

I used your code in ExamplePointLineSeriesXY Winforms example, and it sets the log axis correctly.

So, you probably have reference to wrong chart, or wrong x axis (if you have many of them). :shock:

Best regards,
Pasi

Re: viewxy - how to enable logarithmic x axis?

Posted: Thu Mar 16, 2017 7:05 pm
by greggorob64
I'll have to dig in and figure it out. There's only 1 chart and 1 axes in my application there. However, i'm very rigid in how i display the minimums and maximums and the allowable viewing area.

If I use setrange functions, is there a change that it will reset the scaling on the axis?

Re: viewxy - how to enable logarithmic x axis?

Posted: Fri Mar 17, 2017 7:02 am
by ArctionKestutis
Hi,

I can only confirm that there is no problem in our example if Greg's setting are used. We don't know that event handler XAxis_FormatValueLabel, thisAxis_XRangeChanged and AxisXStyleUpdate() do - maybe something behind them.
Greg, you could subscribe to _chart.AfterRendering event and check the ScaleType there. If it was overwrite it is one thing, if relevant axis is never used that is another thing.

SetRange is not changing scale (unless you customized to do so in your thisAxis_XRangeChanged). For example Zooming is using this method and you can test any Log-scale example on our Demo to test that.

All the best.

Re: viewxy - how to enable logarithmic x axis?

Posted: Mon Mar 27, 2017 8:32 pm
by greggorob64
Well I'm in a position where I don't know what the heck changed, but it magically started working. I'm using the following code to enable my logarithmic axis:

Code: Select all

            axisX.ScaleType = ScaleType.Logarithmic;
            axisX.LogLabelsType = LogLabelsType.Regular;
            axisX.LogBase = 10;
My issue is, when i zoom in, the X axis labels dissapear really easily\quickly. Do I have any options for this?

(pics zoomed out, zoomed in a little, zoomed in more)

Image

Image

Image

Re: viewxy - how to enable logarithmic x axis?

Posted: Tue Mar 28, 2017 1:16 pm
by ArctionKestutis
Hi Greg,

The logarithmic axis major tick is calculated based LogBase. That is, for LogBase=10 labels will be [1, 10, 100 etc], while LogBase=2 labels will be [2, 4, 8, 16 etc]. The minor division count could be changed with Axis.MinorDivCount. If it is not enough Labels from major ticks, then you could customize with Axis.CustomTicks().

All the best.