1f18dabfbdd2c230c775d8d0d1d735de55cd178e.svn-base 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div :class="className" :style="{height:height,width:width}" />
  3. </template>
  4. <script>
  5. import echarts from 'echarts'
  6. require('echarts/theme/macarons') // echarts theme
  7. import resize from './mixins/resize'
  8. export default {
  9. mixins: [resize],
  10. props: {
  11. className: {
  12. type: String,
  13. default: 'chart'
  14. },
  15. width: {
  16. type: String,
  17. default: '100%'
  18. },
  19. height: {
  20. type: String,
  21. default: '300px'
  22. }
  23. },
  24. data() {
  25. return {
  26. chart: null
  27. }
  28. },
  29. mounted() {
  30. this.$nextTick(() => {
  31. this.initChart()
  32. })
  33. },
  34. beforeDestroy() {
  35. if (!this.chart) {
  36. return
  37. }
  38. this.chart.dispose()
  39. this.chart = null
  40. },
  41. methods: {
  42. initChart() {
  43. this.chart = echarts.init(this.$el, 'macarons')
  44. this.chart.setOption({
  45. tooltip: {
  46. trigger: 'item',
  47. formatter: '{a} <br/>{b} : {c} ({d}%)'
  48. },
  49. legend: {
  50. left: 'center',
  51. bottom: '10',
  52. data: ['Industries', 'Technology', 'Forex', 'Gold', 'Forecasts']
  53. },
  54. series: [
  55. {
  56. name: 'WEEKLY WRITE ARTICLES',
  57. type: 'pie',
  58. roseType: 'radius',
  59. radius: [15, 95],
  60. center: ['50%', '38%'],
  61. data: [
  62. { value: 320, name: 'Industries' },
  63. { value: 240, name: 'Technology' },
  64. { value: 149, name: 'Forex' },
  65. { value: 100, name: 'Gold' },
  66. { value: 59, name: 'Forecasts' }
  67. ],
  68. animationEasing: 'cubicInOut',
  69. animationDuration: 2600
  70. }
  71. ]
  72. })
  73. }
  74. }
  75. }
  76. </script>