jQuery UI Widgets › Forums › Chart › Proportional Display of CategoryAxis In Column Chart
This topic contains 10 replies, has 2 voices, and was last updated by vinodn 9 years, 11 months ago.
-
Author
-
Hi Team,
I am using column chart with decimal value on value axis [Y Axis]. The data series being displayed irregularly/repeated value.
For example : 0, 0.1, 0.1, 0.1, 0.2, 0.5 [using decimalPlaces property in formatsetting upto 1]I have 3 times the value ‘0.1’. Here is the problem that chart of look is not giving the feeling of real value as value are wrongly plotted.
I would like to display my valueAxis only once on chart.
Kindly do needful.
Thank you,
Rinkal ParmarHi Rinkal Parmar,
Are you referring to the valueAxis (which is usually the y-axis) or the xAxis/categoryAxis (which is usually the x-axis)? Please clarify and share your chart initialization code and some sample data so that we may better understand your issue.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Referring to y-axis. You can view the same in the below image. Basically, the json data object that is bound to the chart has values upto one decimal precision. However, the chart renders with scale upto 2 decimal precision which is wrong as even the scale should have only one decimal precision. Hence, we set “decimalPlaces” property of the chart in “formatsetting” to “1”. But that is now giving us an incorrect scale with duplicate values.
Hi Rinkal Parmar,
I think this will be fixed if you set the valueAxis unitInterval property to 0.1.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/We can’t hard code it. The values are dynamic. They can be in 0.1, 0.2, 0.3 or in 10, 20, 30. Hard coding unitInterval property to 0.1 would make the chart look full of horizontal lines when the values are big.
Hi Rinkal Parmar,
If setting decimalPlaces to 2 is unacceptable (although I did not understand why), you can implement a format of your own choice using the valueAxis formatFunction callback.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
I want to set Dynamic value to unitInterval. Is there any way to find MAX Y-Axis value?
Regards,
RinkalHi Rinkal,
You can find the largest value in the data adapter’s beforeLoadComplete callback:
<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdraw.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxchart.core.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript"> $(document).ready(function () { // prepare chart data as an array var source = { datatype: "csv", datafields: [ { name: 'Country' }, { name: 'GDP' }, { name: 'DebtPercent' }, { name: 'Debt' } ], url: '../sampledata/gdp_dept_2010.txt' }; var largest; var dataAdapter = new $.jqx.dataAdapter(source, { async: false, autoBind: true, beforeLoadComplete: function (data) { largest = parseFloat(data[0]['DebtPercent']); for (var i = 0; i < data.length; i++) { var newValue = parseFloat(data[i]['DebtPercent']); if (newValue > largest) { largest = newValue; } } alert(largest); } }); // prepare jqxChart settings var settings = { title: "Economic comparison", description: "GDP and Debt in 2010", showLegend: true, enableAnimations: true, padding: { left: 5, top: 5, right: 5, bottom: 5 }, titlePadding: { left: 90, top: 0, right: 0, bottom: 10 }, source: dataAdapter, xAxis: { dataField: 'Country', gridLines: { visible: true }, valuesOnTicks: false }, colorScheme: 'scheme01', columnSeriesOverlap: false, seriesGroups: [ { type: 'line', valueAxis: { visible: true, unitInterval: 10, title: { text: 'Debt (% of GDP)' }, gridLines: { visible: false }, labels: { horizontalAlignment: 'left' } }, series: [ { dataField: 'DebtPercent', displayText: 'Debt (% of GDP)' } ] } ] }; // setup the chart $('#chartContainer').jqxChart(settings); }); </script> </head> <body class='default'> <div id='chartContainer' style="width: 850px; height: 500px;"> </div> </body> </html>
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
Thank you for the replay! Using this solution I can avoid manually calculation outside the chart.
And one more question, can I use callback function for unitInterval?
i.e.,
…
seriesGroups:
[
{
type: ‘line’,
valueAxis:
{
visible: true,
unitInterval: fuction() { // Some logic.. },
title: { text: ‘Debt (% of GDP)’ },
gridLines: { visible: false },
labels: { horizontalAlignment: ‘left’ }
},
series: [
{ dataField: ‘DebtPercent’, displayText: ‘Debt (% of GDP)’ }
]
}
]
…Best Regards,
RinkalHi Rinkal,
No, unitInterval has to have a numeric value. However, you may set it to the result of a function which returns a number, e.g.:
... unitInterval: calculateUnitInterval(), ...
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Thanks Dimitar.
-
AuthorPosts
You must be logged in to reply to this topic.