Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/464.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在渲染后更改Highcharts图例显示_Javascript_Angularjs_Highcharts - Fatal编程技术网

Javascript 在渲染后更改Highcharts图例显示

Javascript 在渲染后更改Highcharts图例显示,javascript,angularjs,highcharts,Javascript,Angularjs,Highcharts,图表渲染后是否可以更改Highcharts显示设置?还是我总是需要重新绘制图表 请参见,在屏幕调整大小时,我希望将图例框从右下移动,如图所示: 在编程方面,我需要的是从 发件人: 致: 在图表呈现之后 非常感谢 这里有一个解决方案: @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width"

图表渲染后是否可以更改Highcharts显示设置?还是我总是需要重新绘制图表

请参见,在屏幕调整大小时,我希望将图例框从右下移动,如图所示:

在编程方面,我需要的是从

发件人:

致:

在图表呈现之后

非常感谢

这里有一个解决方案:

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>BBBIndex</title>
    @*credit goes to http://stackoverflow.com/questions/33755669/highcharts-change-legend-options-dynamically*@
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script src="https://code.highcharts.com/highcharts.js"></script>
    <script src="https://code.highcharts.com/modules/exporting.js"></script>
    <script type="text/javascript">
        $(function () {

            $(document).ready(function () {

                // Build the chart
                $('#container').highcharts({
                    chart: {
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false,
                        type: 'pie'
                    },
                    legend: {
                        layout: 'horizontal',
                        align: 'center',
                        verticalAlign: 'bottom'
                    },
                    title: {
                        text: 'Browser market shares January, 2015 to May, 2015'
                    },
                    tooltip: {
                        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: false
                            },
                            showInLegend: true
                        }
                    },
                    series: [{
                        name: 'Brands',
                        colorByPoint: true,
                        data: [{
                            name: 'Microsoft Internet Explorer',
                            y: 56.33
                        }, {
                            name: 'Chrome',
                            y: 24.03,
                            sliced: true,
                            selected: true
                        }, {
                            name: 'Firefox',
                            y: 10.38
                        }, {
                            name: 'Safari',
                            y: 4.77
                        }, {
                            name: 'Opera',
                            y: 0.91
                        }, {
                            name: 'Proprietary or Undetectable',
                            y: 0.2
                        }]
                    }]
                });
            });

            $("#btnProgChgLegend").toggle(
                function () {
                    var c = $('#container').highcharts();
                    var o = c.options;
                    o.legend.layout = "vertical";
                    o.legend.align = "right";
                    o.legend.verticalAlign = "top";
                    //next line is key
                    c.legend.render();
                },
                function () {
                    var c = $('#container').highcharts();
                    var o = c.options;
                    o.legend.layout = "horizontal";
                    o.legend.align = "center";
                    o.legend.verticalAlign = "bottom";
                    c.legend.render();
                });
            });
    </script>
</head>
<body>
    <div>
        <div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
        <button type="button" id="btnProgChgLegend">Change Legend Programmatically</button>
    </div>
</body>
</html>
@{
布局=空;
}
BBBIndex
@*功劳归于http://stackoverflow.com/questions/33755669/highcharts-change-legend-options-dynamically*@
$(函数(){
$(文档).ready(函数(){
//绘制图表
$(“#容器”)。高图({
图表:{
plotBackgroundColor:null,
plotBorderWidth:null,
影子:错,
键入:“馅饼”
},
图例:{
布局:“水平”,
对齐:'居中',
垂直排列:“底部”
},
标题:{
正文:“浏览器市场份额2015年1月至2015年5月”
},
工具提示:{
pointFormat:“{series.name}:{point.percentage:.1f}%”
},
打印选项:{
馅饼:{
allowPointSelect:true,
光标:“指针”,
数据标签:{
已启用:false
},
showInLegend:对
}
},
系列:[{
名称:'品牌',
colorByPoint:对,
数据:[{
名称:“Microsoft Internet Explorer”,
y:56.33
}, {
名称:“Chrome”,
y:24.03,
切碎:是的,
所选:真
}, {
名称:“Firefox”,
y:10.38
}, {
名称:“Safari”,
y:4.77
}, {
名字:'歌剧',
y:0.91
}, {
名称:“专有或不可检测”,
y:0.2
}]
}]
});
});
$(“#btnprogglegend”)。切换(
函数(){
var c=$(“#容器”).highcharts();
var o=c.期权;
o、 legend.layout=“垂直”;
o、 legend.align=“right”;
o、 legend.verticalign=“顶部”;
//下一行是关键
c、 legend.render();
},
函数(){
var c=$(“#容器”).highcharts();
var o=c.期权;
o、 legend.layout=“水平”;
o、 legend.align=“中心”;
o、 legend.verticalAlign=“底部”;
c、 legend.render();
});
});
以编程方式更改图例
legend : {
        layout: 'horizontal',
        align: 'center',
        verticalAlign: 'bottom',
}
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>BBBIndex</title>
    @*credit goes to http://stackoverflow.com/questions/33755669/highcharts-change-legend-options-dynamically*@
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script src="https://code.highcharts.com/highcharts.js"></script>
    <script src="https://code.highcharts.com/modules/exporting.js"></script>
    <script type="text/javascript">
        $(function () {

            $(document).ready(function () {

                // Build the chart
                $('#container').highcharts({
                    chart: {
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false,
                        type: 'pie'
                    },
                    legend: {
                        layout: 'horizontal',
                        align: 'center',
                        verticalAlign: 'bottom'
                    },
                    title: {
                        text: 'Browser market shares January, 2015 to May, 2015'
                    },
                    tooltip: {
                        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: false
                            },
                            showInLegend: true
                        }
                    },
                    series: [{
                        name: 'Brands',
                        colorByPoint: true,
                        data: [{
                            name: 'Microsoft Internet Explorer',
                            y: 56.33
                        }, {
                            name: 'Chrome',
                            y: 24.03,
                            sliced: true,
                            selected: true
                        }, {
                            name: 'Firefox',
                            y: 10.38
                        }, {
                            name: 'Safari',
                            y: 4.77
                        }, {
                            name: 'Opera',
                            y: 0.91
                        }, {
                            name: 'Proprietary or Undetectable',
                            y: 0.2
                        }]
                    }]
                });
            });

            $("#btnProgChgLegend").toggle(
                function () {
                    var c = $('#container').highcharts();
                    var o = c.options;
                    o.legend.layout = "vertical";
                    o.legend.align = "right";
                    o.legend.verticalAlign = "top";
                    //next line is key
                    c.legend.render();
                },
                function () {
                    var c = $('#container').highcharts();
                    var o = c.options;
                    o.legend.layout = "horizontal";
                    o.legend.align = "center";
                    o.legend.verticalAlign = "bottom";
                    c.legend.render();
                });
            });
    </script>
</head>
<body>
    <div>
        <div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
        <button type="button" id="btnProgChgLegend">Change Legend Programmatically</button>
    </div>
</body>
</html>