123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <template>
- <!-- 支架压力柱状图 -->
- <div class="main">
- <div ref="bar" style="height: 170px; width: 300px"></div>
- <div style="display: flex;flex-flow: column;">
- <div class="botton1">
- <span class="name">486 /万吨</span>
- <span class="value">今年产量</span>
- </div>
- <div class="botton2">
- <span class="name">495 /万吨</span>
- <span class="value">计划产量</span>
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: "Bars",
- data() {
- return {
- myChart: null,
- xData: [],
- yData: [],
- };
- },
- mounted() {
- const option = {
- title: {
- text: "煤炭产量",
- // 标题内边距 上下边距 左右边距titl
- padding: [10, 0, 0, 160],
- textStyle: {
- color: "white",
- fontSize: 16,
- },
- },
- tooltip: {
- // show: false,
- trigger: "axis",
- axisPointer: {
- type: "shadow",
- },
- formatter: (params) => {
- let round = "<span style=\"display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#4693EC;\"></span>";
- return round + "产量:" + params[0].data + "万吨";
- // if (params[0].data > 39) {
- // return params[0].marker + "压力过高:" + params[0].data;
- // } else if (params[0].data < 26) {
- // return params[0].marker + "压力过低:" + params[0].data;
- // } else {
- // return params[0].marker + "压力正常:" + params[0].data;
- // }
- },
- },
- color: ["#FF6666", "#99CC66", "#FFFF66"],
- legend: {
- show: false,
- orient: "horizontal",
- left: "right",
- padding: [25, 20],
- icon: "rect",
- textStyle: {
- color: "#fff",
- },
- data: ["压力超限", "压力正常", "压力过低"],
- },
- grid: {
- top: "22%",
- left: "3%",
- right: "4%",
- bottom: "3%",
- containLabel: true,
- },
- xAxis: [
- {
- type: "category",
- axisLabel: {
- color: "#fff",
- interval: 0,
- fontSize: 9,
- },
- axisLine: {
- show: true,
- },
- data: [
- "1月",
- "2月",
- "3月",
- "4月",
- "5月",
- "6月",
- "7月",
- "8月",
- "9月",
- "10月",
- "11月",
- "12月",
- ],
- },
- ],
- yAxis: [
- {
- type: "value",
- name: "万吨",
- axisLabel: {
- color: "#fff",
- // fontSize: 11,
- },
- nameTextStyle: {
- color: "white",
- padding: [0, 0, 0, -30],
- },
- min: 0,
- max: 100,
- splitLine: {
- show: false,
- lineStyle: {
- type: "dotted",
- color: "#fff",
- },
- },
- },
- ],
- series: [
- {
- name: "数据",
- type: "bar",
- barWidth: 12,
- itemStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: "#00FFE3",
- },
- {
- offset: 1,
- color: "#4693EC",
- },
- ]),
- },
- },
- // barWidth: "10",
- barCategoryGap: "5%",
- data: [70, 80, 80, 80, 80, 80, 90, 75, 95, 72, 73, 82],
- },
- // {
- // //这两组数据用来模拟markLine线段开关,data可以为空
- // name: "压力超限",
- // type: "line",
- // markLine: {
- // data: [
- // {
- // name: "压力超限",
- // yAxis: "64",
- // itemStyle: {
- // normal: {
- // show: true,
- // color: "#FF6666",
- // },
- // },
- // },
- // ],
- // },
- // },
- // {
- // //这两组数据用来模拟markLine线段开关,data可以为空
- // name: "压力正常",
- // type: "line",
- // markLine: {
- // data: [
- // {
- // name: "压力正常",
- // yAxis: "24",
- // itemStyle: {
- // normal: {
- // show: true,
- // color: "#FFFF66",
- // },
- // },
- // },
- // ],
- // },
- // },
- // {
- // name: "压力过低",
- // type: "line",
- // itemStyle: {
- // normal: {
- // color: "#FFFF66",
- // },
- // },
- // },
- ],
- };
- this.myChart = this.$echarts.init(this.$refs.bar);
- // 获取数据
- this.myChart.setOption(option);
- },
- };
- </script>
- <style scoped lang="less">
- .main {
- display: flex;
- }
- .botton1 {
- margin-top: 20px;
- }
- .botton2 {
- margin-top: 20px;
- }
- .name {
- color: #4adefe;
- font-size: 20px;
- display: block;
- }
- .value {
- display: block;
- color: white;
- text-align: center;
- }
- </style>
|