3D柱状图动态数据交互(highcharts图表)

npm install highcharts --save

<template>
    <div class="box">
        <!--文档地址 https://www.hcharts.cn/demo/highcharts/3d-pie-donut   -->

        <div id="container"></div>
        <tr>
            <td>α 角(内旋转角)</td>
            <td><input @input="changea($event, 'alpha')" type="range" min="0" max="45" value="15" /></td>
        </tr>
        <tr>
            <td>β 角(外旋转角)</td>
            <td><input @input="changea($event, 'alpha')" type="range" min="-45" max="45" value="15" />
            </td>
        </tr>
        <tr>
            <td>深度</td>
            <td><input @input="changea($event, 'depth')" type="range" min="20" max="100" value="50" />
            </td>
        </tr>
    </div>

 

<script>

import Highcharts from 'highcharts';
import HighchartsMore from 'highcharts/highcharts-more';
import HighchartsDrilldown from 'highcharts/modules/drilldown';
import Highcharts3D from 'highcharts/highcharts-3d';

HighchartsMore(Highcharts)
HighchartsDrilldown(Highcharts);
Highcharts3D(Highcharts);

export default {
    name: "",
    data() {
        return {
            options: {
                chart: {
                    renderTo: 'container',
                    type: 'column',
                    options3d: {
                        enabled: true,
                        alpha: 15,
                        beta: 15,
                        depth: 50,
                        viewDistance: 25
                    }
                },
                title: {
                    text: '交互性3D柱状图'
                },
                subtitle: {
                    text: '可通过滑动下方滑块测试'
                },
                plotOptions: {
                    column: {
                        depth: 25
                    }
                },
                series: [{
                    name: '图例1',
                    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
                }]
            },
            chart: () => { },
        }
    },
    created() {

    },
    mounted() {
        // 图表初始化函数
        this.init()
    },
    methods: {
        init() {
            this.chart = Highcharts.chart('container', this.options);

        },

        changea(e, id) {
            this.chart.update({
                chart: {
                    options3d: {
                        [id]: Number(e.target.value),
                    }
                },

            })
            console.log('this.options', this.options);

        }

    }
}
</script>
<style lang="scss" scoped>
.box {
    #container {
        width: 600px;
        height: 400px;
    }
}

/* @import url(); 引入css类 */
</style>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值