| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <template>
- <div>
- <div id="bottomLeftChart" style="width:11.25rem;height:6.25rem;"></div>
- </div>
- </template>
- <script>
- import echartMixins from "@/utils/resizeMixins";
- export default {
- data() {
- return {
- chart: null
- };
- },
- mixins: [echartMixins],
- mounted() {
- this.draw();
- },
- methods: {
- draw() {
- // 基于准备好的dom,初始化echarts实例
- this.chart = this.echarts.init(document.getElementById("bottomLeftChart"));
- // ----------------------------------------------------------------
- let category = [
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01",
- "2021-01"
- ];
- let lineData = [
- 18092,
- 20728,
- 24045,
- 28348,
- 32808,
- 36097,
- 39867,
- 44715,
- 48444,
- 50415,
- 56061,
- 62677,
- 59521,
- 67560,
- 18092,
- 20728,
- 24045,
- 28348,
- 32808,
- 36097,
- 39867,
- 44715,
- 48444,
- 50415,
- 36097,
- 39867,
- 44715,
- 48444,
- 50415,
- 50061,
- 32677,
- 49521,
- 32808
- ];
- let barData = [
- 4600,
- 5000,
- 5500,
- 6500,
- 7500,
- 8500,
- 9900,
- 12500,
- 14000,
- 21500,
- 23200,
- 24450,
- 25250,
- 33300,
- 4600,
- 5000,
- 5500,
- 6500,
- 7500,
- 8500,
- 9900,
- 22500,
- 14000,
- 21500,
- 8500,
- 9900,
- 12500,
- 14000,
- 21500,
- 23200,
- 24450,
- 25250,
- 7500
- ];
- let rateData = [];
- for (let i = 0; i < 33; i++) {
- let rate = barData[i] / lineData[i];
- rateData[i] = rate.toFixed(2);
- }
- let option = {
- title: {
- text: "",
- x: "center",
- y: 0,
- textStyle: {
- color: "#B4B4B4",
- fontSize: 16,
- fontWeight: "normal"
- }
- },
- tooltip: {
- trigger: "axis",
- backgroundColor: "rgba(255,255,255,0.1)",
- axisPointer: {
- type: "shadow",
- label: {
- show: true,
- backgroundColor: "#7B7DDC"
- }
- }
- },
- legend: {
- data: [this.$t('已排放'),this.$t('计划排放'),this.$t('排放率')],
- textStyle: {
- color: "#B4B4B4"
- },
- top: "0%"
- },
- grid: {
- x: "8%",
- width: "88%",
- y: "4%"
- },
- xAxis: {
- data: category,
- axisLine: {
- lineStyle: {
- color: "#B4B4B4"
- }
- },
- axisTick: {
- show: false
- }
- },
- yAxis: [
- {
- splitLine: { show: false },
- axisLine: {
- lineStyle: {
- color: "#B4B4B4"
- }
- },
- axisLabel: {
- formatter: "{value} "
- }
- },
- {
- splitLine: { show: false },
- axisLine: {
- lineStyle: {
- color: "#B4B4B4"
- }
- },
- axisLabel: {
- formatter: "{value} "
- }
- }
- ],
- series: [
- {
- name: this.$t('排放率'),
- type: "line",
- smooth: true,
- showAllSymbol: true,
- symbol: "emptyCircle",
- symbolSize: 8,
- yAxisIndex: 1,
- itemStyle: {
- normal: {
- color: "#F02FC2"
- }
- },
- data: rateData
- },
- {
- name: this.$t('已排放'),
- type: "bar",
- barWidth: 10,
- itemStyle: {
- normal: {
- barBorderRadius: 5,
- color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [
- { offset: 0, color: "#956FD4" },
- { offset: 1, color: "#3EACE5" }
- ])
- }
- },
- data: barData
- },
- {
- name: this.$t('计划排放'),
- type: "bar",
- barGap: "-100%",
- barWidth: 10,
- itemStyle: {
- normal: {
- barBorderRadius: 5,
- color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [
- { offset: 0, color: "rgba(156,107,211,0.8)" },
- { offset: 0.2, color: "rgba(156,107,211,0.5)" },
- { offset: 1, color: "rgba(156,107,211,0.2)" }
- ])
- }
- },
- z: -12,
- data: lineData
- }
- ]
- };
- this.chart.setOption(option);
- }
- },
- destroyed() {
- window.onresize = null;
- }
- };
- </script>
- <style lang="scss" scoped>
- </style>
|