You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MiniArea.vue 1.1 KiB

2 vuotta sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <div class="mini-chart">
  3. <div class="chart-content" :style="{height: 46}">
  4. <v-chart :force-fit="true" :height="height" :data="data" :padding="[36, 5, 18, 5]">
  5. <v-tooltip />
  6. <v-smooth-area position="x*y" />
  7. </v-chart>
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. import {format} from 'date-fns'
  13. const data = []
  14. const beginDay = new Date().getTime()
  15. const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5]
  16. for (let i = 0; i < fakeY.length; i += 1) {
  17. data.push({
  18. x: format(new Date(beginDay + 1000 * 60 * 60 * 24 * i), 'yyyy-MM-dd'),
  19. y: fakeY[i]
  20. })
  21. }
  22. const tooltip = [
  23. 'x*y',
  24. (x, y) => ({
  25. name: x,
  26. value: y
  27. })
  28. ]
  29. const scale = [{
  30. dataKey: 'x',
  31. min: 2
  32. }, {
  33. dataKey: 'y',
  34. title: '时间',
  35. min: 1,
  36. max: 22
  37. }]
  38. export default {
  39. name: 'MiniArea',
  40. data () {
  41. return {
  42. data,
  43. scale,
  44. tooltip,
  45. height: 100
  46. }
  47. }
  48. }
  49. </script>
  50. <style scoped>
  51. .mini-chart {
  52. position: relative;
  53. width: 100%
  54. }
  55. .mini-chart .chart-content{
  56. position: absolute;
  57. bottom: -28px;
  58. width: 100%;
  59. }
  60. </style>