Highcharts

Highcharts 是一个用纯 JavaScript 编写的一个图表库, 能够很简单便捷的在 Web 网站或是 Web 应用程序添加有交互性的图表,并且免费提供给个人学习、个人网站和非商业用途使用。

Highcharts 支持的图表类型有直线图、曲线图、区域图、柱状图、饼状图、散状点图、仪表图、气泡图、瀑布流图等多达 20 种图表,其中很多图表可以集成在同一个图形中形成混合图。

饼图

<!--
 * @Description: 
 * @Version: 2.0
 * @Autor: LMJ
 * @Date: 2021-09-07 15:05:21
 * @LastEditors: LMJ
 * @LastEditTime: 2021-09-17 13:16:18
-->
<template>
  <div style="width: 100%; height: 100%">
    <highcharts :options="chartOptions" :callback="myCallback" style="min-width: 450px; min-height: 380px; "></highcharts>
	
  </div>
</template>

<script>

import { Chart } from "highcharts-vue";
import { color, reduce } from 'highcharts';
export default {
  components: {
    highcharts: Chart
  },
  data() {
    return {
      chartOptions: {
        chart: {
          backgroundColor: 'rgba(255,255,255,0)',
		type: 'pie',
		options3d: {
			enabled: true,
			alpha: 45,
			beta: 0
		}
	},
	title: {
		text: '标题',
          left: "center",
          top: "1.5%",
          style: {
            color: "#000000",

          },
	},
	tooltip: {
		pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
	},
	plotOptions: {
		pie: {
			allowPointSelect: true,
			cursor: 'pointer',
			depth: 89,
			dataLabels: {
				enabled: true,
				format: '{point.percentage:.1f} %',
				style: {
					 textOutline: 'none' 
                   }
			}
		}
	},
  credits:{
     enabled: false // 禁用版权信息
},colors: [ '#7cb5ec','#7fb80e', '#ffc000' ,'#d48265'],
	series: [{
		size:'90%',
		type: 'pie',
		name: '占比',
		data: [
			['A.非常有信心',  10.0,],
			['B.比较有信心',   32.50],
			['C.有信心',   25.0],
			{
				name: 'D.当前无信心',
				y: 32.50,
				sliced: true,
				selected: true,
				// 'color': 'Highcharts.getOptions().colors[8]',
			},
			
		]
	}]
      }
    };
  },
  methods: {
    myCallback() {
    //   console.log("this is callback function");
    }
  }
};
</script>

<style scoped lang="scss">
.highcharts-container {
  width:100%;
  height: 100%;
  border: 1px solid #ddd;
  margin: auto;
}

</style>

有图例的

 

<template>
  <div id="mains">
    <div class="title">
      <dv-decoration-3
        :reverse="true"
        style="width: 36px; height: 30px"
      />标题    
<dv-decoration-3 style="width: 36px; height: 30px" />
    </div>
    <highcharts :options="chartOptions" :callback="myCallback" style="min-width: 350px; min-height: 320px; "></highcharts>
  </div>
</template>

<script>

import { Chart } from "highcharts-vue";
import { color } from 'highcharts';
export default {
  components: {
    highcharts: Chart
  },
  data() {
    return {
      chartOptions: {
         chart: {
          backgroundColor: 'rgba(255,255,255,0)',

                    type: 'pie',
                    options3d: {
                        enabled: true,
                        alpha: 45,
                        beta: 0
                    }
                },
                credits: {
                    enabled: false, //此处配置用来取消highcharts.com的链接
                },
                title: {
                    text: '',
                    
                },
                tooltip: {
                    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        depth: 35,
                        dataLabels: {
                            enabled: true,
                            format: '{point.percentage:.1f} %',
				style: {
					 textOutline: 'none' 
                   }
                        },
                        showInLegend: true//控制图例显示
                    }
                },
                legend: {
                    itemStyle:{
                        'color':'#5d5d5d'
                    },
                    layout: 'horizontal',
                    align: 'center',
                    x: -20,
                    verticalAlign: 'bottom',
                    y: 140,
                    verticalAlign: 'middle' //图例
                },
                series: [{
                    type: 'pie',
                    name: '',
                    colors: [ '#7cb5ec','#7fb80e', '#ffc000' ,'#d48265'], //图表颜色
                    data: [
                        ['A.视频案例', 55.00,],
                        ['B.文字案例', 7.50],
                        ['C.图片案例', 30.00],
                        ['D.音频案例', 7.50],
                    ]
                }]

      }
    };
  },
  methods: {
    myCallback() {
      console.log("this is callback function");
    }
  }
};
</script>

<style scoped lang="scss">
#mains {
  width: 520px;
  height: 100%;
}
  .title {
    color: #000000;
    font-weight: bold;
    text-align: center;
    line-height: 30px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    white-space: nowrap;
  }


</style>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值