demo.vue 984 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <app-echarts v-model:dataIndex="dataIndex" @ready="onReady" />
  3. </template>
  4. <script lang="ts" setup>
  5. import { PropType, watch } from 'vue'
  6. import { echarts } from '@/components/base/echarts/core'
  7. import { ChartCycleType } from '@/constants/chart'
  8. import { useCandlestick } from './@next'
  9. import AppEcharts from './index.vue'
  10. const props = defineProps({
  11. goodsCode: {
  12. type: String,
  13. default: '',
  14. },
  15. // 周期类型
  16. cycleType: {
  17. type: Number as PropType<ChartCycleType>,
  18. default: ChartCycleType.Minutes,
  19. },
  20. // 是否显示指标
  21. showIndicator: {
  22. type: Boolean,
  23. default: true,
  24. },
  25. })
  26. const { initChart, createCandlestick, dataIndex } = useCandlestick('XAUUSD')
  27. const onReady = (chart: echarts.ECharts) => {
  28. createCandlestick(chart)
  29. }
  30. // 监听周期选择变化
  31. watch(() => props.cycleType, (val) => {
  32. initChart(val)
  33. })
  34. </script>
  35. <style lang="less">
  36. @import './index.less';
  37. </style>