Javascript 自定义高度图表-更改打印线的高度,默认情况下在特定的x和y位置显示标记值

Javascript 自定义高度图表-更改打印线的高度,默认情况下在特定的x和y位置显示标记值,javascript,jquery,charts,highcharts,Javascript,Jquery,Charts,Highcharts,我正在尝试定制海图 1) 我需要更改绘图线的高度 2) 在标记图像本身的特定位置(顶部白色圆圈内)显示标记值 这就是我迄今为止所取得的成就 Highcharts.setOptions({ global: { useUTC: false } }); /*function updateData(x,y) { var series = chart.se

我正在尝试定制海图

1) 我需要更改绘图线的高度

2) 在标记图像本身的特定位置(顶部白色圆圈内)显示标记值

这就是我迄今为止所取得的成就

Highcharts.setOptions({
            global: {
                useUTC: false
            }
        });
        /*function updateData(x,y)
        {
            var series = chart.series[0];
            series.addPoint([x, y], true, true);
        }*/
var chart;

$(function () {
    var color = '#AA34FF';

    $('#container').highcharts({
        chart: {
            events: {
                load: function(event) {
                    _bindCustomEvents();
                }
            },
            backgroundColor: 'transparent'        
        },

        series: [
            {
                color: 
                {
                    linearGradient: 
                    {
                        x1: 0,
                        y1: 0,
                        x2: 0,
                        y2: 1
                    },
                    stops: 
                    [
                        /*[0, '#a83e3e'],
                                [0.21, '#d34e47'],
                                [0.40, '#edbb5a'],
                                [0.57, '#e2e57a'],
                                [0.76, '#8dcc63'],
                                [1, '#7ab237']*/
                                [0, '#7ab237'],
                                [0.21, '#8dcc63'],
                                [0.40, '#e2e57a'],
                                [0.57, '#edbb5a'],
                                [0.76, '#d34e47'],
                                [1, '#a83e3e']
                            ]
                        },
                        lineWidth: 4,
                        marker: {
                            enabled: false,
                            fillColor: '#FFFFFF',
                            lineWidth: 2,
                            lineColor: null,
                        },
                        type: 'spline',
                        data: [1, 2, 5, 3, 6, 7, 4],
                        backgroundColor: 'transparent',
                        plotShadow : false
                    },
                    {
                        name: '',
                        marker: {
                            symbol: 'diamond'
                        },
                        //same inmage for all points
                        marker: {
                            symbol: 'url(http://fc08.deviantart.net/fs71/f/2014/016/b/9/top_marker_by_skyrbe-d72ewk0.png)'
                        },
                        data: [8,8,8,8,8,8,8],
                        type:'scatter'
                    },
                    {
                        name: '',
                        marker: {
                            symbol: 'diamond'
                        },
                        //same inmage for all points
                        marker: {
                            symbol: 'url(http://fc03.deviantart.net/fs71/f/2014/016/f/a/bottom_marker_by_skyrbe-d72ew7w.png)'
                        },
                        data: [-1,-1,-1,-1,-1,-1,-1],
                        type:'scatter'
                    }
                ],
                xAxis: {
                    categories: [
                        'Sun',
                        'Mon',
                        'Tue',
                        'Wed',
                        'Thu',
                        'Fri',
                        'Sat'
                    ],
                    title: {
                        enabled: true,
                        text: null,
                    },
                    labels: {
                        style: {
                            fontFamily: 'gestaregular',
                            fontSize: '16px',
                            color:'#fff'
                        }
                    },
                    plotLines: [
                        { // mark the weekend
                            color: 'rgba(255,255,255,0.3)',
                            width: 1,
                            value: 0,
                            dashStyle: 'dash',
                            zIndex:10
                        },
                        {
                            color: 'rgba(255,255,255,0.3)',
                            width: 1,
                            value: 1,
                            dashStyle: 'dash',
                            zIndex:10
                        },
                        {
                            color: 'rgba(255,255,255,0.3)',
                            width: 1,
                            value: 2,
                            dashStyle: 'dash',
                            zIndex:10
                        },
                        {
                            color: 'rgba(255,255,255,0.3)',
                            width: 1,
                            value: 3,
                            dashStyle: 'dash',
                            zIndex:10
                        },
                        {
                            color: 'rgba(255,255,255,0.3)',
                            width: 1,
                            value: 4,
                            dashStyle: 'dash',
                            zIndex:10
                        },
                        {
                            color: 'rgba(255,255,255,0.3)',
                            width: 1,
                            value: 5,
                            dashStyle: 'dash',
                            zIndex:10
                        },
                        {
                            color: 'rgba(255,255,255,0.3)',
                            width: 1,
                            value: 6,
                            dashStyle: 'dash',
                            zIndex:10
                        }],
                    lineWidth: 0,
                    minorGridLineWidth: 0,
                    lineColor: 'transparent',
                },
                yAxis: {
                    labels: {
                        enabled: false
                    },
                    title: {
                        enabled: true,
                        text: null,
                    }
                },
                legend: {
                    enabled: false  
                },
                minorTickLength: 0,
                tickLength: 0

            });

        });

function _bindCustomEvents()
{
    var chart = $('#container').highcharts();
    chart.setTitle({ text: ''});
    $('.highcharts-axis').hide();
    $('.highcharts-grid').hide();
    $('.highcharts-axis').find('path').hide();
}

这就是我想要它的样子:它应该是中心样条线[1,2,5,3,6,7,4]的对应值,而不是顶部圆中的“2”

1)绘图线是无限的。图形将尽可能延伸到绘图区域。因此,为了限制这一点,您如何更改您的
yAxis
max:

yAxis: {
    max: 8,
    labels: {
        enabled: false
    },
    title: {
        enabled: true,
        text: null
    }
},
或者,您可以在所需的点上创建一个
序列,并为它们指定所需高度的特定值。使列变细以模拟
绘图线将有助于:

series: [{
            name: '',
            type: 'column',
            pointWidth: 1,
            borderWidth: 0,
            data: [8, 8, 8, 8, 8, 8, 8]
        },
...
2) 圆圈中有哪些值(我猜)?“系列1:XX”?还是整个工具提示

编辑: 对于问题2,您可以使用散点序列(您的圆圈)的
dataLabel
上的
formatter
函数来执行此操作。以下是函数:

var customFormatPoint = function (pointX, seriesIndex) {
    var theChart = $('#container').highcharts();
    var yValue = null;
    var points = theChart.series[seriesIndex].options.data[pointX];
    return points;
};
您可以从以下位置调用此选项:

series: [{
    name: '',
    type: 'column',
    pointWidth: 1,
    borderWidth: 0,
    dataLabels: {
        enabled: true,
        formatter: function () {
            return customFormatPoint(this.point.x, 1);
        }
    },
    data: [7.70, 7.70, 7.70, 7.70, 7.70, 7.70, 7.70]
}, {...
这里的关键元素是你有
this.point.x
,这是散乱点的x轴位置。然后,您需要发送包含要在
dataLabel
中显示的y值的序列索引

我还删除了
绘图线
,并创建了一个仅包含宽度为1且无边框的条的系列。我不得不四处乱弄,以使棒的末端(其最大值)与散射圆的直径一致


请看这个。

是的,序列1的值应该在顶部圆圈中:-)它总是必须显示还是只显示在鼠标上,就像工具提示一样?总是显示。请看一下我的最新问题。此外,设置最大值仍会将绘制线绘制到圆的一半