From a9a4dfd2783cb3eac7864c7a6409d6dbec1f8d27 Mon Sep 17 00:00:00 2001 From: "yanzhi.yan" Date: Thu, 27 Jun 2024 14:48:56 +0800 Subject: [PATCH] feat(ava/advisor): add some meta info, includes 5 chart ckb, 1 purpose, 1 level of measure --- packages/ava/src/ckb/base.ts | 99 +++++++++++++++++++++++++------ packages/ava/src/ckb/constants.ts | 19 +++++- packages/ava/src/ckb/encode.ts | 14 +++++ 3 files changed, 114 insertions(+), 18 deletions(-) diff --git a/packages/ava/src/ckb/base.ts b/packages/ava/src/ckb/base.ts index cf6b6cd28..d6930e13c 100644 --- a/packages/ava/src/ckb/base.ts +++ b/packages/ava/src/ckb/base.ts @@ -1,6 +1,25 @@ import type { PureChartKnowledgeBase } from './types'; export const base: PureChartKnowledgeBase = { + indicator_chart: { + id: 'indicator_chart', + name: 'Value Chart', + alias: ['Indicator'], + family: ['Indicators'], + def: 'A chart show indicator number, can', + purpose: ['Value'], + coord: ['Other'], + category: ['Statistic'], + shape: ['Other'], + encodePres: {}, + dataPres: [ + { minQty: 0, maxQty: 2, fieldConditions: ['Time', 'Ordinal', 'Nominal'] }, + { minQty: 1, maxQty: '*', fieldConditions: ['Interval'] }, + ], + channel: [], + recRate: 'Recommended', + }, + line_chart: { id: 'line_chart', name: 'Line Chart', @@ -1333,23 +1352,69 @@ export const base: PureChartKnowledgeBase = { // recRate: 'Recommended', // }, - /* - * WIP: unavailable until completed - */ - // liquid_chart: { - // id: 'liquid_chart', - // name: 'Liquid Chart', - // alias: ['Liquid Ball', 'Progress Ball'], - // family: ['Others'], - // def: 'Liquid chart is a diagram to represent progress.', - // purpose: ['Composition'], - // coord: ['Other'], - // category: ['Diagram'], - // shape: ['Round'], - // dataPres: [{ minQty: 2, maxQty: 2, fieldConditions: ['Interval'] }], - // channel: ['Position'], - // recRate: 'Not Recommended', - // }, + liquid_chart: { + id: 'liquid_chart', + name: 'Liquid Chart', + alias: ['Liquid Ball', 'Progress Ball'], + family: ['ProgressCharts'], + def: 'Liquid chart is a diagram to represent progress.', + purpose: ['Progress', 'Value'], + coord: ['Other'], + category: ['Diagram'], + shape: ['Round'], + dataPres: [{ minQty: 1, maxQty: 2, fieldConditions: ['Interval'] }], + channel: ['Position'], + recRate: 'Not Recommended', + }, + + gauge_chart: { + id: 'gauge_chart', + name: 'Gauge Chart', + alias: [], + family: ['ProgressCharts'], + def: 'Gauge chart is a diagram to represent progress, different color with different progress.', + purpose: ['Progress', 'Value'], + coord: ['Other'], + category: ['Diagram'], + shape: ['Round'], + dataPres: [{ minQty: 1, maxQty: 2, fieldConditions: ['Interval'] }], + channel: ['Color', 'Position'], + recRate: 'Not Recommended', + }, + + progress_chart: { + id: 'progress_chart', + name: 'Progress Chart', + alias: [], + family: ['ProgressCharts'], + def: 'Progress Chart is a diagram to represent progress, display as bar.', + purpose: ['Progress'], + coord: ['Other'], + category: ['Diagram'], + shape: ['Bars'], + dataPres: [{ minQty: 1, maxQty: 2, fieldConditions: ['Interval'] }], + channel: ['Length'], + recRate: 'Not Recommended', + }, + + geo_area_map: { + id: 'geo_area_map', + name: 'Geo Area Map', + alias: [], + family: ['Others'], + def: 'Geo Area Map display data on a area map.', + purpose: ['Geo', 'Distribution'], + coord: ['Geo'], + category: ['Diagram'], + shape: ['Bars'], + dataPres: [ + { minQty: 1, maxQty: 2, fieldConditions: ['Interval'] }, + { minQty: 1, maxQty: 1, fieldConditions: ['Geo'] }, + { minQty: 0, maxQty: 1, fieldConditions: ['Geo', 'Nominal', 'Time'] }, + ], + channel: ['Size', 'Color', 'Position'], + recRate: 'Not Recommended', + }, /** * WIP: unavailable until completed diff --git a/packages/ava/src/ckb/constants.ts b/packages/ava/src/ckb/constants.ts index d77ad0d8c..b5f0b3379 100644 --- a/packages/ava/src/ckb/constants.ts +++ b/packages/ava/src/ckb/constants.ts @@ -6,6 +6,11 @@ * @public */ export const CHART_IDS = [ + 'indicator_chart', + 'liquid_chart', + 'gauge_chart', + 'progress_chart', + 'geo_area_map', 'line_chart', 'step_line_chart', 'area_chart', @@ -68,6 +73,7 @@ export const CHART_IDS = [ * @public */ export const FAMILIES = [ + 'Indicators', 'LineCharts', 'ColumnCharts', 'BarCharts', @@ -84,6 +90,7 @@ export const FAMILIES = [ 'PointLayer', 'HeatmapLayer', 'Table', + 'ProgressCharts', 'Others', ] as const; @@ -107,6 +114,8 @@ export const PURPOSES = [ 'Spatial', 'Anomaly', 'Value', + 'Progress', + 'Geo', ] as const; /** @@ -164,7 +173,15 @@ export const SHAPES = [ * * @public */ -export const LEVEL_OF_MEASUREMENTS = ['Nominal', 'Ordinal', 'Interval', 'Discrete', 'Continuous', 'Time'] as const; +export const LEVEL_OF_MEASUREMENTS = [ + 'Nominal', + 'Ordinal', + 'Interval', + 'Discrete', + 'Continuous', + 'Time', + 'Geo', +] as const; /** * Array of channels. diff --git a/packages/ava/src/ckb/encode.ts b/packages/ava/src/ckb/encode.ts index e03f701aa..81a8e7f87 100644 --- a/packages/ava/src/ckb/encode.ts +++ b/packages/ava/src/ckb/encode.ts @@ -106,10 +106,24 @@ export const heatmapEncodeRequirement: EncodeRequirements = { }, }; +export const indicatorEncodeRequirement: EncodeRequirements = { + x: { + minQty: 0, + maxQty: 1, + fieldConditions: ['Time', 'Nominal'], + }, + y: { + minQty: 0, + maxQty: '*', + fieldConditions: ['Interval'], + }, +}; + export const areaEncodeRequirement = lineEncodeRequirement; export const columnEncodeRequirement = barEncodeRequirement; export const chartType2EncodeRequirement: Partial> = { + indicator_chart: indicatorEncodeRequirement, line_chart: lineEncodeRequirement, pie_chart: pieEncodeRequirement, donut_chart: pieEncodeRequirement,