BarAndLine.vue 1.4 KB
Newer Older
1
<template>
JEECG低代码平台's avatar
JEECG低代码平台 已提交
2
  <div :style="{ padding: '0 50px 32px 0' }">
3
    <h4 :style="{ marginBottom: '20px' }">{{ title }}</h4>
4
    <v-chart :forceFit="true" :height="height" :data="data" :scale="scale" :padding=" padding" :onClick="handleClick">
5 6 7 8 9 10 11 12 13 14
      <v-tooltip/>
      <v-legend/>
      <v-axis/>
      <v-bar position="type*bar"/>
      <v-line position="type*line" color="#2fc25b" :size="3"/>
    </v-chart>
  </div>
</template>

<script>
15
  import { ChartEventMixins } from './mixins/ChartMixins'
16 17

  export default {
18 19
    name: 'BarAndLine',
    mixins: [ChartEventMixins],
20 21 22 23 24 25 26 27
    props: {
      title: {
        type: String,
        default: ''
      },
      dataSource: {
        type: Array,
        default: () => [
JEECG低代码平台's avatar
JEECG低代码平台 已提交
28 29 30 31 32 33 34
          { type: '10:10', bar: 200, line: 1000 },
          { type: '10:15', bar: 600, line: 1000},
          { type: '10:20', bar: 200, line: 1000},
          { type: '10:25', bar: 900, line: 1000},
          { type: '10:30', bar: 200, line: 1000},
          { type: '10:35', bar: 200, line: 1000},
          { type: '10:40', bar: 100, line: 1000}
35 36 37 38 39 40 41 42 43
        ]
      },
      height: {
        type: Number,
        default: 400
      }
    },
    data() {
      return {
JEECG低代码平台's avatar
JEECG低代码平台 已提交
44
        padding: { top:50, right:50, bottom:100, left:50 },
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
        scale: [{
          dataKey: 'bar',
          min: 0
        }, {
          dataKey: 'line',
          min: 0
        }]
      }
    },
    computed: {
      data() {
        return this.dataSource
      }
    }
  }
</script>