An open source alternative to Tableau. Embeddable visual analytic
TypeScript bidatadata-analysisdata-miningdata-visualizationedak6skanarieslow-codepivot-tablereacttableautableau-alternativetypescriptvegavega-litevisualization
fix: add doc for custom color palette
islxyqwe4f171a8774df
diff --git a/README.md b/README.mdindex f19f71eb..d4eac8c9 100644--- a/README.md+++ b/README.md@@ -296,6 +296,56 @@ When you are using Server-side computation, you should provide `rawFields` togetCustomize the toolbar.+#### `channelScales`: optional _{ [`IChannelScales`](./packages/graphic-walker/src/interfaces.ts) }_++Customize the scale of color, opacity, and size channel.+see [Vega Docs](https://vega.github.io/vega/docs/schemes/#reference) for available color schemes.++Here are some examples:+```ts+// use a another color pattren+const channelScales = {+ color: {+ scheme: "tableau10"+ }+}+// use a diffrent color pattren in dark mode and light mode+const channelScales = {+ color({theme}) {+ if(theme === 'dark') {+ return {+ scheme: 'darkblue'+ }+ }else {+ return {+ scheme: 'lightmulti'+ }+ }+ }+}+// use a custom color palette+const channelScales = {+ color: {+ range: ['red', 'blue', '#000000']+ }+}+// customing opacity+const channelScales = {+ // map value of 0 - 255 to opacity 0 - 1+ opacity: {+ range: [0, 1],+ domain: [0, 255],+ }+}+// set min radius for arc chart+const channelScales = {+ radius: {+ rangeMin: 20+ }+}++```+### Ref```tsdiff --git a/packages/graphic-walker/src/index.tsx b/packages/graphic-walker/src/index.tsxindex e687d7b2..0f91a065 100644--- a/packages/graphic-walker/src/index.tsx+++ b/packages/graphic-walker/src/index.tsx@@ -40,5 +40,5 @@ export const GraphicWalker = observer(forwardRef<IGWHandler, IGWProps>((props, rexport { default as PureRenderer } from './renderer/pureRenderer';export { embedGraphicWalker } from './vanilla';export type { IGWProps };-export { ISegmentKey } from './interfaces';+export { ISegmentKey, ColorSchemes } from './interfaces';export { resolveSpecFromStoInfo } from './utils/save';\ No newline at end of filediff --git a/packages/graphic-walker/src/interfaces.ts b/packages/graphic-walker/src/interfaces.tsindex 15812bac..b6befa8c 100644--- a/packages/graphic-walker/src/interfaces.ts+++ b/packages/graphic-walker/src/interfaces.ts@@ -616,24 +616,26 @@ export type IColorSchemes =};export type IScale = {- domain?: [number, number] | string[],- domainMin?: number,- domainMax?: number,- range?: [number, number] | string[],- rangeMin?: number,- rangeMax?: number,-}+ domain?: [number, number] | string[];+ domainMin?: number;+ domainMax?: number;+ range?: [number, number] | string[];+ rangeMin?: number;+ rangeMax?: number;+};-export type IColorScale = IScale & { scheme?: IColorSchemes }+export type IColorScale = IScale & { scheme?: IColorSchemes };export type IFieldInfos = {- semanticType: ISemanticType,- theme: 'dark' | 'light',- values: any[],-}+ semanticType: ISemanticType;+ theme: 'dark' | 'light';+ values: any[];+};export interface IChannelScales {color?: IColorScale | ((info: IFieldInfos) => IColorScale);opacity?: IScale | ((info: IFieldInfos) => IScale);size?: IScale | ((info: IFieldInfos) => IScale);+ radius?: IScale | ((info: IFieldInfos) => IScale);+ theta?: IScale | ((info: IFieldInfos) => IScale);}diff --git a/packages/graphic-walker/src/main.tsx b/packages/graphic-walker/src/main.tsxindex 44e5a40c..bc9f49af 100644--- a/packages/graphic-walker/src/main.tsx+++ b/packages/graphic-walker/src/main.tsx@@ -13,10 +13,5 @@ embedGraphicWalker(document.getElementById('root') as HTMLElement, {type: 'GeoJSON',url: 'https://raw.githubusercontent.com/drei01/geojson-world-cities/f2a988af4bc15463df55586afbbffbd3068b7218/cities.geojson',},- ],- channelScales: {- color: {- scheme: 'bluegreen'- }- }+ ]});diff --git a/packages/graphic-walker/src/vis/spec/view.ts b/packages/graphic-walker/src/vis/spec/view.tsindex 2f496c48..e7e1382d 100644--- a/packages/graphic-walker/src/vis/spec/view.ts+++ b/packages/graphic-walker/src/vis/spec/view.ts@@ -102,7 +102,9 @@ export function resolveScales(scale: IChannelScales, view: any, data: readonly aaddScale('color');addScale('opacity');addScale('size');- console.log(newEncoding)+ addScale('radius');+ addScale('theta');+return {...view,encoding: newEncoding