jQWidgets Forums
jQuery UI Widgets › Forums › Chart › decimalPlaces error
Tagged: decimalPlaces
This topic contains 3 replies, has 3 voices, and was last updated by ivanpeevski 3 years, 2 months ago.
-
AuthordecimalPlaces error Posts
-
hello please help me
my test data is
var sampleData = [{
a: -10.35,
b: 14.5
}, {
a: 10,
b: 2.5
}, {
a: 10,
b: 0.2
}, {
a: 100,
b: 205
}, {
a: 1,
b: 100
}, {
a: 5.11,
b: 10.13
}, {
a: 20.13,
b: 10.13
}, {
a: 600,
b: 300
}];
var settings = {
title: “Logarithmic Scale Axis Example”,
description: “Sample logarithmic scale axis with base 2″,
enableAnimations:true,
animationDuration:1000,
padding: {
left: 5,
top: 5,
right: 5,
bottom: 5
},
titlePadding: {
left: 0,
top: 0,
right: 0,
bottom: 10
},
source: sampleData,
enableAnimations: true,
categoryAxis: {
dataField: ”,
description: ”,
showGridLines: true,
showTickMarks: true
},
seriesGroups: [{
type: ‘column’,
valueAxis: {
visible: true,
title: { text: ‘Daily Closing Price<br>’ },
tickMarks: { color: ‘#BCBCBC’ },
labels: {
formatSettings: {
decimalPlaces: 0
}
}
},
series: [{
dataField: ‘a’,
displayText: ‘A’
}, {
dataField: ‘b’,
displayText: ‘B’
}]
}]
};
$(‘#jqxChart’).jqxChart(settings);and i’m setting decimalPlaces = 0 but chart show decimalPlaces =3
Hello jmshim,
This is because you have a column with value 0.2 that can not be displayed if the decimal places are set to 0.
If you remove it then you will get the expected outcome.
Here is an Example.Best Regards,
Martin YotovjQWidgets team
https://www.jqwidgets.comthank you Martin Yotov!
but i have one question
My data has negative and decimal points ex(-4.555 or 2.666 ->>> -4,3). Is there any way to set it in the chart options?Hi jmshim,
Unfortunately, it is not possible to display 0 or negative values in a logarithmic scale since it is mathematically impossible for a logarithm to be equal to those values.
In your case, I suggest using a linear scale withunitInterval
set to 100: https://jsfiddle.net/k1fq5y62/
Or you can show your data in absolute values(example: -10 -> 10) and use thecolorFunction
to show users which values are supposed to be negative:
https://jsfiddle.net/u2e941z8/ – In the example, red values are negative and green are positiveI hope this answers your question. If you have any other problems, please do not hesitate to contact us again!
Best Regards,
Ivan PeevskijQWidgets team
https://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.