Skip to content

Commit caf2294

Browse files
committed
fix(workspace): Add missing d3fc CSS variables for chart plugins
Fixes #3101 Chart plugins (Y Line, Y Bar, Y Area, etc.) crash in perspective-workspace with error 'Cannot read properties of null (reading opacity)'. Root cause: workspace theme files were missing the d3fc CSS variable definitions (@include perspective-viewer-pro--d3fc mixin), causing --d3fc-series and related variables to be undefined. Changes: - Add @include perspective-viewer-pro--d3fc to pro.less - Add @include perspective-viewer-pro-dark--d3fc to pro-dark.less - Add defensive null check in getOpacityFromColor() as additional protection
1 parent 046a0ac commit caf2294

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

packages/viewer-d3fc/src/ts/series/colorStyles.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ export const initialiseStyles = (
6060
};
6161

6262
const getOpacityFromColor = (color) => {
63-
return d3.color(color).opacity;
63+
if (!color) {
64+
return 1.0; // Default to fully opaque when color is undefined
65+
}
66+
const parsed = d3.color(color);
67+
return parsed ? parsed.opacity : 1.0;
6468
};
6569

6670
const stepAsColor = (value, opacity) => {

packages/workspace/src/themes/pro-dark.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ perspective-workspace perspective-viewer[settings] {
3939
perspective-workspace {
4040
@include perspective-workspace-pro-base;
4141
@include perspective-viewer-pro-dark--colors;
42+
@include perspective-viewer-pro-dark--d3fc; // Fix: Add d3fc CSS variables for chart plugins
4243

4344
background-color: #000202;
4445
color: white;

packages/workspace/src/themes/pro.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ perspective-indicator[theme="Pro Light"] {
2121
perspective-workspace {
2222
@include perspective-workspace-pro-base;
2323
@include perspective-viewer-pro--colors;
24+
@include perspective-viewer-pro--d3fc; // Fix: Add d3fc CSS variables for chart plugins
2425
background-color: #dadada;
2526
}
2627

0 commit comments

Comments
 (0)