123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <template>
- <view class="content">
-
- <view @click="echarts.onClick" :prop="option" :change:prop="echarts.updateEcharts" ref="chartId" :id="chartId" class="echarts"></view>
-
- </view>
- </template>
- <script>
- import echarts from '../../static/echarts.js'
- let app = getApp();
- export default {
- props: {
- chartId: String,
- dataList: {
- type: Array,
- default: () => {
- return []
- }
- }
- },
- data() {
- return {
- data1: [],
- themeColor: null,
- fuzhuColor: null,
- themeColor50: null,
- themeColor25: null,
- fuzhuColor50: null,
- fuzhuColor15: null,
- option: {
- tooltip: {
- trigger: 'item',
-
-
-
- align: 'auto'
- },
- color: [],
- series: {
- name: '',
- type: 'pie',
- radius: ['52%', '70%'],
- center: ['50%', '50%'],
- data: [],
- itemStyle: {
- normal: {
-
-
-
-
- label: {
-
-
-
- formatter: null,
- rich: {
- d: {
- fontSize: 14,
- color: "#000000"
- }
- }
- }
- },
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.0)'
- }
- }
- }
-
-
-
-
-
-
-
- }
- },
- }
- },
- mounted() {
- this.themeColor = app.globalData.themeColor
- this.themeColor50 = app.globalData.themeColor50
- this.themeColor25 = app.globalData.themeColor25
- this.fuzhuColor = app.globalData.fuzhuColor
- this.fuzhuColor50 = app.globalData.fuzhuColor50
- this.fuzhuColor15 = app.globalData.fuzhuColor15
- this.getDataAction()
- },
- methods: {
- getDataAction() {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.data1 = this.dataList || []
- this.option.series.itemStyle.normal.color = null
- this.data1.forEach((item, index) => {
- item['color'] = ''
- item.name = item.name + item.des
- if (index == 0) {
- item.color = this.themeColor
- } else if (index == 1) {
- item.color = this.fuzhuColor
- } else if (index == 2) {
- item.color = this.themeColor50
- } else {
- item.color = this.themeColor25
- }
- })
- var tempData = this.data1
- var self = this
- this.option.series.data = tempData
- this.option.color = [this.themeColor, this.fuzhuColor, this.themeColor50, this.themeColor25]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- onViewClick(options) {
-
- }
- },
- watch: {
- chartId: {
- handler(e) {
-
- },
- immediate: true
- }
- }
- }
- </script>
- <script module="echarts" lang="renderjs">
- let myChart
- export default {
- mounted() {
- this.initAction()
- },
- methods: {
- initAction() {
- if (typeof window.echarts === 'function') {
- this.initEcharts()
- } else {
-
- const script = document.createElement('script')
-
- script.src = 'static/echarts.js'
- script.onload = this.initEcharts.bind(this)
- document.head.appendChild(script)
- }
- },
- initEcharts() {
-
- myChart = echarts.init(document.getElementById(this.$refs.chartId.$el.id))
-
- if (myChart) myChart.setOption(this.option)
- },
- updateEcharts(newValue, oldValue, ownerInstance, instance) {
-
- if (myChart) myChart.setOption(newValue)
- },
- onClick(event, ownerInstance) {
-
- ownerInstance.callMethod('onViewClick', {
- test: 'test'
- })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .content {
- width: 100%;
- height: 100%;
- position: relative;
- font-size: 60rpx;
- font-family: DIN Alternate;
- font-weight: bold;
- .echarts {
- width: 100%;
- height: 100%;
- }
- }
- </style>
|