@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
|
@@ -779,8 +779,10 @@ var lightenColor = function lightenColor(hex, amount) {
|
|
|
779
779
|
};
|
|
780
780
|
return "#" + toHex(r) + toHex(g) + toHex(b);
|
|
781
781
|
};
|
|
782
|
-
var getFluentPalette = function getFluentPalette(
|
|
783
|
-
|
|
782
|
+
var getFluentPalette = function getFluentPalette(theme) {
|
|
783
|
+
// Check if theme is dark by looking at global color tokens
|
|
784
|
+
var isDark = theme.colorNeutralBackground1.startsWith('#1') || theme.colorNeutralBackground1 === '#000000';
|
|
785
|
+
return isDark ? ['#2899f5', '#ff8c00', '#32cd32', '#f06b71', '#c390f2', '#00b7c3', '#ffb900', '#b4a0ff', '#60cdff', '#92c353'] : ['#0078d4', '#d83b01', '#107c10', '#a4262c', '#5c2d91', '#008272', '#c43148', '#005a9e', '#8764b8', '#498205'];
|
|
784
786
|
};
|
|
785
787
|
/**
|
|
786
788
|
* Returns animation configuration for instant interactions.
|
|
@@ -807,7 +809,7 @@ function createFluentTooltip(theme) {
|
|
|
807
809
|
var fontSize = parseInt(theme.fontSizeBase200.replace('px', '')) || 14;
|
|
808
810
|
var tooltipBg = theme.colorNeutralBackground1;
|
|
809
811
|
var tooltipTitleColor = theme.colorNeutralForeground1;
|
|
810
|
-
var tooltipBodyColor = theme.
|
|
812
|
+
var tooltipBodyColor = theme.colorNeutralForeground1;
|
|
811
813
|
var borderColor = theme.colorNeutralStroke2;
|
|
812
814
|
var callbacks = {
|
|
813
815
|
title: function title(context) {
|
|
@@ -1712,7 +1714,9 @@ function ComboChart(_ref) {
|
|
|
1712
1714
|
_ref$showDataLabels = _ref.showDataLabels,
|
|
1713
1715
|
showDataLabels = _ref$showDataLabels === void 0 ? false : _ref$showDataLabels,
|
|
1714
1716
|
_ref$theme = _ref.theme,
|
|
1715
|
-
theme = _ref$theme === void 0 ? webLightTheme : _ref$theme
|
|
1717
|
+
theme = _ref$theme === void 0 ? webLightTheme : _ref$theme,
|
|
1718
|
+
_ref$axesMode = _ref.axesMode,
|
|
1719
|
+
axesMode = _ref$axesMode === void 0 ? 'legacy' : _ref$axesMode;
|
|
1716
1720
|
var _useState = useState(function () {
|
|
1717
1721
|
return data.map(function (s) {
|
|
1718
1722
|
return s.label;
|
|
@@ -1767,13 +1771,16 @@ function ComboChart(_ref) {
|
|
|
1767
1771
|
return {
|
|
1768
1772
|
type: series.type,
|
|
1769
1773
|
label: series.label,
|
|
1770
|
-
|
|
1774
|
+
// Respect explicit series yAxisID if provided (retro-compatibility).
|
|
1775
|
+
yAxisID: (_series$yAxisID = series.yAxisID) != null ? _series$yAxisID : axesMode === 'dual' ? series.type === 'bar' ? 'y-bar' : 'y-line' : 'y',
|
|
1771
1776
|
data: allCategories.map(function (cat) {
|
|
1772
1777
|
var found = series.data.find(function (d) {
|
|
1773
1778
|
return getPrimary(d) === cat;
|
|
1774
1779
|
});
|
|
1775
1780
|
return found ? getSecondary(found) : 0;
|
|
1776
1781
|
}),
|
|
1782
|
+
// In dual mode, group bars into a common stack so they stack on x axis
|
|
1783
|
+
stack: axesMode === 'dual' && series.type === 'bar' ? 'barStack' : undefined,
|
|
1777
1784
|
backgroundColor: seriesColors[series.label],
|
|
1778
1785
|
borderColor: seriesColors[series.label],
|
|
1779
1786
|
fill: series.type === 'bar',
|
|
@@ -1798,7 +1805,7 @@ function ComboChart(_ref) {
|
|
|
1798
1805
|
labelColor = _useMemo.labelColor,
|
|
1799
1806
|
gridColor = _useMemo.gridColor;
|
|
1800
1807
|
var options = useMemo(function () {
|
|
1801
|
-
|
|
1808
|
+
var base = _extends({
|
|
1802
1809
|
responsive: true,
|
|
1803
1810
|
maintainAspectRatio: false
|
|
1804
1811
|
}, getInstantInteractionAnimations(), {
|
|
@@ -1829,7 +1836,59 @@ function ComboChart(_ref) {
|
|
|
1829
1836
|
display: false
|
|
1830
1837
|
},
|
|
1831
1838
|
tooltip: createFluentTooltip(theme)
|
|
1832
|
-
}
|
|
1839
|
+
}
|
|
1840
|
+
});
|
|
1841
|
+
if (axesMode === 'dual') {
|
|
1842
|
+
return _extends({}, base, {
|
|
1843
|
+
scales: {
|
|
1844
|
+
x: {
|
|
1845
|
+
stacked: true,
|
|
1846
|
+
ticks: {
|
|
1847
|
+
color: labelColor,
|
|
1848
|
+
font: {
|
|
1849
|
+
family: fontFamily,
|
|
1850
|
+
size: fontSize
|
|
1851
|
+
}
|
|
1852
|
+
},
|
|
1853
|
+
grid: {
|
|
1854
|
+
color: gridColor
|
|
1855
|
+
}
|
|
1856
|
+
},
|
|
1857
|
+
'y-bar': {
|
|
1858
|
+
type: 'linear',
|
|
1859
|
+
position: 'left',
|
|
1860
|
+
stacked: true,
|
|
1861
|
+
offset: true,
|
|
1862
|
+
ticks: {
|
|
1863
|
+
color: labelColor,
|
|
1864
|
+
font: {
|
|
1865
|
+
family: fontFamily,
|
|
1866
|
+
size: fontSize
|
|
1867
|
+
}
|
|
1868
|
+
},
|
|
1869
|
+
grid: {
|
|
1870
|
+
color: gridColor
|
|
1871
|
+
}
|
|
1872
|
+
},
|
|
1873
|
+
'y-line': {
|
|
1874
|
+
type: 'linear',
|
|
1875
|
+
position: 'right',
|
|
1876
|
+
stacked: false,
|
|
1877
|
+
ticks: {
|
|
1878
|
+
color: labelColor,
|
|
1879
|
+
font: {
|
|
1880
|
+
family: fontFamily,
|
|
1881
|
+
size: fontSize
|
|
1882
|
+
}
|
|
1883
|
+
},
|
|
1884
|
+
grid: {
|
|
1885
|
+
color: gridColor
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
return _extends({}, base, {
|
|
1833
1892
|
scales: {
|
|
1834
1893
|
x: {
|
|
1835
1894
|
ticks: {
|
|
@@ -1859,7 +1918,7 @@ function ComboChart(_ref) {
|
|
|
1859
1918
|
}
|
|
1860
1919
|
}
|
|
1861
1920
|
});
|
|
1862
|
-
}, [title, showDataLabels, theme, fontFamily, fontSize, labelColor, gridColor, createFluentTooltip]);
|
|
1921
|
+
}, [title, showDataLabels, theme, fontFamily, fontSize, labelColor, gridColor, createFluentTooltip, getInstantInteractionAnimations, axesMode]);
|
|
1863
1922
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
1864
1923
|
className: styles.chartWithLegend
|
|
1865
1924
|
}, React__default.createElement("div", {
|
|
@@ -3370,6 +3429,7 @@ var chartProps = function chartProps(chart) {
|
|
|
3370
3429
|
};
|
|
3371
3430
|
};
|
|
3372
3431
|
var getChartComponent = function getChartComponent(chart, theme) {
|
|
3432
|
+
var _chart$axesMode;
|
|
3373
3433
|
var type = chart.type;
|
|
3374
3434
|
var fuiTheme = theme != null ? theme : webLightTheme;
|
|
3375
3435
|
switch (type) {
|
|
@@ -3403,6 +3463,8 @@ var getChartComponent = function getChartComponent(chart, theme) {
|
|
|
3403
3463
|
case 'multiple-axes':
|
|
3404
3464
|
return React__default.createElement(ComboChart, Object.assign({}, chartProps(chart), {
|
|
3405
3465
|
theme: fuiTheme,
|
|
3466
|
+
// allow the originating chart descriptor to opt into dual axes
|
|
3467
|
+
axesMode: (_chart$axesMode = chart.axesMode) != null ? _chart$axesMode : 'dual',
|
|
3406
3468
|
data: chart.data.map(function (series) {
|
|
3407
3469
|
var _series$type;
|
|
3408
3470
|
return {
|