jQWidgets Forums

jQuery UI Widgets Forums Chart Top Grid Line Missing in jqxChart

This topic contains 6 replies, has 2 voices, and was last updated by  shrijeshmistry 1 month ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • Top Grid Line Missing in jqxChart #135691

    shrijeshmistry
    Participant

    I’m having a jqxChart. I want to divide my value axis domain into 7 intervals. I’m using a function as follows to calculate interval:
    function calculateLinearSpacing(yMax, yMin) {
    return (yMax – yMin) / 7;
    }

    Now, I’m trying to plot the chart.

    This is my code for value Axis:
    valueAxis: {
    title: { text: stringTable.string(“ID_ResourcePredictMemory”) },
    logarithmicScale: logLogScale,
    logarithmicScaleBase: logLogScale ? calculateLogScale(Math.max.apply(null, yValues), Math.min.apply(null, yValues)) : undefined,
    unitInterval: logLogScale ? undefined : calculateLinearSpacing(Math.max.apply(null, yValues), Math.min.apply(null, yValues)),
    labels: {
    horizontalAlignment: “right”,
    formatFunction: function (value) {
    if (value % 1 === 0) {
    return new Intl.NumberFormat().format(value.toString()) + ” ” + stringGB; // No decimal places for integers
    } else {
    return new Intl.NumberFormat().format(value.toFixed(1)) + ” ” + stringGB; // One decimal place for other cases
    }
    }
    }
    }

    I’m facing issue in few scenarios. I can not see the top grid line:
    Bug

    Top Grid Line Missing in jqxChart #135692

    shrijeshmistry
    Participant

    Link to the ImageIssue

    Top Grid Line Missing in jqxChart #135698

    admin
    Keymaster

    Hi,

    I see that you’re calculating the unitInterval dynamically but facing an issue where the top grid line is not visible in certain cases. This typically happens when the yMax value is not a multiple of the interval, causing the axis to stop just before reaching the maximum value. To ensure the top grid line appears, modify your yMax value so that it aligns with the calculated interval. As a solution, you can try to adjust yMax to the Next Multiple of Interval

    function calculateLinearSpacing(yMax, yMin) {
        return (yMax - yMin) / 7;
    }
    
    function adjustMaxValue(yMax, yMin) {
        let interval = calculateLinearSpacing(yMax, yMin);
        return Math.ceil(yMax / interval) * interval; // Adjust max value to align with grid
    }

    Regards,
    Peter

    jQWidgets Team
    https://www.jqwidgets.com/
    Then, use the adjusted value in unitInterval

    Top Grid Line Missing in jqxChart #135699

    shrijeshmistry
    Participant

    Thank you Peter for your help. It worked in the scenarios where it was not working earlier. But I started seeing in other scenarios now:

    Top Grid Line Missing in jqxChart #135705

    shrijeshmistry
    Participant

    Any help would be appreciated. Thanks!

    Top Grid Line Missing in jqxChart #135708

    admin
    Keymaster

    Hi shrijeshmistry,

    This depends on the calculations as I wrote in the previous post. You need to modify your yMax value so that it aligns with the calculated interval.

    Regards,
    Peter

    jQWidgets Team
    https://www.jqwidgets.com/

    Top Grid Line Missing in jqxChart #135710

    shrijeshmistry
    Participant

    I’m doing the calculation you mentioned but it still shows the issue in few scenario(s).

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.