Highcharts 3D饼图(3)tooltip format使用

在这里插入图片描述


  tooltip: { 
                    backgroundColor:'rgba(206,94,74,.95)', //数据提示框的背景颜色
                    borderColor:'rgba(206,94,74,.9)', //边框颜色
                    useHTML: true,  //是否使用HTML编辑提示信息
             		formatter:function(){
   					console.log(this) //控制台输出可以看到有很多属性
                    return '<b style="color:#fff">'+this.key+'</b><p style="color:#fff;">'+this.y+'<span style="color:rgba(250, 250, 250, 0.66);">'+' ('+ Highcharts.numberFormat( this .percentage, 1 ) + '%'+')'+'</span>'+'</p>'
             },
            		valueDecimals: 2 //数据值保留小数位数
                },

		
											...
											...
											...
							    // 数据格式是这样的(参考)
							    
 series: [
                    {
                        type: "pie",
                        data: [
                            ["邮政包裹", 30],
                            ["圆通快递", 20],
                            ["京东快递", 30],
                            ["申通快递", 50],
                            ["德邦物流", 20],
                            ["天天快递", 20],
                            ["其他", 30],
                            ["顺丰快递", 10],
                            ["中通快递", 30],
                            ["韵达快递", 20],
                        ],
                    },
                ],
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
你可以按照以下步骤在Vue中使用Highcharts来绘制3D饼图: 1. 在你的项目的main.js文件中引入Highchartshighcharts-3d插件: ```javascript import Highcharts from 'highcharts' import Highcharts3d from 'highcharts/highcharts-3d' Highcharts3d(Highcharts) ``` 2. 在你的组件中创建一个容器来显示图表,并引入Highcharts库: ```vue <template> <div class="container"> <div :id="id" :option="option" class="chart-container"></div> </div> </template> <script> import Highcharts from 'highcharts' export default { props: { id: { type: String }, // 用于区分多个图表的唯一标识符 option: { type: Object } // 图表的配置选项 }, data() { return { chart: null } }, mounted() { // 在组件加载完成后初始化图表 this.setOption() }, methods: { setOption() { // 销毁之前的图表实例 if (this.chart) { this.chart.destroy() } // 创建一个新的图表实例并渲染到指定容器中 this.chart = Highcharts.chart(this.id, this.option) // 重新调整图表大小,以适应容器 this.chart.reflow() } } } </script> <style scoped> .container { width: 100%; height: 100%; background: #043b8c; .chart-container { width: 100%; height: 100%; } /* 去除水印 */ .highcharts-credits { display: none; } } </style> ``` 3. 在你的父组件中,使用刚才创建的组件,并传入相应的id和配置选项: ```vue <template> <div> <pie-chart id="chart1" :option="chartOptions"></pie-chart> </div> </template> <script> import PieChart from './PieChart.vue' export default { components: { PieChart }, data() { return { chartOptions: { chart: { type: 'pie', options3d: { enabled: true, alpha: 45, beta: 0 } }, title: { text: '3D饼图' }, series: [{ name: 'Brands', data: [ ['Chrome', 61.41], ['Internet Explorer', 11.84], ['Firefox', 10.85], ['Edge', 4.67], ['Safari', 4.18], ['Other', 7.05] ] }] } } } } </script> ``` 这样,你就可以在Vue中使用Highcharts来绘制3D饼图了。记得根据你的需求修改配置选项和数据。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值