viewxy - how to enable logarithmic x axis?

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

viewxy - how to enable logarithmic x axis?

Post by greggorob64 » Tue Mar 14, 2017 8:36 pm

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

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: viewxy - how to enable logarithmic x axis?

Post by ArctionKestutis » Wed Mar 15, 2017 3:02 pm

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.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: viewxy - how to enable logarithmic x axis?

Post by ArctionPasi » Thu Mar 16, 2017 6:27 am

Please check you have set xAxis.ScrollMode = None. In real-time scrolling modes, log X axis can't be used.
LightningChart Support Team, PT

greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

Re: viewxy - how to enable logarithmic x axis?

Post by greggorob64 » Thu Mar 16, 2017 12:32 pm

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?

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: viewxy - how to enable logarithmic x axis?

Post by ArctionPasi » Thu Mar 16, 2017 2:43 pm

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
LightningChart Support Team, PT

greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

Re: viewxy - how to enable logarithmic x axis?

Post by greggorob64 » Thu Mar 16, 2017 7:05 pm

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?

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: viewxy - how to enable logarithmic x axis?

Post by ArctionKestutis » Fri Mar 17, 2017 7:02 am

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.

greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

Re: viewxy - how to enable logarithmic x axis?

Post by greggorob64 » Mon Mar 27, 2017 8:32 pm

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

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: viewxy - how to enable logarithmic x axis?

Post by ArctionKestutis » Tue Mar 28, 2017 1:16 pm

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.

Post Reply