jQWidgets Forums
jQuery UI Widgets › Forums › Chart › Top Grid Line Missing in jqxChart
Tagged: chart, Grid Line Missing
This topic contains 6 replies, has 2 voices, and was last updated by shrijeshmistry 1 month ago.
-
Author
-
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:
Link to the Image
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,
PeterjQWidgets Team
https://www.jqwidgets.com/
Then, use the adjusted value in unitIntervalThank you Peter for your help. It worked in the scenarios where it was not working earlier. But I started seeing in other scenarios now:
Any help would be appreciated. Thanks!
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,
PeterjQWidgets Team
https://www.jqwidgets.com/I’m doing the calculation you mentioned but it still shows the issue in few scenario(s).
-
AuthorPosts
You must be logged in to reply to this topic.