e71bd20d4351abd093236c70145aaea8af8301bf.svn-base 1005 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div :style="{ padding: '0 0 32px 32px' }">
  3. <h4 :style="{ marginBottom: '20px' }">{{ title }}</h4>
  4. <v-chart
  5. height="254"
  6. :data="datasource"
  7. :forceFit="true"
  8. :padding="['auto', 'auto', '40', '50']">
  9. <v-tooltip />
  10. <v-axis />
  11. <v-bar position="x*y"/>
  12. </v-chart>
  13. </div>
  14. </template>
  15. <script>
  16. const data = []
  17. for (let i = 0; i < 12; i += 1) {
  18. data.push({
  19. x: `${i + 1}月`,
  20. y: Math.floor(Math.random() * 1000) + 200
  21. })
  22. }
  23. const tooltip = [
  24. 'x*y',
  25. (x, y) => ({
  26. name: x,
  27. value: y
  28. })
  29. ]
  30. const scale = [{
  31. dataKey: 'x',
  32. min: 2
  33. }, {
  34. dataKey: 'y',
  35. title: '时间',
  36. min: 1,
  37. max: 22
  38. }]
  39. export default {
  40. name: "Bar",
  41. props: {
  42. title: {
  43. type: String,
  44. default: ''
  45. }
  46. },
  47. mounted(){
  48. this.datasource = data
  49. },
  50. data () {
  51. return {
  52. datasource:[],
  53. scale,
  54. tooltip
  55. }
  56. }
  57. }
  58. </script>