@sproutsocial/seeds-react-data-viz 0.4.0 → 0.4.1
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/esm/index.js +78 -39
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +78 -39
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -283,6 +283,10 @@ type TypeDonutChartProps = Readonly<{
|
|
|
283
283
|
hideLegend?: boolean;
|
|
284
284
|
numberFormat?: TypeChartNumberFormat;
|
|
285
285
|
tooltip?: ({ color, name, percent, value, }: TypeDonutChartTooltipProps) => ReactNode;
|
|
286
|
+
onClick?: ({ x }: Readonly<{
|
|
287
|
+
x: string;
|
|
288
|
+
}>) => void;
|
|
289
|
+
tooltipClickLabel?: ReactNode;
|
|
286
290
|
}>;
|
|
287
291
|
declare const DonutChart: react.NamedExoticComponent<Readonly<{
|
|
288
292
|
data: ReadonlyArray<Readonly<{
|
|
@@ -298,6 +302,10 @@ declare const DonutChart: react.NamedExoticComponent<Readonly<{
|
|
|
298
302
|
hideLegend?: boolean;
|
|
299
303
|
numberFormat?: TypeChartNumberFormat;
|
|
300
304
|
tooltip?: ({ color, name, percent, value, }: TypeDonutChartTooltipProps) => ReactNode;
|
|
305
|
+
onClick?: ({ x }: Readonly<{
|
|
306
|
+
x: string;
|
|
307
|
+
}>) => void;
|
|
308
|
+
tooltipClickLabel?: ReactNode;
|
|
301
309
|
}>>;
|
|
302
310
|
|
|
303
311
|
type TypeDonutChartLegendTableProps = Readonly<{
|
|
@@ -499,6 +507,7 @@ declare const areaChartStyles: styled_components.FlattenInterpolation<styled_com
|
|
|
499
507
|
}>, any>>;
|
|
500
508
|
declare const donutChartStyles: styled_components.FlattenInterpolation<styled_components.ThemedStyledProps<Readonly<{
|
|
501
509
|
$colors: ReadonlyArray<TypeChartStyleColor>;
|
|
510
|
+
$hasOnClick: TypeChartStyleHasOnClick;
|
|
502
511
|
}>, any>>;
|
|
503
512
|
|
|
504
513
|
export { AreaChart, ChartLegend, ChartLegendLabel, ChartTable, ChartTooltip, ChartTooltipFooter, ChartTooltipHeader, ChartTooltipPortal, ChartTooltipTable, ChartTooltipTitle, ColorBox, DONUT_CHART_HALO_SIZE, DONUT_CHART_HEIGHT, DONUT_CHART_WIDTH, DatavizColorBox, DonutChart, DonutChartLegendTable, type ExtendedAxisLabelsFormatterContextObject, type ExtendedTimeTicksInfoObject, GlobalChartStyleOverrides, LineChart, NetworkColorBox, TIME_SERIES_CHART_HEIGHT, type TypeAreaChartProps, type TypeChartDataPoint, type TypeChartDataStyles, type TypeChartLegendLabelProps, type TypeChartLegendProps, type TypeChartNumberFormat, type TypeChartStyleColor, type TypeChartStyleHasOnClick, type TypeChartStylePattern, type TypeChartTableProps, type TypeChartTimeFormat, type TypeChartTooltipDateFormatter, type TypeChartTooltipProps, type TypeChartTooltipTableProps, type TypeChartXAnnotations, type TypeChartXAnnotationsDetails, type TypeChartYAxisLabelFormatter, type TypeColorBoxProps, type TypeDatavizColorBox, type TypeDatavizColorBoxProps, type TypeDonutChartLegendTableProps, type TypeDonutChartProps, type TypeDonutChartTooltipProps, type TypeExtendedChart, type TypeLegendLabel, type TypeLineChartProps, type TypeSeriesType, type TypeVerticalBarChartProps, VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT, areaChartOptions, areaChartStyles, baseChartOptions, baseChartStyles, columnChartOptions, donutChartOptions, donutChartStyles, generateChartTooltipPortalId, getDatavizColor, getDatavizColorWithAlpha, getDatavizOpacity, getStorybookCategoricalData, getStorybookSparseTimelineData, isCategoricalHourData, isHourlyTimeData, lineChartOptions, lineChartStyles, timeSeriesChartOptions, timeSeriesChartStyles, transformDataToSeries, transformTimeSeriesTooltipData, xAxisLabelFormatter, yAxisLabelFormatter };
|
package/dist/index.d.ts
CHANGED
|
@@ -283,6 +283,10 @@ type TypeDonutChartProps = Readonly<{
|
|
|
283
283
|
hideLegend?: boolean;
|
|
284
284
|
numberFormat?: TypeChartNumberFormat;
|
|
285
285
|
tooltip?: ({ color, name, percent, value, }: TypeDonutChartTooltipProps) => ReactNode;
|
|
286
|
+
onClick?: ({ x }: Readonly<{
|
|
287
|
+
x: string;
|
|
288
|
+
}>) => void;
|
|
289
|
+
tooltipClickLabel?: ReactNode;
|
|
286
290
|
}>;
|
|
287
291
|
declare const DonutChart: react.NamedExoticComponent<Readonly<{
|
|
288
292
|
data: ReadonlyArray<Readonly<{
|
|
@@ -298,6 +302,10 @@ declare const DonutChart: react.NamedExoticComponent<Readonly<{
|
|
|
298
302
|
hideLegend?: boolean;
|
|
299
303
|
numberFormat?: TypeChartNumberFormat;
|
|
300
304
|
tooltip?: ({ color, name, percent, value, }: TypeDonutChartTooltipProps) => ReactNode;
|
|
305
|
+
onClick?: ({ x }: Readonly<{
|
|
306
|
+
x: string;
|
|
307
|
+
}>) => void;
|
|
308
|
+
tooltipClickLabel?: ReactNode;
|
|
301
309
|
}>>;
|
|
302
310
|
|
|
303
311
|
type TypeDonutChartLegendTableProps = Readonly<{
|
|
@@ -499,6 +507,7 @@ declare const areaChartStyles: styled_components.FlattenInterpolation<styled_com
|
|
|
499
507
|
}>, any>>;
|
|
500
508
|
declare const donutChartStyles: styled_components.FlattenInterpolation<styled_components.ThemedStyledProps<Readonly<{
|
|
501
509
|
$colors: ReadonlyArray<TypeChartStyleColor>;
|
|
510
|
+
$hasOnClick: TypeChartStyleHasOnClick;
|
|
502
511
|
}>, any>>;
|
|
503
512
|
|
|
504
513
|
export { AreaChart, ChartLegend, ChartLegendLabel, ChartTable, ChartTooltip, ChartTooltipFooter, ChartTooltipHeader, ChartTooltipPortal, ChartTooltipTable, ChartTooltipTitle, ColorBox, DONUT_CHART_HALO_SIZE, DONUT_CHART_HEIGHT, DONUT_CHART_WIDTH, DatavizColorBox, DonutChart, DonutChartLegendTable, type ExtendedAxisLabelsFormatterContextObject, type ExtendedTimeTicksInfoObject, GlobalChartStyleOverrides, LineChart, NetworkColorBox, TIME_SERIES_CHART_HEIGHT, type TypeAreaChartProps, type TypeChartDataPoint, type TypeChartDataStyles, type TypeChartLegendLabelProps, type TypeChartLegendProps, type TypeChartNumberFormat, type TypeChartStyleColor, type TypeChartStyleHasOnClick, type TypeChartStylePattern, type TypeChartTableProps, type TypeChartTimeFormat, type TypeChartTooltipDateFormatter, type TypeChartTooltipProps, type TypeChartTooltipTableProps, type TypeChartXAnnotations, type TypeChartXAnnotationsDetails, type TypeChartYAxisLabelFormatter, type TypeColorBoxProps, type TypeDatavizColorBox, type TypeDatavizColorBoxProps, type TypeDonutChartLegendTableProps, type TypeDonutChartProps, type TypeDonutChartTooltipProps, type TypeExtendedChart, type TypeLegendLabel, type TypeLineChartProps, type TypeSeriesType, type TypeVerticalBarChartProps, VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT, areaChartOptions, areaChartStyles, baseChartOptions, baseChartStyles, columnChartOptions, donutChartOptions, donutChartStyles, generateChartTooltipPortalId, getDatavizColor, getDatavizColorWithAlpha, getDatavizOpacity, getStorybookCategoricalData, getStorybookSparseTimelineData, isCategoricalHourData, isHourlyTimeData, lineChartOptions, lineChartStyles, timeSeriesChartOptions, timeSeriesChartStyles, transformDataToSeries, transformTimeSeriesTooltipData, xAxisLabelFormatter, yAxisLabelFormatter };
|
package/dist/index.js
CHANGED
|
@@ -1553,6 +1553,19 @@ var donutChartStyles = import_styled_components7.css`
|
|
|
1553
1553
|
.highcharts-point-hover {
|
|
1554
1554
|
fill-opacity: none;
|
|
1555
1555
|
}
|
|
1556
|
+
|
|
1557
|
+
// apply cursor pointer when click functionality is turned on
|
|
1558
|
+
${({ $hasOnClick }) => $hasOnClick && `
|
|
1559
|
+
.highcharts-series,
|
|
1560
|
+
.highcharts-point {
|
|
1561
|
+
cursor: pointer;
|
|
1562
|
+
}
|
|
1563
|
+
.highcharts-plot-background,
|
|
1564
|
+
.highcharts-crosshair,
|
|
1565
|
+
.highcharts-grid-line {
|
|
1566
|
+
fill: transparent;
|
|
1567
|
+
cursor: pointer;
|
|
1568
|
+
}`}
|
|
1556
1569
|
`;
|
|
1557
1570
|
|
|
1558
1571
|
// src/components/AreaChart/AreaChart.tsx
|
|
@@ -1695,6 +1708,7 @@ var DonutChartLegend = (0, import_react17.memo)(
|
|
|
1695
1708
|
var import_react18 = require("react");
|
|
1696
1709
|
var import_seeds_react_box10 = require("@sproutsocial/seeds-react-box");
|
|
1697
1710
|
var import_seeds_react_duration3 = require("@sproutsocial/seeds-react-duration");
|
|
1711
|
+
var import_seeds_react_icon2 = require("@sproutsocial/seeds-react-icon");
|
|
1698
1712
|
var import_seeds_react_numeral3 = require("@sproutsocial/seeds-react-numeral");
|
|
1699
1713
|
var import_seeds_react_text5 = require("@sproutsocial/seeds-react-text");
|
|
1700
1714
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
@@ -1708,7 +1722,9 @@ var DonutChartTooltip = (0, import_react18.memo)(
|
|
|
1708
1722
|
value,
|
|
1709
1723
|
currency,
|
|
1710
1724
|
icon,
|
|
1711
|
-
numberFormat
|
|
1725
|
+
numberFormat,
|
|
1726
|
+
onClick,
|
|
1727
|
+
tooltipClickLabel
|
|
1712
1728
|
}) {
|
|
1713
1729
|
const rows = [
|
|
1714
1730
|
{
|
|
@@ -1743,7 +1759,13 @@ var DonutChartTooltip = (0, import_react18.memo)(
|
|
|
1743
1759
|
]
|
|
1744
1760
|
}
|
|
1745
1761
|
];
|
|
1746
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.
|
|
1762
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ChartTooltip, { children: [
|
|
1763
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChartTooltipTable, { rows }),
|
|
1764
|
+
onClick && tooltipClickLabel ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChartTooltipFooter, { children: typeof tooltipClickLabel === "string" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_seeds_react_box10.Box, { display: "flex", alignItems: "center", gap: 300, children: [
|
|
1765
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_seeds_react_icon2.Icon, { name: "hand-pointer-clicking-outline", color: "icon.base" }),
|
|
1766
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_seeds_react_text5.Text, { color: "text.subtext", fontSize: 200, children: tooltipClickLabel })
|
|
1767
|
+
] }) : tooltipClickLabel }) : null
|
|
1768
|
+
] });
|
|
1747
1769
|
}
|
|
1748
1770
|
);
|
|
1749
1771
|
|
|
@@ -1784,7 +1806,9 @@ var DonutChartWithData = (0, import_react19.memo)(
|
|
|
1784
1806
|
disableTooltips = false,
|
|
1785
1807
|
hideLegend = false,
|
|
1786
1808
|
numberFormat = "decimal",
|
|
1787
|
-
tooltip
|
|
1809
|
+
tooltip,
|
|
1810
|
+
onClick,
|
|
1811
|
+
tooltipClickLabel
|
|
1788
1812
|
}) {
|
|
1789
1813
|
const [options, setOptions] = (0, import_react19.useState)(donutChartOptions);
|
|
1790
1814
|
const [chart, setChart] = (0, import_react19.useState)(null);
|
|
@@ -1825,7 +1849,12 @@ var DonutChartWithData = (0, import_react19.memo)(
|
|
|
1825
1849
|
return {
|
|
1826
1850
|
name: item.name,
|
|
1827
1851
|
y: item.value,
|
|
1828
|
-
colorIndex: index
|
|
1852
|
+
colorIndex: index,
|
|
1853
|
+
events: onClick ? {
|
|
1854
|
+
click: function() {
|
|
1855
|
+
onClick({ x: item.name });
|
|
1856
|
+
}
|
|
1857
|
+
} : void 0
|
|
1829
1858
|
};
|
|
1830
1859
|
})
|
|
1831
1860
|
}
|
|
@@ -1840,40 +1869,50 @@ var DonutChartWithData = (0, import_react19.memo)(
|
|
|
1840
1869
|
);
|
|
1841
1870
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
1842
1871
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(GlobalChartStyleOverrides, {}),
|
|
1843
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
icon,
|
|
1864
|
-
name,
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1872
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1873
|
+
StyledBox4,
|
|
1874
|
+
{
|
|
1875
|
+
$colors: colors,
|
|
1876
|
+
$hasOnClick: Boolean(onClick),
|
|
1877
|
+
bg: "container.background.base",
|
|
1878
|
+
children: [
|
|
1879
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1880
|
+
import_highcharts_react_official2.HighchartsReact,
|
|
1881
|
+
{
|
|
1882
|
+
highcharts: import_highcharts4.default,
|
|
1883
|
+
options,
|
|
1884
|
+
callback
|
|
1885
|
+
}
|
|
1886
|
+
),
|
|
1887
|
+
chart && !disableTooltips ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1888
|
+
ChartTooltipPortal,
|
|
1889
|
+
{
|
|
1890
|
+
chart,
|
|
1891
|
+
renderContent: (context) => {
|
|
1892
|
+
const { color, icon, name, percent, value } = transformDonutChartTooltipData({ context, data });
|
|
1893
|
+
return tooltip ? tooltip({ color, icon, name, percent, value }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1894
|
+
DonutChartTooltip,
|
|
1895
|
+
{
|
|
1896
|
+
color,
|
|
1897
|
+
currency,
|
|
1898
|
+
icon,
|
|
1899
|
+
name,
|
|
1900
|
+
numberFormat,
|
|
1901
|
+
numberLocale,
|
|
1902
|
+
percent,
|
|
1903
|
+
textLocale,
|
|
1904
|
+
value,
|
|
1905
|
+
onClick,
|
|
1906
|
+
tooltipClickLabel
|
|
1907
|
+
}
|
|
1908
|
+
);
|
|
1870
1909
|
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1910
|
+
}
|
|
1911
|
+
) : null,
|
|
1912
|
+
hideLegend ? null : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_seeds_react_box11.Box, { mt: 350, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DonutChartLegend, { data }) })
|
|
1913
|
+
]
|
|
1914
|
+
}
|
|
1915
|
+
)
|
|
1877
1916
|
] });
|
|
1878
1917
|
}
|
|
1879
1918
|
);
|
|
@@ -1998,7 +2037,7 @@ var LineChartLegend = (0, import_react21.memo)(
|
|
|
1998
2037
|
var import_react22 = require("react");
|
|
1999
2038
|
var import_seeds_react_box13 = require("@sproutsocial/seeds-react-box");
|
|
2000
2039
|
var import_seeds_react_duration5 = require("@sproutsocial/seeds-react-duration");
|
|
2001
|
-
var
|
|
2040
|
+
var import_seeds_react_icon3 = require("@sproutsocial/seeds-react-icon");
|
|
2002
2041
|
var import_seeds_react_numeral5 = require("@sproutsocial/seeds-react-numeral");
|
|
2003
2042
|
var import_seeds_react_text7 = require("@sproutsocial/seeds-react-text");
|
|
2004
2043
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
@@ -2044,7 +2083,7 @@ var LineChartTooltip = (0, import_react22.memo)(
|
|
|
2044
2083
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ChartTooltipTitle, { children: tooltipDateFormatter({ x }) }),
|
|
2045
2084
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ChartTooltipTable, { rows }),
|
|
2046
2085
|
onClick && tooltipClickLabel ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ChartTooltipFooter, { children: typeof tooltipClickLabel === "string" ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_seeds_react_box13.Box, { display: "flex", alignItems: "center", gap: 300, children: [
|
|
2047
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2086
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_seeds_react_icon3.Icon, { name: "hand-pointer-clicking-outline", color: "icon.base" }),
|
|
2048
2087
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_seeds_react_text7.Text, { color: "text.subtext", fontSize: 200, children: tooltipClickLabel })
|
|
2049
2088
|
] }) : tooltipClickLabel }) : null
|
|
2050
2089
|
] });
|