我正在使用来自外部xml文件的数据创建一个简单的行高图,但是我不能让它显示小数点,例如,xml返回25.6,25.1,25.9并且图表将该行放入25和工具提示显示25而不是25.6等。 这是代码:
function chart1(start, end) {
var options = {
chart: {
renderTo: 'chart1',
type: 'line'
},
colors: ['#D9CDB6'],
title: {
text: 'Data coming from A4 table'
},
tooltip:{
formatter:function(){
return Highcharts.numberFormat(this.y,2,',')
}
},
dataLabels: {
enabled: true,
formatter: function () {
return Highcharts.numberFormat(this.y,2);
}
},
xAxis: {
labels: {
enabled: false
},
categories: []
},
yAxis: {
title: {
text: 'Volts'
},
labels: {
format: '{value:.2f}'}
},
series: []
};
// Load the data from the XML file
$.get('chart1data.php?start=' + start + '&end=' + end, function(xml) {
// Split the lines
var $xml = $(xml);
// push categories
$xml.find('categories item').each(function(i, category) {
options.xAxis.categories.push($(category).text());
});
// push series
$xml.find('series').each(function(i, series) {
var seriesOptions = {
name: $(series).find('name').text(),
data: []
};
// push data points
$(series).find('data point').each(function(i, point) {
seriesOptions.data.push(
parseInt($(point).text())
);
});
// add it to the options
options.series.push(seriesOptions);
});
var chart = new Highcharts.Chart(options);
});
}
并且chart1data返回:
<chart><categories><item>2014-10-17 05:00:09</item><item>2014-10-19 03:01:01</item><item>2014-10-19 03:02:04</item><item>2014-10-19 03:03:06</item><item>2014-10-19 02:04:51</item><item>2014-10-19 02:05:04</item><item>2014-10-17 05:06:52</item><item>2014-10-17 05:07:08</item><item>2014-10-17 05:08:12</item><item>2014-10-19 02:09:04</item><item>2014-10-19 02:10:05</item><item>2014-10-19 02:11:01</item><item>2014-10-19 02:12:03</item><item>2014-10-19 02:13:06</item><item>2014-10-19 02:14:01</item><item>2014-10-18 23:15:29</item><item>2014-10-18 23:16:03</item><item>2014-10-18 23:17:05</item><item>2014-10-18 13:18:15</item><item>2014-10-18 13:19:06</item><item>2014-10-18 13:20:03</item><item>2014-10-18 13:21:07</item><item>2014-09-29 19:22:55</item><item>2014-09-29 19:23:05</item><item>2014-10-18 23:24:00</item><item>2014-10-18 23:25:03</item><item>2014-10-18 23:26:05</item><item>2014-10-18 23:27:00</item><item>2014-10-18 23:28:02</item><item>2014-10-18 23:29:05</item><item>2014-10-18 23:30:00</item><item>2014-10-18 23:31:02</item><item>2014-10-18 12:32:39</item><item>2014-10-18 12:33:10</item><item>2014-09-29 19:34:42</item><item>2014-09-29 19:35:10</item><item>2014-10-18 12:36:01</item><item>2014-10-18 12:37:00</item><item>2014-10-18 23:38:02</item><item>2014-10-18 12:39:00</item><item>2014-10-18 12:40:01</item><item>2014-10-17 04:41:51</item><item>2014-10-17 04:42:07</item><item>2014-10-17 04:43:11</item><item>2014-10-17 04:44:00</item><item>2014-10-17 04:45:03</item><item>2014-10-17 04:46:07</item><item>2014-09-29 19:47:11</item><item>2014-10-17 04:48:03</item><item>2014-10-17 04:49:13</item><item>2014-10-17 04:50:01</item><item>2014-10-17 04:51:05</item><item>2014-10-17 04:52:09</item><item>2014-10-17 04:53:12</item><item>2014-10-17 04:54:00</item><item>2014-10-17 04:55:10</item><item>2014-10-17 04:56:14</item><item>2014-10-17 04:57:02</item><item>2014-10-17 04:58:00</item><item>2014-10-17 04:59:59</item></categories><series><name>A4</name><data><point>25,60</point><point>25,61</point><point>25,63</point><point>25,60</point><point>25,62</point><point>25,62</point><point>25,61</point><point>25,60</point><point>25,60</point><point>25,62</point><point>25,62</point><point>25,62</point><point>25,61</point><point>25,64</point><point>25,62</point><point>25,60</point><point>25,64</point><point>25,63</point><point>25,56</point><point>25,58</point><point>25,58</point><point>25,55</point><point>25,58</point><point>25,63</point><point>25,61</point><point>25,62</point><point>25,63</point><point>25,61</point><point>25,62</point><point>25,61</point><point>25,62</point><point>25,61</point><point>25,59</point><point>25,62</point><point>25,59</point><point>25,59</point><point>25,60</point><point>25,58</point><point>25,62</point><point>25,62</point><point>25,61</point><point>25,63</point><point>25,60</point><point>25,58</point><point>25,59</point><point>25,59</point><point>25,60</point><point>25,61</point><point>25,63</point><point>25,62</point><point>25,61</point><point>25,62</point><point>25,59</point><point>25,60</point><point>25,61</point><point>25,59</point><point>25,62</point><point>25,66</point><point>25,59</point><point>25,63</point></data></series></chart>
尝试改变,到。作为小数分隔符,但没有发生任 感谢
答案 0 :(得分:0)
解决了将parseInt($(point).text())更改为parseFloat($(point).text())