jQuery UI Widgets › Forums › Chart › Pie chart different information
Tagged: javascript chart, jquery chart, percentage, Pie chart, Tooltip
This topic contains 4 replies, has 2 voices, and was last updated by ivailo 8 years, 6 months ago.
-
Author
-
Good evening to everyone,
Is it possible set in a pie chart different information (value) for chart tooltip and chart?
I attach a image to explain better what i lookink for:
On the image the tooltip and chart have the same value (125). I would have the possibility to set the value chart with the percentage of all data (27 %) keeping the current value for the tooltip. I’ve another fields where i’ve stored percentage.
Thank you very much to every one.
here is the link for the image:
https://drive.google.com/open?id=0B-_OXqxPsh1qWGhHNEFWWXEwdUUHi nico77,
You can use toolTipFormatFunction to format your tooltips.
Here is a demo.Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comHi Ivailo,
thank you very much for the answer. Sorry but i’m not able to understand how i can use toolTipFormatFunction .Could you help me please? i should put near chart the value of field ‘per’ formatted with “%” and on tooltip the value of field ‘uscite’ formatted with “€”
here is my code:var url = "caricachart.php"; var source = { datatype: "json", datafields: [ { name: 'motivo', type: 'string' }, { name: 'uscite', type: 'string' }, { name: 'per', type: 'string' }, ], url: url }; var toolTipCustomFormatFn = function (value, itemIndex, serie, group, categoryValue, categoryAxis) { return //what have i to insert here? }; var dataAdapter = new $.jqx.dataAdapter(source,{ async: false, autoBind: true, loadError: function (xhr, status, error) { alert('Error loading "' + source.url + '" : ' + error); } }); var settings = { title: "Riepilogo Spese", description: "Grafico per tipo spesa", enableAnimations: true, showLegend: true, showBorderLine: true, legendLayout: { left: 700, top: 160, width: 300, height: 200, flow: 'vertical' }, padding: { left: 5, top: 5, right: 5, bottom: 5 }, titlePadding: { left: 0, top: 0, right: 0, bottom: 10 }, source: dataAdapter, colorScheme: 'scheme01', seriesGroups: [ { type: 'pie', showLabels: true, series: [ { dataField: 'uscite', displayText: 'motivo', labelRadius: 170, initialAngle: 15, radius: 145, centerOffset: 00, toolTipFormatFunction: toolTipCustomFormatFn, //toolTipFormatSettings : { prefix: '€ ', decimalPlaces: 2}, /* formatFunction: function (value) { if (isNaN(value)) return value; return parseFloat(value) + '%'; },*/ } ] } ] }; // setup the chart $('#chartContainer').jqxChart(settings);
Thank you to everyone
Hi nico77,
Here is a modified version of our demo with included toolTipFormatFunction.
Via itemIndex you can access an object from your data and get the value of any property.Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.