An open source alternative to Tableau. Embeddable visual analytic
TypeScript bidatadata-analysisdata-miningdata-visualizationedak6skanarieslow-codepivot-tablereacttableautableau-alternativetypescriptvegavega-litevisualization
feat: add new dataset (#197)
Observed Observer73385d89623e
diff --git a/packages/graphic-walker/src/dataSource/config.ts b/packages/graphic-walker/src/dataSource/config.tsindex f9308159..2231cca8 100644--- a/packages/graphic-walker/src/dataSource/config.ts+++ b/packages/graphic-walker/src/dataSource/config.ts@@ -1,12 +1,13 @@-export const DemoDataAssets = true ? {- CARS: "https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-cars-service.json",- STUDENTS: "https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-students-service.json",- BTC_GOLD: "https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds_btc_gold_service.json",- BIKE_SHARING: 'https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-bikesharing-service.json',- CAR_SALES: 'https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-carsales-service.json',- COLLAGE: 'https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-collage-service.json',- TITANIC: 'https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-titanic-service.json',- KELPER: 'https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-kelper-service.json',+export const DemoDataAssets = process.env.NODE_ENV === 'production' ? {+ CARS: "https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-cars-service.json",+ STUDENTS: "https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-students-service.json",+ BTC_GOLD: "https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-btcgold-service.json",+ BIKE_SHARING: 'https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-bikesharing-service.json',+ CAR_SALES: 'https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-carsales-service.json',+ COLLAGE: 'https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-collage-service.json',+ TITANIC: 'https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-titanic-service.json',+ KELPER: 'https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-kelper-service.json',+ EARTHQUAKE: 'https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-earthquake-service.json'} : {// CARS: "https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-cars-service.json",CARS: "/datasets/ds-cars-service.json",@@ -18,6 +19,7 @@ export const DemoDataAssets = true ? {COLLAGE: '/datasets/ds-collage-service.json',TITANIC: '/datasets/ds-titanic-service.json',KELPER: '/datasets/ds-kelper-service.json',+ EARTHQUAKE: '/datasets/ds-earthquake-service.json'} as const;interface IPublicData {@@ -39,6 +41,10 @@ export const PUBLIC_DATA_LIST: IPublicData[] = [key: "BIKE_SHARING",title: "Bike Sharing"},+ {+ key: "EARTHQUAKE",+ title: "Earthquakes"+ },{key: "CAR_SALES",title: "Car Sales"diff --git a/packages/graphic-walker/src/lib/gog.ts b/packages/graphic-walker/src/lib/gog.tsindex f5649716..2d5cbfc5 100644--- a/packages/graphic-walker/src/lib/gog.ts+++ b/packages/graphic-walker/src/lib/gog.ts@@ -1,5 +1,5 @@// File name: gog represents the Grammar of Graphics (theory by Wilkinson)-import { DraggableFieldState } from "../interfaces";+import { DraggableFieldState, IAnalyticType, ISemanticType } from "../interfaces";type SpitialEncodings = Pick<DraggableFieldState, 'columns' | 'rows'> | Pick<DraggableFieldState, 'latitude' | 'longitude'>type DraggableFieldValues = DraggableFieldState[Exclude<keyof DraggableFieldState, 'filters'>];@@ -29,12 +29,22 @@ const LR = {}, [] as DraggableFieldValues);}},- forceDimension(fields: DraggableFieldValues): DraggableFieldValues {- return fields.map(f => ({- ...f,- analyticType: 'dimension'- }))- }+ forceAnalyticType (analyticType: IAnalyticType) {+ return function (fields: DraggableFieldValues): DraggableFieldValues {+ return fields.map(f => ({+ ...f,+ analyticType+ }))+ }+ },+ forceSemanticType (semanticType: ISemanticType) {+ return function (fields: DraggableFieldValues): DraggableFieldValues {+ return fields.map(f => ({+ ...f,+ semanticType+ }))+ }+ },}type Operator<T> = (value: T) => T;function applyOperations<T>(initialValue: T, operators: Operator<T>[]): T {@@ -61,8 +71,16 @@ export function algebraLint <T extends SpitialEncodings | DraggableFieldValues>(} else if ('latitude' in encodings && 'longitude' in encodings && (encodings.latitude.length > 0 || encodings.longitude.length > 0)) {return {...encodings,- latitude: applyOperations(encodings.latitude, [LR.forceDimension, LR.crossLimit(1)]),- longitude: applyOperations(encodings.longitude, [LR.forceDimension, LR.crossLimit(1)])+ latitude: applyOperations(encodings.latitude, [+ LR.forceAnalyticType('dimension'),+ LR.forceSemanticType('quantitative'),+ LR.crossLimit(1)+ ]),+ longitude: applyOperations(encodings.longitude, [+ LR.forceAnalyticType('dimension'),+ LR.forceSemanticType('quantitative'),+ LR.crossLimit(1)+ ])};}return encodings;