0

我无法弄清楚如何从我的数据中获取“to”和“from”日期到工具提示中。尝试了我在 SO 周围找到的各种方法。有人有任何提示吗?我通常从 CSV 加载数据。现在数据是硬编码在代码中的。

var options = {
    chart: {
        zoomType: 'y',
        borderWidth: '0',
        borderRadius: '15',
        renderTo: 'container',
        inverted: true,
        backgroundColor: {
            linearGradient: [0, 0, 500, 500],
            stops: [
                [0, 'rgb(44, 44, 58)'],
                [1, 'rgb(62, 62, 62)']
            ]
        },
        plotBackgroundColor: 'rgba(255, 255, 255, .9)'
    },
    tooltip: {
        formatter: function () {
            var point = this.point;
            return '<b>' + point.category +
                '</b><br/>' + Highcharts.dateFormat('%b %e, %Y', this.y) +
                ' - ' + Highcharts.dateFormat('%b %e, %Y', this.series[0]);
        }
    },
    legend: {
        enabled: false
    },
    title: {
        text: 'EVMS Calendar'
    },
    xAxis: {
        categories: []
    },
    plotOptions: {
        series: {
            grouping: false
        }
    },
    yAxis: {
        type: 'datetime',
        minRange: '604800000',
        startOnTick: false,
        endOnTick: false,
        title: {
            text: ''
        }
    },
    series: []
},
categories = [];;

//// This is the data processing section \\\\
// Hard Coded Data
var data ="valid data";

// Split the lines
var lines = data.split('\n');

// Iterate over the lines and add categories or series
// Split the data by comma
// Get the number of items in the object (iLen)
// Series start
// Series type is columnrange
// Servies name is item 0 of the line (employees name)
$.each(lines, function (lineNo, line) {
    var items = line.split(','),
        iLen = items.length,
        series = {
            type: 'columnrange',
            data: [],
            name: items[0]
        };
    // Start categories
    // for each items (0) get the row data (dates) and push to categories(line number, from and to)
    categories.push(items[0]);
    for (var i = 1; i < iLen; i += 2) {
        var from = (new Date(items[i])).getTime(),
            to = (new Date(items[i + 1])).getTime();
        if (!isNaN(from) && !isNaN(to)) {
            series.data.push([lineNo, from, to]);
        }
    };
    options.series.push(series);
});

options.xAxis.categories = categories;

// Create the chart
var chart = new Highcharts.Chart(options);
4

1 回答 1

0

啊,我的坏。它的 this.point.high / low。我通过浏览 chrome 中的元素发现了

于 2013-09-13T04:09:52.540 回答