| | |
| | | <template> |
| | | <div id="kline" class="boxDisplay" :style="{ height: `${props.height || defaultH}px`, position: 'relative' }" |
| | | <div :id="props.chartId" class="boxDisplay" :style="{ height: `${props.height || defaultH}px`, position: 'relative' }" |
| | | v-if="defaultH"> |
| | | </div> |
| | | <ul class="flex px-4 py-4 box-border justify-between indicator-box" v-if="showBottom" |
| | |
| | | const props = defineProps({ |
| | | symbol: { |
| | | type: String |
| | | }, |
| | | chartId: { |
| | | type: String, |
| | | default: 'kline' |
| | | }, |
| | | height: { |
| | | type: Number |
| | |
| | | } |
| | | |
| | | const initData = async () => { |
| | | chart = init('kline', config); |
| | | chart = init(props.chartId, config); |
| | | chart.setOffsetRightSpace(15) |
| | | chart.setDataSpace(10) |
| | | if (props.isShowsolid) { |
| | |
| | | length = 2 |
| | | } |
| | | chart.setPriceVolumePrecision(length, 2) |
| | | localStorage.setItem('kline', JSON.stringify(data.value)) |
| | | localStorage.setItem(`kline_${props.chartId}`, JSON.stringify(data.value)) |
| | | |
| | | nextTick(() => { |
| | | chart.applyNewData(data.value); |
| | | }) |
| | | } |
| | | const initData1 = async () => { |
| | | chart = init('kline', config); |
| | | chart = init(props.chartId, config); |
| | | chart.setOffsetRightSpace(15) |
| | | chart.setDataSpace(10) |
| | | let length = 2 |
| | | data.value = JSON.parse(localStorage.getItem('kline')) |
| | | data.value = JSON.parse(localStorage.getItem(`kline_${props.chartId}`)) |
| | | try { |
| | | length = data.value[data.value.length - 1].decimals |
| | | length = data.value && data.value.length ? data.value[data.value.length - 1].decimals : 2 |
| | | } catch (e) { |
| | | length = 2 |
| | | } |
| | | chart.setPriceVolumePrecision(length, 2) |
| | | // if (props.type === 'candle_solid') { |
| | | // chart.createTechnicalIndicator('MA', false, { id: 'candle_pane' }); |
| | | // paneId.value = chart.createTechnicalIndicator('VOL'); |
| | | // } |
| | | |
| | | // this.fetchData() |
| | | chart.setStyleOptions({ |
| | | candle: { |
| | | type: props.chartType |
| | |
| | | if (!quotesStore.stage) { |
| | | quotesStore[SET_STAGE]({ stage: '1min', seconds: 1 * 60 * 1000 }) |
| | | } |
| | | // console.log(data.value) |
| | | |
| | | nextTick(() => { |
| | | chart.applyNewData(data.value); |
| | | if (data.value && data.value.length) chart.applyNewData(data.value); |
| | | }) |
| | | } |
| | | const choiceType = (type) => { // 选择副线 |