An open source alternative to Tableau. Embeddable visual analytic
TypeScript bidatadata-analysisdata-miningdata-visualizationedak6skanarieslow-codepivot-tablereacttableautableau-alternativetypescriptvegavega-litevisualization
feat: change semantic type in chart
islxyqwe32416d4546b3
diff --git a/packages/graphic-walker/src/fields/datasetFields/utils.ts b/packages/graphic-walker/src/fields/datasetFields/utils.tsindex c4673406..74416918 100644--- a/packages/graphic-walker/src/fields/datasetFields/utils.ts+++ b/packages/graphic-walker/src/fields/datasetFields/utils.ts@@ -86,6 +86,17 @@ export const useMenuActions = (channel: "dimensions" | "measures"): IActionMenuI],},+ {+ label: t('semantic_type.name'),+ children: (["nominal", "ordinal", "quantitative", "temporal"] as const).map(x => ({+ label: t(`semantic_type.types.${x}`),+ disabled: f.semanticType === x,+ onPress() {+ const originChannel = f.analyticType === 'dimension' ? 'dimensions' : 'measures';+ vizStore.changeSemanticType(originChannel, index, x);+ },+ }))+ },(f.semanticType === 'temporal' || isDateTimeDrilled) && {label: t('drill.name'),children: DATE_TIME_DRILL_LEVELS.map(level => ({diff --git a/packages/graphic-walker/src/locales/en-US.json b/packages/graphic-walker/src/locales/en-US.jsonindex 85447c0b..3afdf990 100644--- a/packages/graphic-walker/src/locales/en-US.json+++ b/packages/graphic-walker/src/locales/en-US.json@@ -258,6 +258,15 @@"field_menu": {"to_dim": "Move to dimensions","to_mea": "Move to measures",+ "semantic_type": {+ "name": "Change Semantic Type",+ "types": {+ "nominal": "Nominal",+ "ordinal": "Ordinal",+ "quantitative": "Quantitative",+ "temporal": "Temporal"+ }+ },"new_calc": "New calculation","bin": "Bin","binCount": "Bin Count",diff --git a/packages/graphic-walker/src/locales/ja-JP.json b/packages/graphic-walker/src/locales/ja-JP.jsonindex c40b3530..1c61531c 100644--- a/packages/graphic-walker/src/locales/ja-JP.json+++ b/packages/graphic-walker/src/locales/ja-JP.json@@ -258,6 +258,15 @@"log": "対数({{ base }})","binCustom": "ビン(カスタム)","logCustom": "対数(カスタム)",+ "semantic_type": {+ "name": "セマンティックタイプの変更",+ "types": {+ "nominal": "名義",+ "ordinal": "序数",+ "quantitative": "量的",+ "temporal": "時間的"+ }+ },"drill": {"name": "時間単位","feature_name": "時間特性",diff --git a/packages/graphic-walker/src/locales/zh-CN.json b/packages/graphic-walker/src/locales/zh-CN.jsonindex d185a6fe..efc7d23f 100644--- a/packages/graphic-walker/src/locales/zh-CN.json+++ b/packages/graphic-walker/src/locales/zh-CN.json@@ -154,7 +154,7 @@"auto_title": "图表 {{idx}}","chart_name": "图表名称"},- "askviz":{+ "askviz": {"placeholder": "想从数据集中绘制哪种可视化呢?"},"tabpanel": {@@ -264,6 +264,15 @@"log": "对数({{ base }})","binCustom": "自定义分箱","logCustom": "自定义对数",+ "semantic_type": {+ "name": "更改语义类型",+ "types": {+ "nominal": "名义",+ "ordinal": "序数",+ "quantitative": "计量",+ "temporal": "时间"+ }+ },"drill": {"name": "时间粒度","feature_name": "时间特征",diff --git a/packages/graphic-walker/src/store/visualSpecStore.ts b/packages/graphic-walker/src/store/visualSpecStore.tsindex b45674aa..a962a145 100644--- a/packages/graphic-walker/src/store/visualSpecStore.ts+++ b/packages/graphic-walker/src/store/visualSpecStore.ts@@ -16,7 +16,8 @@ import {IVisualConfig,Specification,IComputationFunction,- IGeoUrl+ IGeoUrl,+ ISemanticType} from '../interfaces';import { DATE_TIME_DRILL_LEVELS, DATE_TIME_FEATURE_LEVELS } from "../constants";import { GLOBAL_CONFIG } from '../config';@@ -582,6 +583,15 @@ export class VizSpecStore {encodings[stateKey].push(logField);});}+ public changeSemanticType(stateKey: keyof DraggableFieldState, index: number, newSemanticType: ISemanticType) {+ this.useMutable(({ encodings }) => {+ const originField = encodings[stateKey][index];+ encodings[stateKey].splice(index, 1, {+ ...originField,+ semanticType: newSemanticType+ })+ });+ }public createDateTimeDrilledField(stateKey: keyof DraggableFieldState, index: number, op: 'dateTimeDrill', drillLevel: typeof DATE_TIME_DRILL_LEVELS[number], name: string | ((originFieldName: string) => string), format: string)public createDateTimeDrilledField(stateKey: keyof DraggableFieldState, index: number, op: 'dateTimeFeature', drillLevel: typeof DATE_TIME_FEATURE_LEVELS[number], name: string | ((originFieldName: string) => string), format: string)public createDateTimeDrilledField(stateKey, index, op, drillLevel, name, format) {