b540695c5c2aa37e65f48beee1f9a8a3c63b2460.svn-base 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div :style="{ padding: '0' }">
  3. <h4 :style="{ marginBottom: '20px' }">{{ title }}</h4>
  4. <v-chart ref="chart" :forceFit="true" :height="height" :data="dataSource" :scale="scale">
  5. <v-tooltip :shared="false"/>
  6. <v-axis/>
  7. <v-line position="x*y" :size="lineSize" :color="lineColor"/>
  8. <v-area position="x*y" :color="color"/>
  9. </v-chart>
  10. </div>
  11. </template>
  12. <script>
  13. import { triggerWindowResizeEvent } from '@/utils/util'
  14. export default {
  15. name: 'AreaChartTy',
  16. props: {
  17. // 图表数据
  18. dataSource: {
  19. type: Array,
  20. required: true
  21. },
  22. // 图表标题
  23. title: {
  24. type: String,
  25. default: ''
  26. },
  27. // x 轴别名
  28. x: {
  29. type: String,
  30. default: 'x'
  31. },
  32. // y 轴别名
  33. y: {
  34. type: String,
  35. default: 'y'
  36. },
  37. // Y轴最小值
  38. min: {
  39. type: Number,
  40. default: 0
  41. },
  42. // Y轴最大值
  43. max: {
  44. type: Number,
  45. default: null
  46. },
  47. // 图表高度
  48. height: {
  49. type: Number,
  50. default: 254
  51. },
  52. // 线的粗细
  53. lineSize: {
  54. type: Number,
  55. default: 2
  56. },
  57. // 面积的颜色
  58. color: {
  59. type: String,
  60. default: ''
  61. },
  62. // 线的颜色
  63. lineColor: {
  64. type: String,
  65. default: ''
  66. }
  67. },
  68. computed: {
  69. scale() {
  70. return [
  71. { dataKey: 'x', title: this.x, alias: this.x },
  72. { dataKey: 'y', title: this.y, alias: this.y, min: this.min, max: this.max }
  73. ]
  74. }
  75. },
  76. mounted() {
  77. triggerWindowResizeEvent()
  78. }
  79. }
  80. </script>
  81. <style lang="less" scoped>
  82. @import "chart";
  83. </style>