line.vue 1.5 KB

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