@spteck/fluentui-react-charts 1.0.11 → 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/dist/charts/ComboChart/ComboChart.d.ts +6 -1
- package/dist/fluentui-react-charts.cjs.development.js +70 -8
- package/dist/fluentui-react-charts.cjs.development.js.map +1 -1
- package/dist/fluentui-react-charts.cjs.production.min.js +1 -1
- package/dist/fluentui-react-charts.cjs.production.min.js.map +1 -1
- package/dist/fluentui-react-charts.esm.js +70 -8
- package/dist/fluentui-react-charts.esm.js.map +1 -1
- package/dist/hooks/useChartUtils.d.ts +2 -2
- package/package.json +1 -1
|
@@ -12,6 +12,11 @@ export interface ComboChartProps<T> {
|
|
|
12
12
|
title?: string;
|
|
13
13
|
showDataLabels?: boolean;
|
|
14
14
|
theme?: Theme;
|
|
15
|
+
/**
|
|
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 for bars.
|
|
18
|
+
*/
|
|
19
|
+
axesMode?: 'legacy' | 'dual';
|
|
15
20
|
}
|
|
16
|
-
export declare function ComboChart<T extends object>({ data, getPrimary, getSecondary, title, showDataLabels, theme, }: ComboChartProps<T>): React.JSX.Element;
|
|
21
|
+
export declare function ComboChart<T extends object>({ data, getPrimary, getSecondary, title, showDataLabels, theme, axesMode, }: ComboChartProps<T>): React.JSX.Element;
|
|
17
22
|
export default ComboChart;
|
|
@@ -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(
|
|
790
|
-
|
|
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.
|
|
819
|
+
var tooltipBodyColor = theme.colorNeutralForeground1;
|
|
818
820
|
var borderColor = theme.colorNeutralStroke2;
|
|
819
821
|
var callbacks = {
|
|
820
822
|
title: function title(context) {
|
|
@@ -1719,7 +1721,9 @@ function ComboChart(_ref) {
|
|
|
1719
1721
|
_ref$showDataLabels = _ref.showDataLabels,
|
|
1720
1722
|
showDataLabels = _ref$showDataLabels === void 0 ? false : _ref$showDataLabels,
|
|
1721
1723
|
_ref$theme = _ref.theme,
|
|
1722
|
-
theme = _ref$theme === void 0 ? reactComponents.webLightTheme : _ref$theme
|
|
1724
|
+
theme = _ref$theme === void 0 ? reactComponents.webLightTheme : _ref$theme,
|
|
1725
|
+
_ref$axesMode = _ref.axesMode,
|
|
1726
|
+
axesMode = _ref$axesMode === void 0 ? 'legacy' : _ref$axesMode;
|
|
1723
1727
|
var _useState = React.useState(function () {
|
|
1724
1728
|
return data.map(function (s) {
|
|
1725
1729
|
return s.label;
|
|
@@ -1774,13 +1778,16 @@ function ComboChart(_ref) {
|
|
|
1774
1778
|
return {
|
|
1775
1779
|
type: series.type,
|
|
1776
1780
|
label: series.label,
|
|
1777
|
-
|
|
1781
|
+
// Respect explicit series yAxisID if provided (retro-compatibility).
|
|
1782
|
+
yAxisID: (_series$yAxisID = series.yAxisID) != null ? _series$yAxisID : axesMode === 'dual' ? series.type === 'bar' ? 'y-bar' : 'y-line' : 'y',
|
|
1778
1783
|
data: allCategories.map(function (cat) {
|
|
1779
1784
|
var found = series.data.find(function (d) {
|
|
1780
1785
|
return getPrimary(d) === cat;
|
|
1781
1786
|
});
|
|
1782
1787
|
return found ? getSecondary(found) : 0;
|
|
1783
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,
|
|
1784
1791
|
backgroundColor: seriesColors[series.label],
|
|
1785
1792
|
borderColor: seriesColors[series.label],
|
|
1786
1793
|
fill: series.type === 'bar',
|
|
@@ -1805,7 +1812,7 @@ function ComboChart(_ref) {
|
|
|
1805
1812
|
labelColor = _useMemo.labelColor,
|
|
1806
1813
|
gridColor = _useMemo.gridColor;
|
|
1807
1814
|
var options = React.useMemo(function () {
|
|
1808
|
-
|
|
1815
|
+
var base = _extends({
|
|
1809
1816
|
responsive: true,
|
|
1810
1817
|
maintainAspectRatio: false
|
|
1811
1818
|
}, getInstantInteractionAnimations(), {
|
|
@@ -1836,7 +1843,59 @@ function ComboChart(_ref) {
|
|
|
1836
1843
|
display: false
|
|
1837
1844
|
},
|
|
1838
1845
|
tooltip: createFluentTooltip(theme)
|
|
1839
|
-
}
|
|
1846
|
+
}
|
|
1847
|
+
});
|
|
1848
|
+
if (axesMode === 'dual') {
|
|
1849
|
+
return _extends({}, base, {
|
|
1850
|
+
scales: {
|
|
1851
|
+
x: {
|
|
1852
|
+
stacked: true,
|
|
1853
|
+
ticks: {
|
|
1854
|
+
color: labelColor,
|
|
1855
|
+
font: {
|
|
1856
|
+
family: fontFamily,
|
|
1857
|
+
size: fontSize
|
|
1858
|
+
}
|
|
1859
|
+
},
|
|
1860
|
+
grid: {
|
|
1861
|
+
color: gridColor
|
|
1862
|
+
}
|
|
1863
|
+
},
|
|
1864
|
+
'y-bar': {
|
|
1865
|
+
type: 'linear',
|
|
1866
|
+
position: 'left',
|
|
1867
|
+
stacked: true,
|
|
1868
|
+
offset: true,
|
|
1869
|
+
ticks: {
|
|
1870
|
+
color: labelColor,
|
|
1871
|
+
font: {
|
|
1872
|
+
family: fontFamily,
|
|
1873
|
+
size: fontSize
|
|
1874
|
+
}
|
|
1875
|
+
},
|
|
1876
|
+
grid: {
|
|
1877
|
+
color: gridColor
|
|
1878
|
+
}
|
|
1879
|
+
},
|
|
1880
|
+
'y-line': {
|
|
1881
|
+
type: 'linear',
|
|
1882
|
+
position: 'right',
|
|
1883
|
+
stacked: false,
|
|
1884
|
+
ticks: {
|
|
1885
|
+
color: labelColor,
|
|
1886
|
+
font: {
|
|
1887
|
+
family: fontFamily,
|
|
1888
|
+
size: fontSize
|
|
1889
|
+
}
|
|
1890
|
+
},
|
|
1891
|
+
grid: {
|
|
1892
|
+
color: gridColor
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
return _extends({}, base, {
|
|
1840
1899
|
scales: {
|
|
1841
1900
|
x: {
|
|
1842
1901
|
ticks: {
|
|
@@ -1866,7 +1925,7 @@ function ComboChart(_ref) {
|
|
|
1866
1925
|
}
|
|
1867
1926
|
}
|
|
1868
1927
|
});
|
|
1869
|
-
}, [title, showDataLabels, theme, fontFamily, fontSize, labelColor, gridColor, createFluentTooltip]);
|
|
1928
|
+
}, [title, showDataLabels, theme, fontFamily, fontSize, labelColor, gridColor, createFluentTooltip, getInstantInteractionAnimations, axesMode]);
|
|
1870
1929
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
1871
1930
|
className: styles.chartWithLegend
|
|
1872
1931
|
}, React__default.createElement("div", {
|
|
@@ -3377,6 +3436,7 @@ var chartProps = function chartProps(chart) {
|
|
|
3377
3436
|
};
|
|
3378
3437
|
};
|
|
3379
3438
|
var getChartComponent = function getChartComponent(chart, theme) {
|
|
3439
|
+
var _chart$axesMode;
|
|
3380
3440
|
var type = chart.type;
|
|
3381
3441
|
var fuiTheme = theme != null ? theme : reactComponents.webLightTheme;
|
|
3382
3442
|
switch (type) {
|
|
@@ -3410,6 +3470,8 @@ var getChartComponent = function getChartComponent(chart, theme) {
|
|
|
3410
3470
|
case 'multiple-axes':
|
|
3411
3471
|
return React__default.createElement(ComboChart, Object.assign({}, chartProps(chart), {
|
|
3412
3472
|
theme: fuiTheme,
|
|
3473
|
+
// allow the originating chart descriptor to opt into dual axes
|
|
3474
|
+
axesMode: (_chart$axesMode = chart.axesMode) != null ? _chart$axesMode : 'dual',
|
|
3413
3475
|
data: chart.data.map(function (series) {
|
|
3414
3476
|
var _series$type;
|
|
3415
3477
|
return {
|