123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <template>
- <div id="myChart66" style="width: 100%; height: 100%;"></div>
- </template>
- <script>
- import { oldPersonMind } from '../../api'
- export default {
- //老年人精神状态
- name: "OldPersonMentality",
- data() {
- return {
- dataArr: [],
- colorArr: ['#238aff','#ff0','#0f0'],
- myChart: null
- }
- },
- methods: {
- async draw() {
- const result = await oldPersonMind({}, 'POST');
- this.dataArr = result;
- const seriesArr = [];
- for(let i = 0; i < this.dataArr.length; i++) {
- const d = this.dataArr[i];
- const imgArr = new Array(this.dataArr.length).fill({});
- imgArr[i] = { value: parseInt(d.value) };
- seriesArr.push({
- type: 'pictorialBar',
- barWidth: 40,
- symbol: `image://${require('../../assets/PatrolmanStatistics/sjx-' + i + '.png')}`,
- itemStyle: {
- normal: {
- color: (params) => {
- return this.colorArr[params.dataIndex];
- }
- }
- },
- label: {
- show: true,
- position: 'top',
- textStyle: {
- fontSize: 18
- },
- fontWeight: 'bold',
- offset: [0, 0],
- formatter: '{c}%'
- },
- data: imgArr
- });
- }
- this.myChart = this.$echarts.init(document.getElementById('myChart66'));
- this.myChart.setOption({
- xAxis: {
- type: 'category',
- data: this.dataArr.map((item) => item.label ),
- splitLine: {
- show: false
- },
- axisLine: {
- show: false
- },
- axisLabel: {
- show: true,
- color: '#fff',
- fontWeight: 'bold',
- fontSize: 15
- },
- axisTick: {
- show: false
- }
- },
- yAxis: {
- type: 'value',
- splitLine: {
- show: false
- },
- axisLine: {
- show: false
- },
- axisLabel: {
- show: false
- },
- axisTick: {
- show: false
- }
- },
- series: seriesArr
- });
- }
- },
- watch: {
- data() {
- this.myChart.destroy();
- this.draw();
- }
- },
- mounted() {
- this.draw();
- }
- }
- </script>
- <style scoped>
- </style>
|