An open source alternative to Tableau. Embeddable visual analytic
TypeScript bidatadata-analysisdata-miningdata-visualizationedak6skanarieslow-codepivot-tablereacttableautableau-alternativetypescriptvegavega-litevisualization
fix: painter webgl renderer background color (#326)
islxyqwea7976553ca73
diff --git a/packages/graphic-walker/src/components/painter/index.tsx b/packages/graphic-walker/src/components/painter/index.tsxindex 5268c166..34305a05 100644--- a/packages/graphic-walker/src/components/painter/index.tsx+++ b/packages/graphic-walker/src/components/painter/index.tsx@@ -21,8 +21,9 @@ import { Button } from '../ui/button';import { Dialog, DialogContent } from '../ui/dialog';import { Slider } from '../ui/slider';import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs';-import { themeContext } from '@/store/theme';+import { colorContext, themeContext } from '@/store/theme';import { WebGLRenderer } from 'vega-webgl-renderer';+import { parseColorToHex } from '@/utils/colors';//@ts-ignoreCanvasHandler.prototype.context = function () {@@ -611,15 +612,16 @@ const Painter = ({ themeConfig, themeKey }: { themeConfig?: GWGlobalConfig; them}, []);const mediaTheme = useContext(themeContext);+ const colorConfig = useContext(colorContext);const vegaConfig = useMemo<VegaGlobalConfig>(() => {const presetConfig = themeConfig ?? builtInThemes[themeKey ?? 'vega'];const config: VegaGlobalConfig = {...presetConfig?.[mediaTheme],- background: 'transparent',+ background: parseColorToHex(colorConfig[mediaTheme].background),};return config;- }, [themeConfig, themeKey, mediaTheme]);+ }, [colorConfig, themeConfig, themeKey, mediaTheme]);return (<Dialogdiff --git a/packages/graphic-walker/src/utils/colors.ts b/packages/graphic-walker/src/utils/colors.tsindex 0c41b316..a640901d 100644--- a/packages/graphic-walker/src/utils/colors.ts+++ b/packages/graphic-walker/src/utils/colors.ts@@ -1,6 +1,7 @@import { IColorConfig, IColorPalette, IColorSet } from '../interfaces';import colorString from 'color-string';import rgb from 'color-space/rgb.js';+import hsl from 'color-space/hsl.js';import hwb from 'color-space/hwb.js';import colors from 'tailwindcss/colors';@@ -36,6 +37,10 @@ export function parseColorToHSL(color: string) {return `${h} ${s}% ${l}%`;}+export function parseColorToHex(color: string) {+ return colorString.to.hex(hsl.rgb(toHSL(color)));+}+function ColorSetToCss(set: Required<IColorSet>) {return Object.entries(set).map(([name, value]) => `--${name}:${parseColorToHSL(value)};`)