|
|
@@ -1,5 +1,9 @@
|
|
|
<template>
|
|
|
<div ref="chartRef" style="width:375px;height: 300px;background-color: #fff;"></div>
|
|
|
+ <ul>
|
|
|
+ <li @click="onChange(0)">日线</li>
|
|
|
+ <li @click="onChange(4)">1分钟线</li>
|
|
|
+ </ul>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
@@ -14,6 +18,12 @@ const historyData = shallowRef<Model.HistoryDatasRsp[]>([])
|
|
|
const futuresStore = useFuturesStore()
|
|
|
const quote = futuresStore.getGoodsQuote('AGTD')
|
|
|
|
|
|
+const chartInstance = shallowRef() // 图表实例
|
|
|
+
|
|
|
+const onChange = (period: number) => {
|
|
|
+ chartInstance.value.ChangePeriod(period)
|
|
|
+}
|
|
|
+
|
|
|
// 获取历史行情
|
|
|
queryHistoryDatas({
|
|
|
data: {
|
|
|
@@ -76,7 +86,7 @@ queryHistoryDatas({
|
|
|
const resource = Chart.JSChart.GetResource()
|
|
|
resource.FrameLogo.Text = ''
|
|
|
|
|
|
- const chart = Chart.JSChart.Init(chartRef.value)
|
|
|
- chart.SetOption(option)
|
|
|
+ chartInstance.value = Chart.JSChart.Init(chartRef.value)
|
|
|
+ chartInstance.value.SetOption(option)
|
|
|
})
|
|
|
</script>
|