jQuery UI Widgets › Forums › Chart › Facing problem with PIE chart
Tagged: chart, formatFunction, jqxChart, nan, pie
This topic contains 3 replies, has 2 voices, and was last updated by Dimitar 9 years, 9 months ago.
-
Author
-
Sorry for posting the wrong question in wrong forum.
Here is my sample code snippet…
function drawPieTokenChart() {
// prepare chart data as an array
var source =
{
datatype: “csv”,
datafields: [
{ name: ‘Token’ },
{ name: ‘Count’ }
],
url: $(‘#hdnPieChartData’).val() + ‘?t=’ + new Date().getTime()
};
var dataAdapter = new $.jqx.dataAdapter(source, {
async: false, autoBind: true, loadError: function (xhr, status, error) { //alert(‘Error loading “‘ + source.url + ‘” : ‘ + error);
}
});
// prepare jqxChart settings
var settings = {
title: token,
description: “”,
enableAnimations: true,
showLegend: true,
showBorderLine: true,
//padding: { left: 5, top: 5, right: 5, bottom: 5 },
//titlePadding: { left: 0, top: 0, right: 0, bottom: 10 },
source: dataAdapter,
colorScheme: ‘scheme03’,
seriesGroups:
[
{
type: ‘pie’,
showLabels: false,
series:
[
{
dataField: ‘Count’,
displayText: ‘Token’,
labelRadius: 45,
initialAngle: 0,
radius: 125,
centerOffset: 0,
offsetY: 200,
formatFunction: function (value) {
if (isNaN(value))
return value;
return parseFloat(value) + ‘%’;
},
}
]
}
]
};
// setup the chart
$(‘#pieChart’).jqxChart(settings);
}$(‘#hdnPieChartData’).val() – contains the path of the csv file from where I am reading the data.
Thanks,
HarishHello Harish,
Instead of your formatFunction, you may try applying the formatSettings property as follows:
formatSettings: { sufix: '%' }
If the issue persists, please share some sample data so that we may test your code. Remember to format your sample snippet by selecting it and pressing the
code
button in the toolbar.Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
Still, it does not solve the issue of NaN. If I remove formatFunction and use formatSettings {sufix:’%’}, I can still see an empty legend displayed.
Any idea, why?Thanks,
Harish. PHi Harish. P,
Please share some sample data so that we may test your code and see what causes the issue. Remember to format your sample snippet by selecting it and pressing the
code
button in the toolbar. Alternatively, post a JSFiddle example.Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.