123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <template>
- <div id="chart-state" style="width: 100%; height: 100%"></div>
- </template>
- <script>
- export default {
- name: "chartState",
- data() {
- return {
- myChart: null
- }
- },
- methods: {
- init() {
- let options = {
- graphic: [
- {
- type: 'text',
- left: '45%',
- top: '42%',
- style: {
- text: '总存栏',
- fontSize: 14,
- fill: 'rgb(192, 188, 189)'
- }
- },
- {
- type: 'text',
- left: '45%',
- top: '50%',
- style: {
- text: '120',
- fontSize: 16,
- fontWeight: 700,
- fill: 'rgb(192, 188, 189)'
- }
- }
- ],
- series: [
- {
- name: '',
- type: 'pie',
- hoverAnimation: false,
- legendHoverLink: false,
- cursor: 'default',
- radius: ['45%', '30%'],
- center: ['50%', '50%'],
- color: [
- 'rgba(0, 150, 254, 0.2)',
- 'rgba(2, 205, 206, 0.2)',
- 'rgba(253, 160, 0, 0.2)',
- 'rgba(191, 40, 18, 0.2)',
- ],
- label: {
- show: false,
- },
- labelLine: {
- show: false,
- },
- zlevel: 1,
- itemStyle: {
- normal: {
- borderColor: '#0a1a2a',
- },
- ellipsis: {
- borderColor: '#0a1a2a',
- },
- },
- tooltip: {
- show: false,
- },
- data: [
- {
- value: 41,
- name: '',
- },
- {
- value: 20,
- name: '',
- },
- {
- value: 20,
- name: '',
- },
- {
- value: 20,
- name: '',
- },
- ],
- },
- {
- name: '',
- type: 'pie',
- zlevel: 2,
- cursor: 'default',
- hoverAnimation: false,
- legendHoverLink: false,
- radius: ['60%', '45%'],
- center: ['50%', '50%'],
- color: [
- 'rgba(0, 150, 254, 0.9)',
- 'rgba(2, 205, 206, 0.9)',
- 'rgba(253, 160, 0, 0.9)',
- 'rgba(191, 40, 18, 0.9)',
- ],
- label: {
- show: false,
- },
- labelLine: {
- show: false,
- },
- itemStyle: {
- normal: {
- // shadowBlur: 15,
- // shadowColor: 'rgba(0, 0, 0, 0.5)',
- borderColor: '#0a1a2a',
- // borderWidth:'10',
- },
- ellipsis: {
- borderColor: '#0a1a2a',
- },
- },
- tooltip: {
- show: false,
- },
- data: [
- {
- value: 41,
- name: '',
- },
- {
- value: 20,
- name: '',
- },
- {
- value: 20,
- name: '',
- },
- {
- value: 20,
- name: '',
- },
- ],
- },
- {
- name: 'title',
- type: 'pie',
- zlevel: 3,
- hoverAnimation: false,
- legendHoverLink: false,
- radius: ['80%', '60%'],
- center: ['50%', '50%'],
- color: ['rgba(0, 150, 254, 1)', 'rgba(2, 205, 206, 1)', 'rgba(253, 160, 0, 1)', 'rgba(191, 40, 18, 1)'],
- label: {
- show: true,
- formatter: (params) => {
- return `
- ${params.name}: ${params.percent}%
- ${params.data.value}个
- `;
- },
- padding:[0,-30],
- textStyle:{
- lineHeight: 25
- }
- },
- labelLine: {
- show: true,
- // showAbove:true,
- length: 30,
- length2: 50,
- },
- itemStyle: {
- shadowBlur: 15,
- shadowColor: 'rgba(0, 0, 0, 0.3)',
- borderColor: '#0a1a2a',
- },
- data: [
- {
- value: 41,
- name: '低级',
- label: {
- color: '#fff',
- },
- },
- {
- value: 20,
- name: '中级',
- label: {
- color: '#fff',
- },
- },
- {
- value: 20,
- name: '⾼级',
- label: {
- color: '#fff',
- },
- },
- {
- value: 20,
- name: '极⾼',
- label: {
- color: '#fff',
- },
- },
- ],
- },
- ],
- }
- this.myChart.setOption(options)
- }
- },
- mounted() {
- this.myChart = this.$echarts.init(document.getElementById('chart-state'));
- this.init()
- let that = this;
- window.addEventListener('resize', function() {
- that.myChart.resize();
- })
- }
- }
- </script>
- <style scoped>
- </style>
|