<template>
  <div :style="{ padding: '0 0 0 0' }">
    <v-chart :forceFit="true" :height="height" :data="data" :scale="scale" :padding="padding">
      <v-tooltip />
      <v-axis dataKey="x"/>
      <v-axis dataKey="y" :label="IAxisLabel" />
      <v-smooth-line position="x*y" color="#6569F7" shape="smooth" :size="lineSize"/>
      <v-point position="x*y" color="#fff" shape="circle" />
      <!--<v-area position="x*y" color="#D9DBFF" shape="smooth"/>-->
    </v-chart>
  </div>
</template>

<script>
  const DataSet = require('@antv/data-set');

  const IAxisLabel= {
    offset: 4,
  }

  export default {
    name: 'SmoothLineAndArea',
    props: {
      dataSource: {
        type: Array,
        default: () => [

        ]
      },
      yaxisText: {
        type: String,
        default: 'y'
      },
      width: {
        type: Number,
        default: 800
      },
      height: {
        type: Number,
        default: 294
      },
      padding: {
        type: Array,
        default: ['auto', 'auto', '40', '50']
      },
    },
    computed: {
      scale() {
        return [{
          dataKey: 'y',
          alias: this.yaxisText
        }]
      },
      data() {
        const dv = new DataSet.View().source(this.dataSource)
        dv.transform({
          type: 'fold',
          fields: ['value'],
          key: 'city',
          value: 'y',
        })
        let rows =  dv.rows
        return rows
      }
    },
    data() {
      return {
        lineSize: 6,
        IAxisLabel
      };
    }
  };
</script>
