如何在highcharts中创建精确的自定义格式化程序

时间:2016-07-03 13:49:06

标签: javascript highcharts

我想创建一个精确的自定义工具提示格式化程序,如下所示(与原始格式一样):enter image description here

到目前为止,我所取得的成就是像这样做一个工具提示格式化程序:

enter image description here

我正在添加图形配置的原始代码:

var chart = new Highcharts.Chart({
                chart: {
                    renderTo: containerId,
                    type: 'spline',
                    zoomType: 'x'

                },
                title: {
                    text: name
                },
                xAxis: {
                    type: 'datetime'
                },
                legend: {
                    enabled: true
                },
                yAxis: yAxis,
                tooltip: {
                    enabled: isToolTipEnabled,
                    crosshairs: [true,false],
                    shared: true,
                    formatter: function() {
                        var s = '<b>' + moment(this.x).format("DD-MM-YYYY") + '</b>';

                        $.each(this.points, function(i, point) {
                            s += '<br/><span style="color:'+ point.series.color +'">\u25CF</span> ' + point.series.name + ': ' + point.y;
                        });

                        return s;
                    }
                },
                plotOptions: {
                    spline: {
                        marker: {
                            radius: 4,
                            lineColor: '#666666',
                            lineWidth: 1
                        }
                    },
                    series: {
                        cursor: 'pointer',
                        point: {
                            events: {
                                click: function(e) {
                                    callback(e.point.id);

                                }
                            }
                        },
                        animation: {
                            duration: 2000
                        },
                        marker: {
                            enabled: false

                        }
                    }
                },
                series: series
            });

0 个答案:

没有答案