123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <template>
- <div class="container">
- <div id="ELeft1" style="height:100%;"></div>
- </div>
- </template>
- <script>
- export default {
- name: "ELeft1",
- data() {
- return {};
- },
- mounted() {
- this.drawChart();
- },
- methods: {
- drawChart() {
- // 基于准备好的dom,初始化echarts实例
- let myChart = this.$echarts.init(document.getElementById("ELeft1"));
- // 指定图表的配置项和数据
- let option = {
- color: ["#01D7EF"],
- tooltip: {
- trigger: "axis",
- textStyle: {
- fontSize: 20,
- color: "#fff"
- }
- },
- grid: {
- x: "5%",
- y: "18%",
- x2: "10%",
- y2: "13%",
- containLabel: true,
- },
- calculable: true,
- xAxis: {
- name: "(时间)",
- nameTextStyle: {
- fontSize: 20,
- color: "#fff",
- },
- type: "category",
- data: ["2015", "2016", "2017", "2018", "2019", "2020"],
- textStyle: {
- fontSize: 20,
- color: "#fff",
- },
- axisLabel: {
- textStyle: {
- fontSize: 20,
- color: "#fff"
- },
- },
- axisLine: {
- lineStyle: {
- color: "#fff",
- width: 2,
- },
- },
- },
- yAxis: {
- name: "(元/公斤)",
- nameTextStyle: {
- fontSize: 20,
- color: "#fff",
- },
- type: "value",
- axisLabel: {
- textStyle: {
- fontSize: 20,
- color: "#fff"
- },
- },
- axisLine: {
- lineStyle: {
- color: "#fff",
- width: 2,
- },
- },
- scale: true,
- min(val) {
- return Number((val.min*0.7).toFixed(0))
- }
- },
- series: [
- {
- name: "公羊",
- type: "line",
- barWidth: "30%",
- data: [21.9, 21.0, 23.6, 27.8, 30.7, 32.4],
- markLine: {
- data: [{ type: "average", name: "平均值", label: {fontSize: 20} }],
- },
- }
- ]
- };
- // 使用刚指定的配置项和数据显示图表。
- myChart.setOption(option);
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- </style>
|