123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <!--
- * @Author: your name
- * @Date: 2021-10-26 17:53:37
- * @LastEditTime: 2021-10-27 11:05:10
- * @LastEditors: Please set LastEditors
- * @Description: 成本分析柱状图
- * @FilePath: \hyyfScreen\src\views\Production\board\ChartCostLine.vue
- -->
- <template>
- <div class="cost-histogram">
- <div id="costHistogram"></div>
- </div>
- </template>
- <script>
- export default {
- props: {
- data: {
- type: Array,
- default: () => []
- }
- },
- data() {
- return {
- myChart: null
- }
- },
- methods: {
- init() {
- let options = {
- // title: {
- // text: '存栏变动',
- // x: 10,
- // y: 0
- // },
- tooltip: {
- trigger: 'axis',
- },
- // legend: {
- // data: ['头']
- // },
- color: ['#3aa0ff', '#4dcb73', '#fad337', '#f2637b', '#975fe4'],
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: [
- {
- type: 'value',
- name: '元',
- boundaryGap: [0, 0.01],
- axisPointer: {
- type: 'shadow'
- },
- axisLine: {
- show: true,
- lineStyle: {
- color: '#fff',
- }
- },
- axisTick:{
- show: false
- },
- }
- ],
- yAxis: //[
- {
- type: 'category',
- inverse: true,
- // axisLabel: {
- // // formatter: '{value} °C'
- // show: true
- // },
- axisLine: {
- show: true,
- lineStyle: {
- color: '#fff',
- }
- },
- // axisTick:{
- // show:false
- // },
- // splitLine:{
- // show:false
- // }
- },
- // {
- // type: 'value',
- // name: '湿度',
- // axisLabel: {
- // formatter: '{value} RH'
- // },
- // axisLine: {
- // show: false,
- // lineStyle: {
- // color: '#6e7079',
- // }
- // },
- // axisTick:{
- // show:false
- // },
- // // splitLine:{
- // // show:false
- // // }
- // }
- //],
- // dataset: [
- // {
- // dimensions: ['num'],
- // source: [
- // [32541],
- // [82467],
- // [54363],
- // [64642],
- // [40257],
- // [95422]
- // ]
- // },
- // {
- // transeform: {
- // type: 'sort',
- // config: {
- // dimension: 'num',
- // order: 'desc'
- // }
- // }
- // }
- // ],
- series: [
- {
- // name: '头',
- type: 'bar',
- data: this.data,
- itemStyle: {
- normal: {
- color: function (colors) { // 颜色设置
- var colorList = ['rgb(112,182,3)', 'rgb(232,56,92)', 'rgb(123,0,255)', 'rgb(0,215,233)', 'rgb(255,255,160)', 'rgb(0,0,255)']
- return colorList[colors.dataIndex]
- },
- label: {
- show: true,
- position: 'right'
- }
- },
- textStyle: {
- show: true
- },
- }
- }
- ]
- }
- this.myChart.setOption(options);
- }
- },
- mounted() {
- this.myChart = this.$echarts.init(document.getElementById('costHistogram'));
- this.init();
- },
- watch: {
- data(value) {
- console.log('成本分析柱状图数据', value)
- this.init()
- }
- }
- }
- </script>
- <style scoped>
- .cost-histogram {
- width: 90%;
- height: 50%;
- }
- #costHistogram {
- width: 100%;
- height: 100%;
- }
- </style>
|