javascript - Highcharts data plugin decimal separator -
if got highcharts 3 data plugin read values table. not problem english because of . decimal separator. in dutch table uses , decimal separator. graph don't show because of data plugin can't see 5,5 same 5.5.
this javascript code:
<!-- language: lang-js --> $('#grafiek620').highcharts({ chart: { type: 'bar' }, credits: { enabled: false }, data: { table: document.getelementbyid('datatable620') }, title: { text: jquery('#datatable620').data('labeltitle') }, xaxis: { labels: { rotation: 0 }, title: { text: jquery('#datatable620').data('labelx') } }, yaxis: [{ min: 0, title: { text: jquery('#datatable620').data('labely') }, labels: { rotation: 0 } }, { opposite: true, title: { text: jquery('#datatable620').data('labelz') }, }], legend: { layout: "horizontal" } });
i have added js fiddle: http://jsfiddle.net/knscs/
ok, have 1 solution here :
var convertstringtofloat = function( datas ) { return datas.map(function(i, el) { var str = $(el).text(); return parsefloat(str.replace(",", ".")); }); } convertstringtofloat ( $("td", $('#datatable620') ) )
here have array of float, have create series highchart.
series: [{ data: convertstringtofloat ( $("td", $('#datatable620') ) ) }]
here working example : http://jsfiddle.net/knscs/3/
to display number (in dutch way), have ability in options of highcharts
:
highcharts.setoptions({ lang: { decimalpoint: ',' } });
ps : name of functions of choice... didn't think convertstringtofloat
not choice ;)
Comments
Post a Comment