feat: support chagne scatter size

This commit is contained in:
Meng Xiangzhuo 2024-10-18 04:19:11 +08:00
parent aec27859a6
commit 629159c574
No known key found for this signature in database
GPG Key ID: 7A1735AB4A5A3594
3 changed files with 21 additions and 1 deletions

View File

@ -3,6 +3,8 @@ import { ChartType, ChartTypeString, IndicatorConfig } from '@/types';
import { watchDebounced } from '@vueuse/core';
const DEFAULT_SCATTER_SYMBOL_SIZE = 3;
const props = defineProps({
modelValue: { required: true, type: Object as () => Record<string, IndicatorConfig> },
columns: { required: true, type: Array as () => string[] },
@ -16,6 +18,7 @@ const availableGraphTypes = ref<ChartTypeString[]>(Object.keys(ChartType) as Cha
const selAvailableIndicator = ref('');
const cancelled = ref(false);
const fillTo = ref('');
const scatterSymbolSize = ref(DEFAULT_SCATTER_SYMBOL_SIZE);
function newColor() {
selColor.value = randomColor();
@ -32,6 +35,9 @@ const combinedIndicator = computed<IndicatorConfig>(() => {
if (fillTo.value && graphType.value === ChartType.line) {
val.fill_to = fillTo.value;
}
if (graphType.value == ChartType.scatter) {
val.scatterSymbolSize = scatterSymbolSize.value;
}
return {
[selAvailableIndicator.value]: val,
};
@ -59,7 +65,7 @@ watch(
);
watchDebounced(
[selColor, graphType, fillTo],
[selColor, graphType, fillTo, scatterSymbolSize],
() => {
emitIndicator();
},
@ -108,5 +114,12 @@ watchDebounced(
class="mt-1"
label="Area chart - Fill to (leave empty for line chart)"
/>
<BFormGroup
v-if="graphType === ChartType.scatter"
label="Scatter symbol size"
label-class="mt-1"
>
<BFormSpinbutton v-model="scatterSymbolSize" />
</BFormGroup>
</div>
</template>

View File

@ -10,6 +10,7 @@ export interface IndicatorConfig {
color?: string;
type?: ChartType | ChartTypeString;
fill_to?: string;
scatterSymbolSize?: number;
}
export interface PlotConfig {

View File

@ -24,6 +24,12 @@ export function generateCandleSeries(
},
showSymbol: false,
};
if (value.type === ChartType.scatter) {
sp['symbolSize'] = value.scatterSymbolSize;
sp['emphasis'] = {
disabled: true,
};
}
return sp;
}