javascript - 使用 Highcharts 设置启用/禁用 3D 模式

标签 javascript jquery highcharts

我制作了一个表格来动态更改图表中的值。我可以更改标题、副标题等,但是...如何更改以设置启用或禁用 3D 模式?

$(document).ready(function () {

    //Title inputText
    $('#gra_title').blur(function(){
        chart.setTitle({ text: $('#gra_title').attr("value") });
    });

    //Subtitle inputText
    $('#gra_subtitle').blur(function(){
        chart.setTitle(null, { text: $('#gra_subtitle').attr("value") });
    });

    //Credits checkbox
    $('#gra_credits_visible').click(function () {
        if ($('#gra_credits_visible').is(':checked')){ 
            chart.credits.show();
        }else{
            chart.credits.hide();
        }
    });

.........  //More events to change chart

    //3D checkbox - MY PERSONAL BUG
    $('#gra_3d_visible').click(function () {
        if ($('#gra_3d_visible').is(':checked')){ 
            chart.options.chart.options3d.enabled = true;
        }else{
            chart.options.chart.options3d.enabled = false;
        }
        chart.redraw();
        // return TRUE or FALSE, but don't change 3D/2D mode
        alert(chart.options.chart.options3d.enabled);
    });


});

这是我的图表:

chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container',
        marginRight: 0,
        events: {
            load: function () {
                this.credits.element.onclick = function () {
                    window.open('http://www.url.com', '_blank');
                }
            }
        },
        marginTop: 80,
        type: 'column',
        options3d: {
            enabled: true,
            alpha: 15,
            beta: 15,
            viewDistance: 25,
            depth: 90
        }
    },
    plotOptions: {
        column: {
            depth: 90
        }
    },
    credits: {
        enabled: true,
        text: 'MyWeb.com',
        style: {
            cursor: 'pointer',
            color: '#909090',
            fontSize: '10px'
        }
    },
    title: {
        text: 'Población Mundial'
    },
    subtitle: {
        text: 'Fuente: Wikipedia.org'
    },
    xAxis: {
        title: {
            text: 'Continentes'
        },
        categories: ['Africa', 'América', 'Asia', 'Europa', 'Oceanía']
    },
    yAxis: {
        title: {
            text: 'Población (millones)'
        },
    },
    series: [{
        name: 'Año 1800',
        data: [107, 31, 635, 203, 2]
    }]
});

我在 API Documentation 中寻找但我什么也没找到。

最佳答案

很遗憾,您需要销毁和创建图表,3d 的更新选项不可用。

关于javascript - 使用 Highcharts 设置启用/禁用 3D 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24604866/

相关文章:

javascript - react / react Hook : I am trying to trigger a validation using hooks whenever a user leaves input field

javascript - 在 MVC3 的 DropdownList 中加载大量数据

jQuery:加载方法 - 重新加载没有 url 的页面的特定部分?

javascript - 如何使用 Highchartsng 动态添加新的 Highchart

javascript - Highcharts - 更新特定类别值

javascript - Cocoa:WKWebView/WebView 无法打开 Gmail 或 Inbox 内的链接

javascript - Wordpress 帖子/页面编辑器无法工作 - 无法读取属性错误

jQuery 加载 HTML 到 <div>

javascript - Laravel 5.5 中使用 AJAX 提交表单

javascript - Highcharts 列区域