Jquery 如何在highcharts中的标志系列中添加动态数据

Jquery 如何在highcharts中的标志系列中添加动态数据,jquery,json,highcharts,Jquery,Json,Highcharts,我在这段代码中获取数据我的图表正在运行,我在X轴上为最大值和最小值添加了标志,现在我想在标志内显示评级。但这里我的分类数据是来的,但评级不是来的。这里我的数据和评级是动态数据,不是静态的。我已经尝试过堆栈溢出建议,也尝试过包含highstock.js和highcharts.js文件,但仍然不起作用。请给我柱状图的正确答案 $(document). ready(function() { var options = { chart: {

我在这段代码中获取数据我的图表正在运行,我在X轴上为最大值和最小值添加了标志,现在我想在标志内显示评级。但这里我的分类数据是来的,但评级不是来的。这里我的数据和评级是动态数据,不是静态的。我已经尝试过堆栈溢出建议,也尝试过包含highstock.js和highcharts.js文件,但仍然不起作用。请给我柱状图的正确答案

  $(document). ready(function() {
        var options = {
            chart: {
                renderTo: 'container',
                type: 'column',
                marginRight: 130,
                marginBottom: 50
            },
            title: {
                text: 'Top 15 Projects Facilities Rating',
                x: -20 //center
            },
            subtitle: {
                text: '',
                x: -20
            },
            xAxis: {
                categories: []
            },
            yAxis: {
                title: {
                    text: 'Facilities Rating'
                },
               stackLabels: {
                enabled: true,
                style: {
                    fontWeight: 'bold',
                    color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                }
            },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                formatter: function() {
                        return '<b>'+ this.series.name +'</b><br/>'+
                        this.x +': '+ this.y;
                }
            },
            plotOptions:{
            column: {
                stacking: 'normal',
                dataLabels: {
                    enabled: true,
                    color:'white'
                }
            }
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'top',
                borderWidth: 0
            },
            series: [{
                name:'RATING',
                data:[],
                id:'dataseries'
           },
    {      
    type: 'flags',
    onSeries: 'dataseries',
    data: [{
        x: 0,
        text: 'Minimum Facilites Rating',
        title: 'Min'
    }, {
        x: 15,
        text: 'Maximum Facilites Rating',
        title: 'max'
    }],
    width: 30,
    showInLegend: false
    }]
        }

        $.getJSON("bargraph_data.php", function(json) {
            options.xAxis.categories = json[0]['data'];
           // options.series.splice(0,0, json[1]);
            options.series[0].data = json[1]['data'];

            chart = new Highcharts.Chart(options);

        });
    });
你也可以登录[链接]
请给出如何将y值添加到标志系列点动态而非静态的解决方案。

您正在覆盖默认系列的标志。。选中此行:

options.series[0] = json[1]; 
它将用新系列替换标志。我想您需要预先设置选项,如下所示:

options.series.splice(0, 0, json[1]);

谢谢@Pawel Fus您的建议很有帮助,但还有一个问题要问。数据在系列2中未定义,且标志显示在图表底部,我要求在图表顶部的上侧。这是使用HighCharts从MySQL获取数据的柱状图为什么数据在系列2中未定义?如果序列不存在,或者序列的Id与此处不匹配:onSeries:“dataseries”则标志将显示在xAxis.Fus上。我已在序列中添加了此代码。它仍然显示未定义。但在序列2中,我的数据是动态的。请告诉我如何在数据[]内调用它,/-代码序列:[{data:[],id:'dataseries',type:'flags',onSeries:'dataseries',//还有一件事我想在条的顶部显示最小和最大标志。但它显示条的底部。这里我使用垂直对齐:'top',什么代码?你应该为数据系列添加id:'dataseries',而不是为标志。什么显示为未定义?你在哪里看到的u获取标志的垂直对齐…?没有这样的选项。Fus现在仍然无法在dataseries中工作。请给出我的代码示例。我想知道鼠标悬停在min或max上的时间。然后它显示为项目名称:带有来自db的评级。但在鼠标悬停时,它只显示项目名称:undefined。请在此链接上查看标志是如何显示的ws在图表的顶部…但在我的例子中它显示了图表的底部。这是我想要的。所以请建议我