Scatter FlexChart logScale x-axis

Posted by: benoit.laplante on 27 February 2025, 1:54 pm EST

  • Posted 27 February 2025, 1:54 pm EST

    How to generate/force more major ticks on log scale x-axis?

    I can easily add more tick by forcing a smaller majorUnit on linear scale.

    But I tried any combination of majorUnit, labelPadding or overlappingLabels to force more ticks on log scale without any success. The only way I found is by making the chart bigger or reducing the label font-size or formatting in scientific notation.

    I setup a demo here: https://jscodemine.mescius.io/sample/is9gD9s2zUmREphZwWZagQ/

    Can you help me out to generate a major tick at every 10^x on a 375x250 chart size using default label format?

  • Posted 28 February 2025, 5:30 am EST

    Hi Benoit,

    This behavior is by design, the labels are automatically rendered according to the chart size for the logarithmic axis. If you want to render all the labels i.e. 10^x, then you can override the ‘_createLogarithmicLabels’ method of the Axis class.

    Here’s an updated sample demonstrating the same - https://jscodemine.mescius.io/share/3fjnF9dU7EOX2iuhG5zLTA/

    Regards

  • Posted 28 February 2025, 5:23 pm EST

    Hi Vivek,

    Thank you for the workaround. I see you copied the _createLogarithmicLabels code from built generated esm code. Since this function is not documented, could you name correctly the function parameters and variable names so I can understand what is going on?

    To add on your behavior comment, the labels are also automatically rendered based on chart size for linear scale axis too. The difference is we can control linear scale axis using the majorUnit to generate more ticks. If the majorUnit is too small, it automatically hide overlapping labels (when overlappingLabels=Auto).

    Why this inconsistent behavior with log scale axis?

    Can I propose to control logScale tick genaration with majorUnit (or new axis attribute named majorLogUnit) where the unit = log(tick_i+1) -log(tick_i) . In my use case setting majorUnit=1 would generate a tick at every 10^x unless labels are overlapping.

  • Posted 3 March 2025, 8:16 am EST

    Hi Benoit,

    Actually, I also don’t have access to the actual function parameters as this is an internal function, however, as per my investigation I have the following observations -

    (Axis as any).prototype._createLogarithmicLabels = function (t, e, i, r, n, s)

    t = min property value of the axis

    e = max property value of the axis

    i = majorUnit

    r = array that has actual label values

    n = array that has strings to be displayed for each label

    s = not sure about this parameter, seems like a boolean value check for some updates in calculating label values

    Different behaviors are observed for labels of the linear scale axis and log scale axis because, for the log scale there is a large difference between label values after each major tick mark, and the minor tick marks also needs to be calculated accordingly keeping equal number of minor tick marks between each pair of major tick marks. All this part for log scale labels is handled separately, due to which this variation in behavior is observed.

    We have also created an enhancement request as per your suggestion. Here’s the internal tracking ID for the same - WJM-35828. We will update you on its progress when we have some information from the engineering team.

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels