Skip to content

Commit cdec445

Browse files
authored
Merge pull request #111 from microsoft/user/mattwar/FixNegativeAxisLabels
Fix fonts to correctly display negative axis labels
2 parents aacb107 + 08675f9 commit cdec445

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/Client/features/plotlyChartProvider.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ const PlotlyAxisSides = {
7878

7979
const PlotlyColorways = ChartColorways;
8080

81+
// Set Font family so a font is picked that has good Unicode support.
82+
const PlotlyFontFamily =
83+
"'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif";
84+
8185
const SankeyDefaultNodeColors: readonly string[] = [
8286
'#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd',
8387
'#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf',
@@ -486,7 +490,7 @@ class PlotlyChartBuilder {
486490
...this._layout,
487491
paper_bgcolor: '#1e1e1e',
488492
plot_bgcolor: '#1e1e1e',
489-
font: { color: '#f2f5fa' },
493+
font: { color: '#f2f5fa', family: PlotlyFontFamily },
490494
colorway: [...PlotlyColorways.Default],
491495
xaxis: { ...(this._layout.xaxis ?? {}), ...darkAxis },
492496
yaxis: { ...(this._layout.yaxis ?? {}), ...darkAxis },
@@ -511,7 +515,7 @@ class PlotlyChartBuilder {
511515
...this._layout,
512516
paper_bgcolor: '#ffffff',
513517
plot_bgcolor: '#ffffff',
514-
font: { color: '#2a3f5f' },
518+
font: { color: '#2a3f5f', family: PlotlyFontFamily },
515519
xaxis: { ...(this._layout.xaxis ?? {}), ...lightAxis },
516520
yaxis: { ...(this._layout.yaxis ?? {}), ...lightAxis },
517521
};
@@ -3229,7 +3233,9 @@ function applyDarkModeToLayout(layout: Record<string, unknown>): Record<string,
32293233
layout.plot_bgcolor = '#1e1e1e';
32303234

32313235
if (!layout.font || typeof layout.font !== 'object') { layout.font = {}; }
3232-
(layout.font as Record<string, unknown>).color = '#f2f5fa';
3236+
const font = layout.font as Record<string, unknown>;
3237+
font.color = '#f2f5fa';
3238+
if (!font.family) { font.family = PlotlyFontFamily; }
32333239

32343240
applyDarkModeToAxis(layout, 'xaxis');
32353241
applyDarkModeToAxis(layout, 'yaxis');
@@ -3273,7 +3279,9 @@ function applyLightModeToLayout(layout: Record<string, unknown>): Record<string,
32733279
layout.plot_bgcolor = '#ffffff';
32743280

32753281
if (!layout.font || typeof layout.font !== 'object') { layout.font = {}; }
3276-
(layout.font as Record<string, unknown>).color = '#2a3f5f';
3282+
const font = layout.font as Record<string, unknown>;
3283+
font.color = '#2a3f5f';
3284+
if (!font.family) { font.family = PlotlyFontFamily; }
32773285

32783286
applyLightModeToAxis(layout, 'xaxis');
32793287
applyLightModeToAxis(layout, 'yaxis');

0 commit comments

Comments
 (0)