HighCharts の HTML-table-to-chart スクリプトを使用して、テーブルから折れ線グラフを作成しようとしています。
私はx軸を持ちたいdatetime
ので、ここに私がやったことです:
Date.parse(this.innerHTML)
行ヘッダーを日付文字列に変換するために使用します。- xAxis オプション オブジェクトに設定
type
します。datetime
日付変換は機能しており、デフォルトのツールチップに正しく表示されますが、グラフ自体は x 値を日時ではなくカテゴリのように扱っています。ポイントオブジェクトの設定方法に関係していると思いますが、修正方法がわかりません。
Highcharts.visualize = function(table, options) {
// the categories
options.xAxis.categories = [];
$('tbody th', table).each(function(i) {
var date = Date.parse(this.innerHTML);
options.xAxis.categories.push(date);
});
// the data series
options.series = [];
$('tr', table).each(function(i) {
var tr = this;
$('th, td', tr).each(function(j) {
if (j > 0) { // skip first column
if (i === 0) { // get the name and init the series
options.series[j - 1] = {
name: this.innerHTML,
data: []
};
} else { // add values
options.series[j - 1].data.push(parseFloat(this.innerHTML));
}
}
});
});
charts[charts.length] = new Highcharts.Chart(options);
};
助言がありますか?
ここにフィドルがあります:http://jsfiddle.net/supertrue/et2Vy/