line.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view style="width: 100%; height: 100%">
  3. <qiun-data-charts :type="type" :opts="mergedOpts" :chartData="chartData" />
  4. </view>
  5. </template>
  6. <script>
  7. import qiunDataCharts from "@/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue";
  8. export default {
  9. props: {
  10. chartData: { type: Object, default: () => ({}) }, // 图表数据
  11. chartOpts: { type: Object, default: () => ({}) }, // 图表配置项
  12. type: { type: String, default: "line" }, // 图表类型:line、area 等
  13. },
  14. components: { qiunDataCharts },
  15. data() {
  16. return {
  17. opts: {
  18. color: [
  19. "#1890FF",
  20. "#91CB74",
  21. "#FAC858",
  22. "#EE6666",
  23. "#73C0DE",
  24. "#3CA272",
  25. "#FC8452",
  26. "#9A60B4",
  27. "#ea7ccc",
  28. ],
  29. padding: [15, 10, 0, 15],
  30. dataLabel: false,
  31. enableScroll: false,
  32. update: true,
  33. duration: 0,
  34. animation: false,
  35. legend: {},
  36. xAxis: {
  37. disableGrid: true,
  38. },
  39. yAxis: {
  40. gridType: "dash",
  41. dashLength: 2,
  42. },
  43. extra: {
  44. line: {
  45. type: "curve",
  46. width: 2,
  47. activeType: "hollow",
  48. linearType: "custom",
  49. },
  50. },
  51. },
  52. };
  53. },
  54. computed: {
  55. mergedOpts() {
  56. // 合并默认配置与自定义配置
  57. return { ...this.opts, ...this.chartOpts };
  58. },
  59. },
  60. onReady() {},
  61. methods: {},
  62. };
  63. </script>
  64. <style scoped>
  65. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  66. .charts-box {
  67. width: 100%;
  68. height: 300px;
  69. }
  70. </style>