@spscommerce/ds-react-charts 4.33.0 → 4.34.2-ie

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.
Files changed (31) hide show
  1. package/dist/out-tsc/bar/SpsBarChart.d.ts +23 -0
  2. package/dist/out-tsc/bar/SpsBarChart.examples.d.ts +2 -0
  3. package/dist/out-tsc/bar/SpsBarChart.examples.js +49 -0
  4. package/dist/out-tsc/bar/SpsBarChart.examples.js.map +1 -0
  5. package/dist/out-tsc/bar/SpsBarChart.js +137 -0
  6. package/dist/out-tsc/bar/SpsBarChart.js.map +1 -0
  7. package/dist/out-tsc/bar/SpsHorizontalBarChart.d.ts +24 -0
  8. package/dist/out-tsc/bar/SpsHorizontalBarChart.js +144 -0
  9. package/dist/out-tsc/bar/SpsHorizontalBarChart.js.map +1 -0
  10. package/dist/out-tsc/index.d.ts +6 -0
  11. package/dist/out-tsc/index.js +7 -0
  12. package/dist/out-tsc/index.js.map +1 -0
  13. package/dist/out-tsc/manifest.d.ts +2 -0
  14. package/dist/out-tsc/manifest.js +21 -0
  15. package/dist/out-tsc/manifest.js.map +1 -0
  16. package/dist/out-tsc/prop-types.d.ts +23 -0
  17. package/dist/out-tsc/prop-types.js +26 -0
  18. package/dist/out-tsc/prop-types.js.map +1 -0
  19. package/dist/out-tsc/setup-jest.d.ts +1 -0
  20. package/dist/out-tsc/setup-jest.js +3 -0
  21. package/dist/out-tsc/setup-jest.js.map +1 -0
  22. package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.d.ts +18 -0
  23. package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.examples.d.ts +2 -0
  24. package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.examples.js +21 -0
  25. package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.examples.js.map +1 -0
  26. package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.js +148 -0
  27. package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.js.map +1 -0
  28. package/lib/index.cjs.js +136 -17
  29. package/lib/index.es.js +377 -407
  30. package/package.json +11 -10
  31. package/vite.config.js +1 -1
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import type { ChartDataObject, ChartAxis } from "@spscommerce/ds-shared";
3
+ import * as PropTypes from "../prop-types";
4
+ declare const propTypes: {
5
+ barFillColor1: PropTypes.Requireable<string>;
6
+ barFillColor2: PropTypes.Requireable<string>;
7
+ barFillColorHover: PropTypes.Requireable<string>;
8
+ chartData: PropTypes.Requireable<ChartDataObject[]>;
9
+ chartHeight: PropTypes.Requireable<number>;
10
+ chartWidth: PropTypes.Requireable<number>;
11
+ barSize: PropTypes.Requireable<number>;
12
+ yAxis: PropTypes.Requireable<ChartAxis>;
13
+ xAxis: PropTypes.Requireable<ChartAxis>;
14
+ yMaxValue: PropTypes.Requireable<number>;
15
+ yTickFormat: PropTypes.Requireable<(i: number) => string>;
16
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
17
+ className: PropTypes.Requireable<string>;
18
+ "data-testid": PropTypes.Requireable<string>;
19
+ unsafelyReplaceClassName: PropTypes.Requireable<string>;
20
+ };
21
+ export declare type SpsBarChartProps = PropTypes.InferTS<typeof propTypes, HTMLDivElement>;
22
+ export declare function SpsBarChart(props: SpsBarChartProps): JSX.Element;
23
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { DSReactExamples } from "@spscommerce/ds-shared";
2
+ export declare const SpsBarChartExamples: DSReactExamples;
@@ -0,0 +1,49 @@
1
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
+ return cooked;
4
+ };
5
+ import * as React from "react";
6
+ import { code } from "@spscommerce/utils";
7
+ export var SpsBarChartExamples = {
8
+ general: {
9
+ label: "General Usage",
10
+ description: function (_a) {
11
+ var NavigateTo = _a.NavigateTo, Link = _a.Link;
12
+ return (React.createElement(React.Fragment, null,
13
+ React.createElement("p", null, "Use Bar Charts to visualize the comparison of a dataset across multiple categories or subjects. When using bar charts, the dataset should attempt to provide a clear answer to a clear question (i.e. avoid comparing multiple or unrelated datasets in a single chart)."),
14
+ React.createElement("p", null,
15
+ "Bar Charts should not be used when the visualization of the data is too complex or the number of categories too numerous to be easily understood at a glance. In these cases consider the use of more general lists of content such as a",
16
+ " ",
17
+ React.createElement(NavigateTo, { to: "Tables" }, "Table"),
18
+ "."),
19
+ React.createElement("h5", null, "Color"),
20
+ React.createElement("p", null,
21
+ "The number of colors used should be directly related to the number of comparisons being made. When comparing categories across a single data set, only one color should be used. When comparing multiple categories across multiple series of data, use the appropriate number of colors to the number of categories. For more details on color usage visit the",
22
+ " ",
23
+ React.createElement(Link, { to: "/style-and-layout/colors" }, "Colors"),
24
+ " section."),
25
+ React.createElement("h5", null, "Interaction"),
26
+ React.createElement("p", null, "Charts should include interactivity on hover to give users insight to specifics of the data. Tooltips can be used to display expanded definitions or additional related data points for the selected category.")));
27
+ },
28
+ },
29
+ horizontal: {
30
+ label: "Horizontal Bar Chart",
31
+ description: code(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <p>In Horizontal Bar Charts categories are listed vertically on the Y-axis and with data points are plotted horizontally on the X-axis.</p>\n "], ["\n <p>In Horizontal Bar Charts categories are listed vertically on the Y-axis and with data points are plotted horizontally on the X-axis.</p>\n "]))),
32
+ examples: {
33
+ vertical: {
34
+ react: code(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n function DemoComponent() {\n const data = [\n { value: 69, label: \"Aktie Sports\" },\n { value: 69, label: \"Dicks Sporting Goods\" },\n { value: 64, label: \"FGL Sports\" },\n { value: 62, label: \"Foot Asylum\" },\n { value: 55, label: \"Hervis\" },\n { value: 51, label: \"Lovell Rugby\" },\n { value: 48, label: \"Modells Sporting Goods\" },\n { value: 44, label: \"Perry Sport\" },\n { value: 44, label: \"Sportman Warhouse Australia\" },\n { value: 44, label: \"Perry Sport 2\" },\n ]\n\n xTickFormat = (i) => `${i}${i !== 0 ? \"%\" : \"\"}`\n\n return (\n <SpsHorizontalBarChart\n chartData={data}\n chartHeight={523}\n chartWidth={838}\n barFillColor1 = \"#32BE6F\"\n barFillColor2 = \"#32BE6F80\"\n barFillColorHover = \"#289858\"\n yAxis={{\n tickValues: 'label',\n }}\n xAxis={{\n tickValues: 'value',\n tickCount: '10'\n }}\n marginLeft={135}\n xMaxValue={100}\n barSize={20}\n xTickFormat={xTickFormat}\n />\n )\n }\n "], ["\n function DemoComponent() {\n const data = [\n { value: 69, label: \"Aktie Sports\" },\n { value: 69, label: \"Dicks Sporting Goods\" },\n { value: 64, label: \"FGL Sports\" },\n { value: 62, label: \"Foot Asylum\" },\n { value: 55, label: \"Hervis\" },\n { value: 51, label: \"Lovell Rugby\" },\n { value: 48, label: \"Modells Sporting Goods\" },\n { value: 44, label: \"Perry Sport\" },\n { value: 44, label: \"Sportman Warhouse Australia\" },\n { value: 44, label: \"Perry Sport 2\" },\n ]\n\n xTickFormat = (i) => \\`\\${i}\\${i !== 0 ? \"%\" : \"\"}\\`\n\n return (\n <SpsHorizontalBarChart\n chartData={data}\n chartHeight={523}\n chartWidth={838}\n barFillColor1 = \"#32BE6F\"\n barFillColor2 = \"#32BE6F80\"\n barFillColorHover = \"#289858\"\n yAxis={{\n tickValues: 'label',\n }}\n xAxis={{\n tickValues: 'value',\n tickCount: '10'\n }}\n marginLeft={135}\n xMaxValue={100}\n barSize={20}\n xTickFormat={xTickFormat}\n />\n )\n }\n "]))),
35
+ },
36
+ },
37
+ },
38
+ vertical: {
39
+ label: "Vertical Bar Chart",
40
+ description: code(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n <p>In Vertical Bar Charts data points are plotted vertically on the Y-axis and with categories being listed horizontally on the X-axis.</p>\n <p>If the categories become too crowded along the X-axis, opt for a Horizontal Bar Chart instead.</p>\n "], ["\n <p>In Vertical Bar Charts data points are plotted vertically on the Y-axis and with categories being listed horizontally on the X-axis.</p>\n <p>If the categories become too crowded along the X-axis, opt for a Horizontal Bar Chart instead.</p>\n "]))),
41
+ examples: {
42
+ vertical: {
43
+ react: code(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n function DemoComponent() {\n const data = [\n { value: 112, label: \"Aktie Sports\" },\n { value: 100, label: \"Dicks Sporting Goods\" },\n { value: 90, label: \"FGL Sports\" },\n { value: 82, label: \"Foot Asylum\" },\n { value: 76, label: \"Hervis\" },\n { value: 64, label: \"Lovell Rugby\" },\n { value: 64, label: \"Modells Sporting Goods\" },\n ]\n\n return (\n <SpsBarChart\n chartData={data}\n chartHeight={364}\n chartWidth={838}\n barFillColor1 = \"#9B4B87\"\n barFillColor2 = \"#9B4B8780\"\n barFillColorHover = \"#7C3C6C\"\n yAxis={{\n tickValues: 'value',\n tickCount: '5',\n }}\n xAxis={{\n tickValues: 'label',\n }}\n yMaxValue={125}\n barSize={45}\n />\n )\n }\n "], ["\n function DemoComponent() {\n const data = [\n { value: 112, label: \"Aktie Sports\" },\n { value: 100, label: \"Dicks Sporting Goods\" },\n { value: 90, label: \"FGL Sports\" },\n { value: 82, label: \"Foot Asylum\" },\n { value: 76, label: \"Hervis\" },\n { value: 64, label: \"Lovell Rugby\" },\n { value: 64, label: \"Modells Sporting Goods\" },\n ]\n\n return (\n <SpsBarChart\n chartData={data}\n chartHeight={364}\n chartWidth={838}\n barFillColor1 = \"#9B4B87\"\n barFillColor2 = \"#9B4B8780\"\n barFillColorHover = \"#7C3C6C\"\n yAxis={{\n tickValues: 'value',\n tickCount: '5',\n }}\n xAxis={{\n tickValues: 'label',\n }}\n yMaxValue={125}\n barSize={45}\n />\n )\n }\n "]))),
44
+ },
45
+ },
46
+ },
47
+ };
48
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
49
+ //# sourceMappingURL=SpsBarChart.examples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpsBarChart.examples.js","sourceRoot":"","sources":["../../../src/bar/SpsBarChart.examples.tsx"],"names":[],"mappings":";;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,MAAM,CAAC,IAAM,mBAAmB,GAAoB;IAClD,OAAO,EAAE;QACP,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,UAAC,EAAoB;gBAAlB,UAAU,gBAAA,EAAE,IAAI,UAAA;YAAO,OAAA,CACrC;gBACE,0SAKI;gBACJ;;oBAG0E,GAAG;oBAC3E,oBAAC,UAAU,IAAC,EAAE,EAAC,QAAQ,YAAmB;wBACxC;gBACJ,wCAAc;gBACd;;oBAK4C,GAAG;oBAC7C,oBAAC,IAAI,IAAC,EAAE,EAAC,0BAA0B,aAAc;gCAC/C;gBACJ,8CAAoB;gBACpB,gPAII,CACH,CACJ;QA9BsC,CA8BtC;KACF;IACD,UAAU,EAAE;QACV,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,IAAI,wOAAA,qKAEZ,IAAA;QACL,QAAQ,EAAE;YACR,QAAQ,EAAE;gBACR,KAAK,EAAE,IAAI,m/DAAA,w7DAuCF,IAAA;aACV;SACF;KACF;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EAAE,IAAI,2VAAA,wRAGZ,IAAA;QACL,QAAQ,EAAE;YACR,QAAQ,EAAE;gBACR,KAAK,EAAE,IAAI,gjDAAA,6+CAgCF,IAAA;aACV;SACF;KACF;CACF,CAAC"}
@@ -0,0 +1,137 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __read = (this && this.__read) || function (o, n) {
13
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14
+ if (!m) return o;
15
+ var i = m.call(o), r, ar = [], e;
16
+ try {
17
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
+ }
19
+ catch (error) { e = { error: error }; }
20
+ finally {
21
+ try {
22
+ if (r && !r.done && (m = i["return"])) m.call(i);
23
+ }
24
+ finally { if (e) throw e.error; }
25
+ }
26
+ return ar;
27
+ };
28
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
29
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
+ if (ar || !(i in from)) {
31
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
32
+ ar[i] = from[i];
33
+ }
34
+ }
35
+ return to.concat(ar || Array.prototype.slice.call(from));
36
+ };
37
+ import * as React from "react";
38
+ import { Group } from "@visx/group";
39
+ import { BarRounded } from "@visx/shape";
40
+ import { scaleLinear, scaleBand } from "@visx/scale";
41
+ import { LinearGradient } from "@visx/gradient";
42
+ import { AxisBottom, AxisLeft } from "@visx/axis";
43
+ import { GridRows } from "@visx/grid";
44
+ import * as DSColors from "@spscommerce/ds-colors";
45
+ import { SpsTooltip } from "@spscommerce/ds-react";
46
+ import nanoid from "nanoid";
47
+ import * as PropTypes from "../prop-types";
48
+ var propsDoc = {
49
+ barFillColor1: "string",
50
+ barFillColor2: "string",
51
+ barFillColorHover: "string",
52
+ chartData: "ChartDataObject[]",
53
+ chartHeight: "number",
54
+ chartWidth: "number",
55
+ barSize: "number",
56
+ yAxis: "ChartAxis",
57
+ xAxis: "ChartAxis",
58
+ yMaxValue: "number",
59
+ yTickFormat: "(i: number) => string",
60
+ };
61
+ var propTypes = __assign(__assign({}, PropTypes.spsGlobalPropTypes), { barFillColor1: PropTypes.string, barFillColor2: PropTypes.string, barFillColorHover: PropTypes.string, chartData: PropTypes.arrayOf(PropTypes.impl()), chartHeight: PropTypes.number, chartWidth: PropTypes.number, barSize: PropTypes.number, yAxis: PropTypes.impl(), xAxis: PropTypes.impl(), yMaxValue: PropTypes.number, yTickFormat: PropTypes.fun() });
62
+ export function SpsBarChart(props) {
63
+ var _a = props.barFillColor1, barFillColor1 = _a === void 0 ? DSColors.colors.blue200 : _a, _b = props.barFillColor2, barFillColor2 = _b === void 0 ? "#007DB880" : _b, _c = props.barFillColorHover, barFillColorHover = _c === void 0 ? DSColors.colors.blue300 : _c, chartData = props.chartData, chartHeight = props.chartHeight, chartWidth = props.chartWidth, barSize = props.barSize, _d = props.yAxis, yAxis = _d === void 0 ? {
64
+ tickValues: "value",
65
+ tickCount: 3,
66
+ } : _d, _e = props.xAxis, xAxis = _e === void 0 ? {
67
+ tickValues: "label",
68
+ } : _e, yMaxValue = props.yMaxValue, yTickFormat = props.yTickFormat;
69
+ var margin = {
70
+ top: 30,
71
+ bottom: 70,
72
+ left: 50,
73
+ right: 30,
74
+ };
75
+ var xMax = chartWidth - margin.left - margin.right;
76
+ var yMax = chartHeight - margin.top - margin.bottom;
77
+ var x = function (d) { return d[xAxis.tickValues]; };
78
+ var y = function (d) { return d[yAxis.tickValues]; };
79
+ var xScale = scaleBand({
80
+ range: [0, xMax],
81
+ round: true,
82
+ domain: chartData.map(x),
83
+ padding: 0.4,
84
+ });
85
+ var yScale = scaleLinear({
86
+ range: [yMax, 0],
87
+ round: true,
88
+ domain: [0, yMaxValue || Math.max.apply(Math, __spreadArray([], __read(chartData.map(y)), false))],
89
+ });
90
+ var compose = function (scale, accessor) { return function (data) { return scale(accessor(data)); }; };
91
+ var xPoint = compose(xScale, x);
92
+ var yPoint = compose(yScale, y);
93
+ var colorGradientID = nanoid();
94
+ return (React.createElement("svg", { width: chartWidth, height: chartHeight, className: "sps-chart-wrapper" },
95
+ React.createElement(GridRows, { scale: yScale, left: margin.left, width: xMax, numTicks: yAxis.tickCount, stroke: DSColors.colors.gray400, strokeOpacity: 0.2 }),
96
+ React.createElement(LinearGradient, { id: colorGradientID, from: barFillColor1, to: barFillColor2 }),
97
+ chartData.map(function (element, idx) {
98
+ var barHeight = yMax - yPoint(element);
99
+ var barID = nanoid();
100
+ return (React.createElement(Group, { key: idx },
101
+ React.createElement(BarRounded, { id: barID, top: true, radius: 4,
102
+ /*
103
+ * When we have barSize defined we need to recalculate the x position
104
+ * so the label is centered in the middle of the bar
105
+ */
106
+ x: xPoint(element) + margin.left
107
+ + (barSize ? ((xScale.bandwidth() - barSize) / 2) : 0), y: yMax - barHeight, height: barHeight, width: barSize || xScale.bandwidth(), fill: "url(#" + colorGradientID + ")", onMouseEnter: function (e) {
108
+ var targetElement = e.target;
109
+ targetElement.style.fill = barFillColorHover;
110
+ }, onMouseLeave: function (e) {
111
+ var targetElement = e.target;
112
+ targetElement.style.fill = null;
113
+ } }),
114
+ React.createElement(AxisLeft, { scale: yScale, left: margin.left, hideTicks: true, numTicks: yAxis.tickCount, tickFormat: yTickFormat || undefined, stroke: DSColors.colors.gray300, tickLabelProps: function () { return ({
115
+ textAnchor: "end",
116
+ fontSize: "12px",
117
+ fill: DSColors.colors.gray400,
118
+ fontWeight: "200",
119
+ }); } }),
120
+ React.createElement(AxisBottom, { top: yMax, scale: xScale, left: margin.left, hideTicks: true, hideAxisLine: true, stroke: DSColors.colors.gray300, tickLabelProps: function () { return ({
121
+ textAnchor: "middle",
122
+ fontSize: "12px",
123
+ fontWeight: "200",
124
+ fill: DSColors.colors.gray400,
125
+ width: xScale.bandwidth() + (xScale.bandwidth() / 2),
126
+ lineHeight: "15px",
127
+ verticalAnchor: "start",
128
+ }); } }),
129
+ React.createElement(SpsTooltip, { for: barID }, element.label)));
130
+ })));
131
+ }
132
+ Object.assign(SpsBarChart, {
133
+ props: propsDoc,
134
+ propTypes: propTypes,
135
+ displayName: "SpsBarChart",
136
+ });
137
+ //# sourceMappingURL=SpsBarChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpsBarChart.js","sourceRoot":"","sources":["../../../src/bar/SpsBarChart.tsx"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,QAAQ,CAAC,MAAM,CAAC,OAAO,EAC/B,cAAc,EAAE,cAAM,OAAA,CAAC;wBACrB,UAAU,EAAE,KAAK;wBACjB,QAAQ,EAAE,MAAM;wBAChB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO;wBAC7B,UAAU,EAAE,KAAK;qBAClB,CAAC,EALoB,CAKpB,GACF;gBACF,oBAAC,UAAU,IACT,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,SAAS,QACT,YAAY,QACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,EAC/B,cAAc,EAAE,cAAM,OAAA,CAAC;wBACrB,UAAU,EAAE,QAAQ;wBACpB,QAAQ,EAAE,MAAM;wBAChB,UAAU,EAAE,KAAK;wBACjB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO;wBAC7B,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;wBACpD,UAAU,EAAE,MAAM;wBAClB,cAAc,EAAE,OAAO;qBACxB,CAAC,EARoB,CAQpB,GACF;gBACF,oBAAC,UAAU,IAAC,GAAG,EAAE,KAAK,IACnB,OAAO,CAAC,KAAK,CACH,CACP,CACT,CAAC;QACJ,CAAC,CAAC,CACE,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;IACzB,KAAK,EAAE,QAAQ;IACf,SAAS,WAAA;IACT,WAAW,EAAE,aAAa;CAC3B,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import type { ChartDataObject, ChartAxis } from "@spscommerce/ds-shared";
3
+ import * as PropTypes from "../prop-types";
4
+ declare const propTypes: {
5
+ barFillColor1: PropTypes.Requireable<string>;
6
+ barFillColor2: PropTypes.Requireable<string>;
7
+ barFillColorHover: PropTypes.Requireable<string>;
8
+ chartData: PropTypes.Requireable<ChartDataObject[]>;
9
+ chartHeight: PropTypes.Requireable<number>;
10
+ chartWidth: PropTypes.Requireable<number>;
11
+ barSize: PropTypes.Requireable<number>;
12
+ yAxis: PropTypes.Requireable<ChartAxis>;
13
+ xAxis: PropTypes.Requireable<ChartAxis>;
14
+ marginLeft: PropTypes.Requireable<number>;
15
+ xMaxValue: PropTypes.Requireable<number>;
16
+ xTickFormat: PropTypes.Requireable<(i: number) => string>;
17
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
18
+ className: PropTypes.Requireable<string>;
19
+ "data-testid": PropTypes.Requireable<string>;
20
+ unsafelyReplaceClassName: PropTypes.Requireable<string>;
21
+ };
22
+ export declare type SpsHorizontalBarChartProps = PropTypes.InferTS<typeof propTypes, HTMLDivElement>;
23
+ export declare function SpsHorizontalBarChart(props: SpsHorizontalBarChartProps): JSX.Element;
24
+ export {};
@@ -0,0 +1,144 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __read = (this && this.__read) || function (o, n) {
13
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14
+ if (!m) return o;
15
+ var i = m.call(o), r, ar = [], e;
16
+ try {
17
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
+ }
19
+ catch (error) { e = { error: error }; }
20
+ finally {
21
+ try {
22
+ if (r && !r.done && (m = i["return"])) m.call(i);
23
+ }
24
+ finally { if (e) throw e.error; }
25
+ }
26
+ return ar;
27
+ };
28
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
29
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
+ if (ar || !(i in from)) {
31
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
32
+ ar[i] = from[i];
33
+ }
34
+ }
35
+ return to.concat(ar || Array.prototype.slice.call(from));
36
+ };
37
+ import * as React from "react";
38
+ import { Group } from "@visx/group";
39
+ import { BarRounded } from "@visx/shape";
40
+ import { scaleLinear, scaleBand } from "@visx/scale";
41
+ import { LinearGradient } from "@visx/gradient";
42
+ import { AxisBottom, AxisLeft } from "@visx/axis";
43
+ import { GridColumns } from "@visx/grid";
44
+ import * as DSColors from "@spscommerce/ds-colors";
45
+ import { SpsTooltip } from "@spscommerce/ds-react";
46
+ import nanoid from "nanoid";
47
+ import * as PropTypes from "../prop-types";
48
+ var propsDoc = {
49
+ barFillColor1: "string",
50
+ barFillColor2: "string",
51
+ barFillColorHover: "string",
52
+ chartData: "ChartDataObject[]",
53
+ chartHeight: "number",
54
+ chartWidth: "number",
55
+ barSize: "number",
56
+ yAxis: "ChartAxis",
57
+ xAxis: "ChartAxis",
58
+ marginLeft: "number",
59
+ xMaxValue: "number",
60
+ xTickFormat: "(i: number) => string",
61
+ };
62
+ var propTypes = __assign(__assign({}, PropTypes.spsGlobalPropTypes), { barFillColor1: PropTypes.string, barFillColor2: PropTypes.string, barFillColorHover: PropTypes.string, chartData: PropTypes.arrayOf(PropTypes.impl()), chartHeight: PropTypes.number, chartWidth: PropTypes.number, barSize: PropTypes.number, yAxis: PropTypes.impl(), xAxis: PropTypes.impl(), marginLeft: PropTypes.number, xMaxValue: PropTypes.number, xTickFormat: PropTypes.fun() });
63
+ export function SpsHorizontalBarChart(props) {
64
+ var _a = props.barFillColor1, barFillColor1 = _a === void 0 ? DSColors.colors.blue200 : _a, _b = props.barFillColor2, barFillColor2 = _b === void 0 ? "#007DB880" : _b, _c = props.barFillColorHover, barFillColorHover = _c === void 0 ? DSColors.colors.blue300 : _c, chartData = props.chartData, chartHeight = props.chartHeight, chartWidth = props.chartWidth, barSize = props.barSize, _d = props.yAxis, yAxis = _d === void 0 ? {
65
+ tickValues: "label",
66
+ } : _d, _e = props.xAxis, xAxis = _e === void 0 ? {
67
+ tickValues: "value",
68
+ tickCount: 3,
69
+ } : _e, _f = props.marginLeft, marginLeft = _f === void 0 ? 30 : _f, xMaxValue = props.xMaxValue, xTickFormat = props.xTickFormat;
70
+ var margin = {
71
+ top: 30,
72
+ bottom: 30,
73
+ left: marginLeft,
74
+ right: 30,
75
+ };
76
+ var xMax = chartWidth - margin.left - margin.right;
77
+ var yMax = chartHeight - margin.top - margin.bottom;
78
+ var x = function (d) { return d[xAxis.tickValues]; };
79
+ var y = function (d) { return d[yAxis.tickValues]; };
80
+ var yScale = scaleBand({
81
+ range: [0, yMax],
82
+ round: true,
83
+ domain: chartData.map(y),
84
+ padding: 0.4,
85
+ });
86
+ var xScale = scaleLinear({
87
+ range: [0, xMax],
88
+ round: true,
89
+ domain: [0, xMaxValue || Math.max.apply(Math, __spreadArray([], __read(chartData.map(x)), false))],
90
+ });
91
+ var compose = function (scale, accessor) { return function (data) { return scale(accessor(data)); }; };
92
+ var xPoint = compose(xScale, x);
93
+ var yPoint = compose(yScale, y);
94
+ var colorGradientID = nanoid();
95
+ var bgColorGradientID = nanoid();
96
+ return (React.createElement("svg", { width: chartWidth, height: chartHeight, className: "sps-chart-wrapper" },
97
+ React.createElement(GridColumns, { scale: xScale, left: margin.left, height: yMax, stroke: DSColors.colors.gray400, strokeOpacity: 0.2 }),
98
+ React.createElement(LinearGradient, { id: bgColorGradientID, from: "#D2D4D580", to: "#D2D4D5", vertical: false }),
99
+ React.createElement(LinearGradient, { id: colorGradientID, from: barFillColor2, to: barFillColor1, vertical: false }),
100
+ chartData.map(function (element, idx) {
101
+ var barWidth = xPoint(element);
102
+ var barID = nanoid();
103
+ return (React.createElement(Group, { key: idx },
104
+ React.createElement("rect", { x: margin.left,
105
+ /*
106
+ * When we have barSize defined we need to recalculate the y position
107
+ * so the label is centered in the middle of the bar
108
+ */
109
+ y: yPoint(element) + (barSize ? ((yScale.bandwidth() - barSize) / 2) : 0), height: barSize || yScale.bandwidth(), width: xMax, fill: "url(#" + bgColorGradientID + ")" }),
110
+ React.createElement(BarRounded, { id: barID, right: true, radius: 4, x: margin.left,
111
+ /*
112
+ * When we have barSize defined we need to recalculate the y position
113
+ * so the label is centered in the middle of the bar
114
+ */
115
+ y: yPoint(element) + (barSize ? ((yScale.bandwidth() - barSize) / 2) : 0), height: barSize || yScale.bandwidth(), width: barWidth, fill: "url(#" + colorGradientID + ")", onMouseEnter: function (e) {
116
+ var targetElement = e.target;
117
+ targetElement.style.fill = barFillColorHover;
118
+ }, onMouseLeave: function (e) {
119
+ var targetElement = e.target;
120
+ targetElement.style.fill = null;
121
+ } }),
122
+ React.createElement(AxisLeft, { scale: yScale, left: margin.left, hideTicks: true, hideAxisLine: true, stroke: DSColors.colors.gray300, tickLabelProps: function () { return ({
123
+ textAnchor: "end",
124
+ fontSize: "12px",
125
+ fill: DSColors.colors.gray400,
126
+ fontWeight: "200",
127
+ width: margin.left,
128
+ verticalAnchor: "middle",
129
+ }); } }),
130
+ React.createElement(AxisBottom, { top: yMax, scale: xScale, left: margin.left, hideTicks: true, numTicks: xAxis.tickCount, tickFormat: xTickFormat || undefined, stroke: DSColors.colors.gray300, tickLabelProps: function () { return ({
131
+ textAnchor: "middle",
132
+ fontSize: "12px",
133
+ fontWeight: "200",
134
+ fill: DSColors.colors.gray400,
135
+ }); } }),
136
+ React.createElement(SpsTooltip, { for: barID }, element.label)));
137
+ })));
138
+ }
139
+ Object.assign(SpsHorizontalBarChart, {
140
+ props: propsDoc,
141
+ propTypes: propTypes,
142
+ displayName: "SpsHorizontalBarChart",
143
+ });
144
+ //# sourceMappingURL=SpsHorizontalBarChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpsHorizontalBarChart.js","sourceRoot":"","sources":["../../../src/bar/SpsHorizontalBarChart.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OA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AAC,KAAK,CACH,CACP,CACT,CAAC;QACJ,CAAC,CAAC,CACE,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE;IACnC,KAAK,EAAE,QAAQ;IACf,SAAS,WAAA;IACT,WAAW,EAAE,uBAAuB;CACrC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./manifest";
2
+ export * from "./bar/SpsBarChart";
3
+ export * from "./bar/SpsHorizontalBarChart";
4
+ export * from "./bar/SpsBarChart.examples";
5
+ export * from "./stackedHorizontalBarChart/SpsStackedHorizontalBarChart";
6
+ export * from "./stackedHorizontalBarChart/SpsStackedHorizontalBarChart.examples";
@@ -0,0 +1,7 @@
1
+ export * from "./manifest";
2
+ export * from "./bar/SpsBarChart";
3
+ export * from "./bar/SpsHorizontalBarChart";
4
+ export * from "./bar/SpsBarChart.examples";
5
+ export * from "./stackedHorizontalBarChart/SpsStackedHorizontalBarChart";
6
+ export * from "./stackedHorizontalBarChart/SpsStackedHorizontalBarChart.examples";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,0DAA0D,CAAC;AACzE,cAAc,mEAAmE,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ComponentManifest } from "@spscommerce/ds-shared";
2
+ export declare const MANIFEST: ComponentManifest;
@@ -0,0 +1,21 @@
1
+ import * as React from "react";
2
+ import { SpsBarChart } from "./bar/SpsBarChart";
3
+ import { SpsBarChartExamples } from "./bar/SpsBarChart.examples";
4
+ import { SpsHorizontalBarChart } from "./bar/SpsHorizontalBarChart";
5
+ import { SpsStackedHorizontalBarChart } from "./stackedHorizontalBarChart/SpsStackedHorizontalBarChart";
6
+ import { SpsStackedHorizontalBarChartExamples } from "./stackedHorizontalBarChart/SpsStackedHorizontalBarChart.examples";
7
+ export var MANIFEST = {
8
+ "Bar Chart": {
9
+ description: function () { return (React.createElement("p", null,
10
+ "Bar Charts are a data visualization used to compare sets of data to more easily analyze questions or identify gaps oriented toward user goals. ",
11
+ React.createElement("br", null),
12
+ "Each chart should focus on answering a single question about the dataset.")); },
13
+ components: [SpsBarChart, SpsHorizontalBarChart],
14
+ examples: SpsBarChartExamples,
15
+ },
16
+ "Stacked Horizontal Bar Chart": {
17
+ components: [SpsStackedHorizontalBarChart],
18
+ examples: SpsStackedHorizontalBarChartExamples,
19
+ },
20
+ };
21
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/manifest.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0DAA0D,CAAC;AACxG,OAAO,EAAE,oCAAoC,EAAE,MAAM,mEAAmE,CAAC;AAEzH,MAAM,CAAC,IAAM,QAAQ,GAAsB;IACzC,WAAW,EAAE;QACX,WAAW,EAAE,cAAM,OAAA,CACjB;;YAEkE,+BAAM;wFAEpE,CACL,EANkB,CAMlB;QACD,UAAU,EAAE,CAAC,WAAW,EAAE,qBAAqB,CAAC;QAChD,QAAQ,EAAE,mBAAmB;KAC9B;IACD,8BAA8B,EAAE;QAC9B,UAAU,EAAE,CAAC,4BAA4B,CAAC;QAC1C,QAAQ,EAAE,oCAAoC;KAC/C;CACF,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { MutableRefObject } from "react";
2
+ import * as PropTypes from "prop-types";
3
+ export declare type Deprecated<T> = PropTypes.Requireable<T>;
4
+ export declare function deprecated<T>(type: PropTypes.Requireable<T>): Deprecated<T>;
5
+ export declare function enumValue<T>(e: any): PropTypes.Requireable<T>;
6
+ export declare function fun<T extends (...args: any[]) => any>(): PropTypes.Requireable<T>;
7
+ export declare function impl<T>(): PropTypes.Requireable<T>;
8
+ export declare function ref<T>(): PropTypes.Requireable<MutableRefObject<T>>;
9
+ export declare type ReactNodeOrRenderFn = PropTypes.ReactNodeLike | (() => PropTypes.ReactNodeLike);
10
+ export declare const nodeOrRenderFn: PropTypes.Requireable<ReactNodeOrRenderFn>;
11
+ export declare type TypeDoc = Record<string, string | {
12
+ type: string;
13
+ required?: boolean;
14
+ deprecated?: boolean;
15
+ }>;
16
+ export declare type InferTS<T, K extends HTMLElement> = PropTypes.InferProps<T> & Omit<React.HTMLProps<K>, keyof T>;
17
+ export declare const spsGlobalPropTypes: {
18
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
19
+ className: PropTypes.Requireable<string>;
20
+ "data-testid": PropTypes.Requireable<string>;
21
+ unsafelyReplaceClassName: PropTypes.Requireable<string>;
22
+ };
23
+ export * from "prop-types";
@@ -0,0 +1,26 @@
1
+ import { values } from "@spscommerce/utils";
2
+ import * as PropTypes from "prop-types";
3
+ export function deprecated(type) {
4
+ return type;
5
+ }
6
+ export function enumValue(e) {
7
+ return PropTypes.oneOf(values(e));
8
+ }
9
+ export function fun() {
10
+ return PropTypes.func;
11
+ }
12
+ export function impl() {
13
+ return PropTypes.object;
14
+ }
15
+ export function ref() {
16
+ return PropTypes.object;
17
+ }
18
+ export var nodeOrRenderFn = PropTypes.oneOfType([PropTypes.node, PropTypes.func]);
19
+ export var spsGlobalPropTypes = {
20
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
21
+ className: PropTypes.string,
22
+ "data-testid": PropTypes.string,
23
+ unsafelyReplaceClassName: PropTypes.string,
24
+ };
25
+ export * from "prop-types";
26
+ //# sourceMappingURL=prop-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prop-types.js","sourceRoot":"","sources":["../../src/prop-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAIxC,MAAM,UAAU,UAAU,CAAI,IAA8B;IAC1D,OAAO,IAAqB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,SAAS,CAAI,CAAM;IACjC,OAAO,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,GAAG;IACjB,OAAQ,SAAS,CAAC,IAAiC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAQ,SAAS,CAAC,MAA0C,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,GAAG;IACjB,OAAQ,SAAS,CAAC,MAA4D,CAAC;AACjF,CAAC;AAID,MAAM,CAAC,IAAM,cAAc,GAAG,SAAS,CAAC,SAAS,CAC/C,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CACjC,CAAC;AAWF,MAAM,CAAC,IAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAClF,SAAS,EAAE,SAAS,CAAC,MAAM;IAC3B,aAAa,EAAE,SAAS,CAAC,MAAM;IAC/B,wBAAwB,EAAE,SAAS,CAAC,MAAM;CAC3C,CAAC;AAEF,cAAc,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import * as jestDom from "@testing-library/jest-dom";
2
+ expect.extend(jestDom);
3
+ //# sourceMappingURL=setup-jest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-jest.js","sourceRoot":"","sources":["../../src/setup-jest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAErD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import * as PropTypes from "../prop-types";
3
+ declare const propTypes: {
4
+ chartData: PropTypes.Requireable<ChartDataProps[]>;
5
+ chartHeight: PropTypes.Requireable<number>;
6
+ chartWidth: PropTypes.Requireable<number>;
7
+ target: PropTypes.Requireable<number>;
8
+ goal: PropTypes.Requireable<number>;
9
+ total: PropTypes.Requireable<number>;
10
+ };
11
+ export interface ChartDataProps {
12
+ label: string;
13
+ value: number;
14
+ color: string;
15
+ }
16
+ export declare type SpsStackedHorizontalBarChartProps = PropTypes.InferTS<typeof propTypes, HTMLDivElement>;
17
+ export declare function SpsStackedHorizontalBarChart(props: SpsStackedHorizontalBarChartProps): JSX.Element;
18
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { DSReactExamples } from "@spscommerce/ds-shared";
2
+ export declare const SpsStackedHorizontalBarChartExamples: DSReactExamples;
@@ -0,0 +1,21 @@
1
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
+ return cooked;
4
+ };
5
+ import { code } from "@spscommerce/utils";
6
+ export var SpsStackedHorizontalBarChartExamples = {
7
+ basic: {
8
+ label: "Basic",
9
+ description: code(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <p>Stacked horizontal bar chart example.</p>\n "], ["\n <p>Stacked horizontal bar chart example.</p>\n "]))),
10
+ examples: {
11
+ basic: {
12
+ react: code(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n function DemoComponent() {\n // The sum of the values must be 100\n const data = [\n {label: 'Label 1', value: 10, color: '#6c5efb'},\n {label: 'Label 2', value: 7, color: '#ff9632'},\n {label: 'Label 3', value: 35, color: '#a44afe'},\n {label: 'Label 4', value: 29, color: '#32be6f'},\n {label: 'Label 5', value: 19, color: '#a5a9ab'}\n ];\n\n return (\n <SpsStackedHorizontalBarChart\n chartData={data}\n chartHeight={100}\n chartWidth={800}\n />\n )\n }\n "], ["\n function DemoComponent() {\n // The sum of the values must be 100\n const data = [\n {label: 'Label 1', value: 10, color: '#6c5efb'},\n {label: 'Label 2', value: 7, color: '#ff9632'},\n {label: 'Label 3', value: 35, color: '#a44afe'},\n {label: 'Label 4', value: 29, color: '#32be6f'},\n {label: 'Label 5', value: 19, color: '#a5a9ab'}\n ];\n\n return (\n <SpsStackedHorizontalBarChart\n chartData={data}\n chartHeight={100}\n chartWidth={800}\n />\n )\n }\n "]))),
13
+ },
14
+ vertical: {
15
+ react: code(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n function DemoComponent() {\n // The sum of the values must be 100\n const data = [\n {label: 'Label 1', value: 10, color: '#6c5efb'},\n {label: 'Label 2', value: 7, color: '#ff9632'},\n {label: 'Label 3', value: 35, color: '#a44afe'},\n {label: 'Label 4', value: 29, color: '#32be6f'},\n {label: 'Label 5', value: 19, color: '#a5a9ab'}\n ];\n\n return (\n <SpsStackedHorizontalBarChart\n chartData={data}\n chartHeight={100}\n chartWidth={800}\n total={81}\n target={67}\n goal={99}\n />\n )\n }\n "], ["\n function DemoComponent() {\n // The sum of the values must be 100\n const data = [\n {label: 'Label 1', value: 10, color: '#6c5efb'},\n {label: 'Label 2', value: 7, color: '#ff9632'},\n {label: 'Label 3', value: 35, color: '#a44afe'},\n {label: 'Label 4', value: 29, color: '#32be6f'},\n {label: 'Label 5', value: 19, color: '#a5a9ab'}\n ];\n\n return (\n <SpsStackedHorizontalBarChart\n chartData={data}\n chartHeight={100}\n chartWidth={800}\n total={81}\n target={67}\n goal={99}\n />\n )\n }\n "]))),
16
+ },
17
+ },
18
+ },
19
+ };
20
+ var templateObject_1, templateObject_2, templateObject_3;
21
+ //# sourceMappingURL=SpsStackedHorizontalBarChart.examples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpsStackedHorizontalBarChart.examples.js","sourceRoot":"","sources":["../../../src/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.examples.tsx"],"names":[],"mappings":";;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,MAAM,CAAC,IAAM,oCAAoC,GAAoB;IACnE,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,IAAI,yIAAA,sEAEZ,IAAA;QACL,QAAQ,EAAE;YACR,KAAK,EAAE;gBACL,KAAK,EAAE,IAAI,q9BAAA,k5BAmBF,IAAA;aACV;YACD,QAAQ,EAAE;gBACR,KAAK,EAAE,IAAI,ylCAAA,shCAsBF,IAAA;aACV;SACF;KACF;CACF,CAAC"}