BarAndLine.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  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. <v-tooltip/>
  6. <v-legend/>
  7. <v-axis/>
  8. <v-bar position="type*bar"/>
  9. <v-line position="type*line" color="#2fc25b" :size="3"/>
  10. </v-chart>
  11. </div>
  12. </template>
  13. <script>
  14. import { ChartEventMixins } from './mixins/ChartMixins'
  15. export default {
  16. name: 'BarAndLine',
  17. mixins: [ChartEventMixins],
  18. props: {
  19. title: {
  20. type: String,
  21. default: ''
  22. },
  23. dataSource: {
  24. type: Array,
  25. default: () => [
  26. { type: '10:10', bar: 200, line: 1000 },
  27. { type: '10:15', bar: 600, line: 1000},
  28. { type: '10:20', bar: 200, line: 1000},
  29. { type: '10:25', bar: 900, line: 1000},
  30. { type: '10:30', bar: 200, line: 1000},
  31. { type: '10:35', bar: 200, line: 1000},
  32. { type: '10:40', bar: 100, line: 1000}
  33. ]
  34. },
  35. height: {
  36. type: Number,
  37. default: 400
  38. }
  39. },
  40. data() {
  41. return {
  42. padding: { top:50, right:50, bottom:100, left:50 },
  43. scale: [{
  44. dataKey: 'bar',
  45. min: 0
  46. }, {
  47. dataKey: 'line',
  48. min: 0
  49. }]
  50. }
  51. },
  52. computed: {
  53. data() {
  54. return this.dataSource
  55. }
  56. }
  57. }
  58. </script>