123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <template>
- <div class="crop_chart_c">
- <div id="crop_chart_c" style="width: 100%;height:400px;"></div>
- </div>
- </template>
- <script>
- export default {
- name: "crop_chart_c",
- props: {},
- data() {
- return {};
- },
- created() {},
- mounted() {
- this.drawChart();
- },
- methods: {
- drawChart() {
- // 基于准备好的dom,初始化echarts实例
- let myChart = this.$echarts.init(
- document.getElementById("crop_chart_c")
- );
- // 指定图表的配置项和数据
- let option = {
- title: {
- text: "未来保育猪数量预测",
- left: "center",
- bottom: 5
- },
- color: ["#3398DB"],
- tooltip: {
- trigger: "axis",
- axisPointer: {
- // 坐标轴指示器,坐标轴触发有效
- type: "line" // 默认为直线,可选为:'line' | 'shadow'
- }
- },
- toolbox: {
- show: true,
- feature: {
- dataView: { show: true, readOnly: true },
- magicType: { show: true, type: ["line", "bar"] },
- restore: { show: true },
- saveAsImage: { show: true }
- }
- },
- grid: {
- left: "10%",
- right: "10%",
- bottom: "13%",
- containLabel: true
- },
- xAxis: [
- {
- type: "category",
- data: [
- "七月",
- "八月",
- "九月",
- "十月",
- "十一月",
- "十二月"
- ],
- axisTick: {
- alignWithLabel: true
- }
- }
- ],
- yAxis: [
- {
- type: "value"
- }
- ],
- series: [
- {
- name: "数量",
- type: "bar",
- barWidth: "50%",
- data: [355, 200, 422, 390, 330, 220],
- encode: {
- // Map the "amount" column to X axis.
- x: "amount",
- // Map the "product" column to Y axis
- y: "product"
- },
- markPoint: {
- data: [
- { type: "max", name: "最大值" },
- { type: "min", name: "最小值" }
- ]
- },
- markLine: {
- data: [{ type: "average", name: "平均值" }]
- }
- }
- ]
- };
- // 使用刚指定的配置项和数据显示图表。
- myChart.setOption(option);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- </style>
|