BaseCharts.vue 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div>
  3. <div class="crumbs">
  4. <el-breadcrumb separator="/">
  5. <el-breadcrumb-item><i class="el-icon-date"></i> 图表</el-breadcrumb-item>
  6. <el-breadcrumb-item>基础图表</el-breadcrumb-item>
  7. </el-breadcrumb>
  8. </div>
  9. <div class="container">
  10. <div class="plugins-tips">
  11. vue-schart:vue.js封装sChart.js的图表组件。
  12. 访问地址:<a href="https://github.com/lin-xin/vue-schart" target="_blank">vue-schart</a>
  13. </div>
  14. <div class="schart">
  15. <div class="content-title">柱状图</div>
  16. <schart canvasId="bar" width="500" height="400" :data="data1" type="bar" :options="options1"></schart>
  17. </div>
  18. <div class="schart">
  19. <div class="content-title">折线图</div>
  20. <schart canvasId="line" width="500" height="400" :data="data1" type="line" :options="options1"></schart>
  21. </div>
  22. <div class="schart">
  23. <div class="content-title">饼状图</div>
  24. <schart canvasId="pie" width="500" height="400" :data="data2" type="pie" :options="options2"></schart>
  25. </div>
  26. <div class="schart">
  27. <div class="content-title">环形图</div>
  28. <schart canvasId="ring" width="500" height="400" :data="data2" type="ring" :options="options2"></schart>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import Schart from 'vue-schart';
  35. export default {
  36. components: {
  37. Schart
  38. },
  39. data: () => ({
  40. data1:[
  41. {name:'2012',value:1141},
  42. {name:'2013',value:1499},
  43. {name:'2014',value:2260},
  44. {name:'2015',value:1170},
  45. {name:'2016',value:970},
  46. {name:'2017',value:1450}
  47. ],
  48. data2 : [
  49. {name:'短袖',value:1200},
  50. {name:'休闲裤',value:1222},
  51. {name:'连衣裙',value:1283},
  52. {name:'外套',value:1314},
  53. {name:'羽绒服',value:2314}
  54. ],
  55. options1: {
  56. title: '某商店近年营业总额',
  57. bgColor: '#009688',
  58. titleColor: '#ffffff',
  59. fillColor: '#e0f2f1',
  60. axisColor: '#ffffff',
  61. contentColor: '#999'
  62. },
  63. options2: {
  64. title: '某商店各商品年度销量',
  65. bgColor: '#607d8b',
  66. titleColor: '#ffffff',
  67. legendColor: '#ffffff'
  68. }
  69. })
  70. }
  71. </script>
  72. <style scoped>
  73. .schart{
  74. width: 600px;
  75. display: inline-block;
  76. }
  77. .content-title{
  78. clear: both;
  79. font-weight: 400;
  80. line-height: 50px;
  81. margin: 10px 0;
  82. font-size: 22px;
  83. color: #1f2f3d;
  84. }
  85. </style>