LineChartMultid.vue 1.9 KB
Newer Older
1 2 3
<template>
  <div :style="{ padding: '0 0 32px 32px' }">
    <h4 :style="{ marginBottom: '20px' }">{{ title }}</h4>
4 5 6 7 8 9
    <v-chart :force-fit="true" :height="height" :data="data" :scale="scale">
      <v-tooltip/>
      <v-axis/>
      <v-legend/>
      <v-line position="type*y" color="x"/>
      <v-point position="type*y" color="x" :size="4" :v-style="style" :shape="'circle'"/>
10 11 12 13 14 15 16 17 18 19 20 21 22 23
    </v-chart>
  </div>
</template>

<script>
  import { DataSet } from '@antv/data-set'

  export default {
    name: 'LineChartMultid',
    props: {
      title: {
        type: String,
        default: ''
      },
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
      dataSource: {
        type: Array,
        default: () => [
          { type: 'Jan', jeecg: 7.0, jeebt: 3.9 },
          { type: 'Feb', jeecg: 6.9, jeebt: 4.2 },
          { type: 'Mar', jeecg: 9.5, jeebt: 5.7 },
          { type: 'Apr', jeecg: 14.5, jeebt: 8.5 },
          { type: 'May', jeecg: 18.4, jeebt: 11.9 },
          { type: 'Jun', jeecg: 21.5, jeebt: 15.2 },
          { type: 'Jul', jeecg: 25.2, jeebt: 17.0 },
          { type: 'Aug', jeecg: 26.5, jeebt: 16.6 },
          { type: 'Sep', jeecg: 23.3, jeebt: 14.2 },
          { type: 'Oct', jeecg: 18.3, jeebt: 10.3 },
          { type: 'Nov', jeecg: 13.9, jeebt: 6.6 },
          { type: 'Dec', jeecg: 9.6, jeebt: 4.8 }
        ]
40
      },
41 42
      fields: {
        type: Array,
43 44
        default: () => ['jeecg', 'jeebt']
      },
45 46 47
      height: {
        type: Number,
        default: 254
48 49 50 51 52 53 54 55 56
      }
    },
    data() {
      return {
        scale: [{
          dataKey: 'x',
          min: 0,
          max: 1
        }],
57
        style: { stroke: '#fff', lineWidth: 1 }
58 59
      }
    },
60 61 62
    computed: {
      data() {
        const dv = new DataSet.View().source(this.dataSource)
63 64 65 66
        dv.transform({
          type: 'fold',
          fields: this.fields,
          key: 'x',
67 68 69
          value: 'y'
        })
        return dv.rows
70 71 72 73 74 75 76 77
      }
    }
  }
</script>

<style scoped>

</style>