Skip to content

An open source alternative to Tableau. Embeddable visual analytic

fix: facet dark theme and legend for multi-view

ObservedObserver940225f5b744
diff --git a/packages/graphic-walker/src/App.tsx b/packages/graphic-walker/src/App.tsx
index 4e38c80b..eaefc681 100644
--- a/packages/graphic-walker/src/App.tsx
+++ b/packages/graphic-walker/src/App.tsx
@@ -166,7 +166,7 @@ const App = observer<IGWProps>(function App (props) {
{vizEmbededMenu.show && (
<ClickMenu x={vizEmbededMenu.position[0]} y={vizEmbededMenu.position[1]}>
<div
- className="flex items-center whitespace-nowrap py-1 px-4 hover:bg-gray-100"
+ className="flex items-center whitespace-nowrap py-1 px-4 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer"
onClick={() => {
commonStore.closeEmbededMenu();
commonStore.setShowInsightBoard(true);
diff --git a/packages/graphic-walker/src/components/clickMenu.tsx b/packages/graphic-walker/src/components/clickMenu.tsx
index 85a77164..137f348c 100644
--- a/packages/graphic-walker/src/components/clickMenu.tsx
+++ b/packages/graphic-walker/src/components/clickMenu.tsx
@@ -3,16 +3,10 @@ import styled from "styled-components";
const MenuContainer = styled.div`
min-width: 100px;
- background-color: #fff;
- border: 1px solid #f0f0f0;
position: absolute;
z-index: 99;
cursor: pointer;
padding: 4px;
- @media (prefers-color-scheme: dark) {
- background-color: #000;
- border: 1px solid #4b5563;
- }
`;
interface ClickMenuProps {
x: number;
@@ -22,7 +16,7 @@ interface ClickMenuProps {
const ClickMenu: React.FC<ClickMenuProps> = (props) => {
const { x, y, children } = props;
return (
- <MenuContainer className="shadow-lg text-sm" style={{ left: x + "px", top: y + "px" }}>
+ <MenuContainer className="shadow-lg text-sm bg-white border border-gray-100 dark:bg-black dark:border-gray-700" style={{ left: x + "px", top: y + "px" }}>
{children}
</MenuContainer>
);
diff --git a/packages/graphic-walker/src/vis/react-vega.tsx b/packages/graphic-walker/src/vis/react-vega.tsx
index 1a786463..96c31099 100644
--- a/packages/graphic-walker/src/vis/react-vega.tsx
+++ b/packages/graphic-walker/src/vis/react-vega.tsx
@@ -105,6 +105,7 @@ interface SingleViewProps {
asCrossFilterTrigger: boolean;
selectEncoding: 'default' | 'none';
brushEncoding: 'x' | 'y' | 'default' | 'none';
+ hideLegend?: boolean;
}
function availableChannels (geomType: string): Set<string> {
@@ -203,9 +204,16 @@ function getSingleView(props: SingleViewProps) {
brushEncoding,
enableCrossFilter,
asCrossFilterTrigger,
+ hideLegend = false,
} = props
const fields: IViewField[] = [x, y, color, opacity, size, shape, row, column, xOffset, yOffset, theta, radius]
let markType = geomType;
+ let config: any = {};
+ if (hideLegend) {
+ config.legend = {
+ disable: true
+ };
+ }
if (geomType === 'auto') {
const types: ISemanticType[] = [];
if (x !== NULL_FIELD) types.push(x.semanticType)//types.push(getFieldType(x));
@@ -220,6 +228,7 @@ function getSingleView(props: SingleViewProps) {
channelStack(encoding, stack);
if (!enableCrossFilter || brushEncoding === 'none' && selectEncoding === 'none') {
return {
+ config,
mark: {
type: markType,
opacity: 0.96,
@@ -327,6 +336,7 @@ function getSingleView(props: SingleViewProps) {
if (brushEncoding !== 'none') {
return {
+ config,
transform: asCrossFilterTrigger ? [] : [
{ filter: { param: BRUSH_SIGNAL_NAME } }
],
@@ -347,6 +357,7 @@ function getSingleView(props: SingleViewProps) {
}
return {
+ config,
transform: asCrossFilterTrigger ? [] : [
{ filter: { param: POINT_SIGNAL_NAME } }
],
@@ -555,6 +566,7 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
for (let i = 0; i < rowRepeatFields.length; i++) {
for (let j = 0; j < colRepeatFields.length; j++, index++) {
const sourceId = index;
+ const hasLegend = i === 0 && j === colRepeatFields.length - 1;
const singleView = getSingleView({
x: colRepeatFields[j] || NULL_FIELD,
y: rowRepeatFields[i] || NULL_FIELD,
@@ -575,6 +587,7 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
brushEncoding,
enableCrossFilter: crossFilterTriggerIdx !== -1,
asCrossFilterTrigger: crossFilterTriggerIdx === sourceId,
+ hideLegend: !hasLegend,
});
const node = i * colRepeatFields.length + j < viewPlaceholders.length ? viewPlaceholders[i * colRepeatFields.length + j].current : null
let commonSpec = { ...spec };
diff --git a/packages/graphic-walker/src/vis/theme.ts b/packages/graphic-walker/src/vis/theme.ts
index d0f49101..a3809ab5 100644
--- a/packages/graphic-walker/src/vis/theme.ts
+++ b/packages/graphic-walker/src/vis/theme.ts
@@ -1,6 +1,10 @@
const DEFAULT_COLOR = "#5B8FF9";
const DARK_COMMON_DESIGN = {
background: "transparent",
+ header: {
+ titleColor: "#d1d5db", // change title color to white
+ labelColor: "#d1d5db", // change label color to white
+ },
axis: {
gridColor: "#666",
domainColor: "#d1d5db", // change axis color to white