@spteck/fluentui-react-charts 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -304,31 +304,6 @@ const targetData = [
304
304
  title="Sales vs Target"
305
305
  theme={webLightTheme}
306
306
  />
307
-
308
- > Note: ComboChart supports a backward-compatible dual-axis layout via the `axesMode` prop.
309
- > - Default: `axesMode="legacy"` — preserves previous behavior: a single y-axis named `y` and a non-stacked x-axis.
310
- > - Dual mode: `axesMode="dual"` — enables a stacked x-axis and two named y-axes: `y-bar` (left) and `y-line` (right).
311
-
312
- Usage examples:
313
-
314
- ```tsx
315
- // legacy (default) — unchanged behavior for existing consumers
316
- <ComboChart
317
- data={[{ label: 'Sales', data: salesData, type: 'bar' }]}
318
- getPrimary={(d) => d.month}
319
- getSecondary={(d) => d.value}
320
- />
321
-
322
- // dual mode — bars default to 'y-bar' (stacked on x), lines default to 'y-line'
323
- <ComboChart
324
- data={[
325
- { label: 'Sales', data: salesData, type: 'bar' },
326
- { label: 'Target', data: targetData, type: 'line' }
327
- ]}
328
- getPrimary={(d) => d.month}
329
- getSecondary={(d) => d.value}
330
- axesMode="dual"
331
- />
332
307
  ```
333
308
 
334
309
  #### BubbleChart
@@ -14,7 +14,7 @@ export interface ComboChartProps<T> {
14
14
  theme?: Theme;
15
15
  /**
16
16
  * 'legacy' keeps previous behaviour (single 'y' axis, non-stacked x).
17
- * 'dual' enables named y-axes ('y-bar' and 'y-line') and stacked x.
17
+ * 'dual' enables named y-axes ('y-bar' and 'y-line') and stacked x for bars.
18
18
  */
19
19
  axesMode?: 'legacy' | 'dual';
20
20
  }
@@ -786,8 +786,10 @@ var lightenColor = function lightenColor(hex, amount) {
786
786
  };
787
787
  return "#" + toHex(r) + toHex(g) + toHex(b);
788
788
  };
789
- var getFluentPalette = function getFluentPalette(_theme) {
790
- return ['#4e79a7', '#f28e2c', '#e15759', '#76b7b2', '#59a14f', '#edc949', '#af7aa1', '#ff9da7', '#9c755f', '#bab0ab', '#8cd17d', '#b6992d', '#d37295', '#fabfd2', '#79706e'];
789
+ var getFluentPalette = function getFluentPalette(theme) {
790
+ // Check if theme is dark by looking at global color tokens
791
+ var isDark = theme.colorNeutralBackground1.startsWith('#1') || theme.colorNeutralBackground1 === '#000000';
792
+ return isDark ? ['#2899f5', '#ff8c00', '#32cd32', '#f06b71', '#c390f2', '#00b7c3', '#ffb900', '#b4a0ff', '#60cdff', '#92c353'] : ['#0078d4', '#d83b01', '#107c10', '#a4262c', '#5c2d91', '#008272', '#c43148', '#005a9e', '#8764b8', '#498205'];
791
793
  };
792
794
  /**
793
795
  * Returns animation configuration for instant interactions.
@@ -814,7 +816,7 @@ function createFluentTooltip(theme) {
814
816
  var fontSize = parseInt(theme.fontSizeBase200.replace('px', '')) || 14;
815
817
  var tooltipBg = theme.colorNeutralBackground1;
816
818
  var tooltipTitleColor = theme.colorNeutralForeground1;
817
- var tooltipBodyColor = theme.colorNeutralForeground2;
819
+ var tooltipBodyColor = theme.colorNeutralForeground1;
818
820
  var borderColor = theme.colorNeutralStroke2;
819
821
  var callbacks = {
820
822
  title: function title(context) {
@@ -1776,7 +1778,7 @@ function ComboChart(_ref) {
1776
1778
  return {
1777
1779
  type: series.type,
1778
1780
  label: series.label,
1779
- // default yAxis assignment: legacy uses single 'y', dual uses 'y-bar'/'y-line'
1781
+ // Respect explicit series yAxisID if provided (retro-compatibility).
1780
1782
  yAxisID: (_series$yAxisID = series.yAxisID) != null ? _series$yAxisID : axesMode === 'dual' ? series.type === 'bar' ? 'y-bar' : 'y-line' : 'y',
1781
1783
  data: allCategories.map(function (cat) {
1782
1784
  var found = series.data.find(function (d) {
@@ -1784,6 +1786,8 @@ function ComboChart(_ref) {
1784
1786
  });
1785
1787
  return found ? getSecondary(found) : 0;
1786
1788
  }),
1789
+ // In dual mode, group bars into a common stack so they stack on x axis
1790
+ stack: axesMode === 'dual' && series.type === 'bar' ? 'barStack' : undefined,
1787
1791
  backgroundColor: seriesColors[series.label],
1788
1792
  borderColor: seriesColors[series.label],
1789
1793
  fill: series.type === 'bar',
@@ -1861,6 +1865,7 @@ function ComboChart(_ref) {
1861
1865
  type: 'linear',
1862
1866
  position: 'left',
1863
1867
  stacked: true,
1868
+ offset: true,
1864
1869
  ticks: {
1865
1870
  color: labelColor,
1866
1871
  font: {
@@ -1893,7 +1898,6 @@ function ComboChart(_ref) {
1893
1898
  return _extends({}, base, {
1894
1899
  scales: {
1895
1900
  x: {
1896
- stacked: false,
1897
1901
  ticks: {
1898
1902
  color: labelColor,
1899
1903
  font: {
@@ -1906,9 +1910,7 @@ function ComboChart(_ref) {
1906
1910
  }
1907
1911
  },
1908
1912
  y: {
1909
- type: 'linear',
1910
1913
  position: 'left',
1911
- stacked: false,
1912
1914
  ticks: {
1913
1915
  color: labelColor,
1914
1916
  font: {
@@ -1918,7 +1920,8 @@ function ComboChart(_ref) {
1918
1920
  },
1919
1921
  grid: {
1920
1922
  color: gridColor
1921
- }
1923
+ },
1924
+ stacked: false
1922
1925
  }
1923
1926
  }
1924
1927
  });
@@ -3433,6 +3436,7 @@ var chartProps = function chartProps(chart) {
3433
3436
  };
3434
3437
  };
3435
3438
  var getChartComponent = function getChartComponent(chart, theme) {
3439
+ var _chart$axesMode;
3436
3440
  var type = chart.type;
3437
3441
  var fuiTheme = theme != null ? theme : reactComponents.webLightTheme;
3438
3442
  switch (type) {
@@ -3466,6 +3470,8 @@ var getChartComponent = function getChartComponent(chart, theme) {
3466
3470
  case 'multiple-axes':
3467
3471
  return React__default.createElement(ComboChart, Object.assign({}, chartProps(chart), {
3468
3472
  theme: fuiTheme,
3473
+ // allow the originating chart descriptor to opt into dual axes
3474
+ axesMode: (_chart$axesMode = chart.axesMode) != null ? _chart$axesMode : 'dual',
3469
3475
  data: chart.data.map(function (series) {
3470
3476
  var _series$type;
3471
3477
  return {