@spscommerce/ds-react-charts 4.34.2-ie → 4.36.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/lib/index.cjs.js +21 -142
- package/lib/index.es.js +422 -379
- package/package.json +10 -11
- package/vite.config.js +1 -1
- package/dist/out-tsc/bar/SpsBarChart.d.ts +0 -23
- package/dist/out-tsc/bar/SpsBarChart.examples.d.ts +0 -2
- package/dist/out-tsc/bar/SpsBarChart.examples.js +0 -49
- package/dist/out-tsc/bar/SpsBarChart.examples.js.map +0 -1
- package/dist/out-tsc/bar/SpsBarChart.js +0 -137
- package/dist/out-tsc/bar/SpsBarChart.js.map +0 -1
- package/dist/out-tsc/bar/SpsHorizontalBarChart.d.ts +0 -24
- package/dist/out-tsc/bar/SpsHorizontalBarChart.js +0 -144
- package/dist/out-tsc/bar/SpsHorizontalBarChart.js.map +0 -1
- package/dist/out-tsc/index.d.ts +0 -6
- package/dist/out-tsc/index.js +0 -7
- package/dist/out-tsc/index.js.map +0 -1
- package/dist/out-tsc/manifest.d.ts +0 -2
- package/dist/out-tsc/manifest.js +0 -21
- package/dist/out-tsc/manifest.js.map +0 -1
- package/dist/out-tsc/prop-types.d.ts +0 -23
- package/dist/out-tsc/prop-types.js +0 -26
- package/dist/out-tsc/prop-types.js.map +0 -1
- package/dist/out-tsc/setup-jest.d.ts +0 -1
- package/dist/out-tsc/setup-jest.js +0 -3
- package/dist/out-tsc/setup-jest.js.map +0 -1
- package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.d.ts +0 -18
- package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.examples.d.ts +0 -2
- package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.examples.js +0 -21
- package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.examples.js.map +0 -1
- package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.js +0 -148
- package/dist/out-tsc/stackedHorizontalBarChart/SpsStackedHorizontalBarChart.js.map +0 -1
package/lib/index.es.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
20
|
import * as React from "react";
|
|
2
21
|
import React__default, { useMemo } from "react";
|
|
3
22
|
import * as DSColors from "@spscommerce/ds-colors";
|
|
@@ -4611,57 +4630,13 @@ function impl() {
|
|
|
4611
4630
|
return propTypes$3.exports.object;
|
|
4612
4631
|
}
|
|
4613
4632
|
propTypes$3.exports.oneOfType([propTypes$3.exports.node, propTypes$3.exports.func]);
|
|
4614
|
-
|
|
4633
|
+
const spsGlobalPropTypes = {
|
|
4615
4634
|
children: propTypes$3.exports.oneOfType([propTypes$3.exports.arrayOf(propTypes$3.exports.node), propTypes$3.exports.node]),
|
|
4616
4635
|
className: propTypes$3.exports.string,
|
|
4617
4636
|
"data-testid": propTypes$3.exports.string,
|
|
4618
4637
|
unsafelyReplaceClassName: propTypes$3.exports.string
|
|
4619
4638
|
};
|
|
4620
|
-
|
|
4621
|
-
__assign$1 = Object.assign || function(t) {
|
|
4622
|
-
for (var s, i2 = 1, n = arguments.length; i2 < n; i2++) {
|
|
4623
|
-
s = arguments[i2];
|
|
4624
|
-
for (var p in s)
|
|
4625
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
4626
|
-
t[p] = s[p];
|
|
4627
|
-
}
|
|
4628
|
-
return t;
|
|
4629
|
-
};
|
|
4630
|
-
return __assign$1.apply(this, arguments);
|
|
4631
|
-
};
|
|
4632
|
-
var __read$2 = function(o, n) {
|
|
4633
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4634
|
-
if (!m)
|
|
4635
|
-
return o;
|
|
4636
|
-
var i2 = m.call(o), r, ar = [], e;
|
|
4637
|
-
try {
|
|
4638
|
-
while ((n === void 0 || n-- > 0) && !(r = i2.next()).done)
|
|
4639
|
-
ar.push(r.value);
|
|
4640
|
-
} catch (error) {
|
|
4641
|
-
e = { error };
|
|
4642
|
-
} finally {
|
|
4643
|
-
try {
|
|
4644
|
-
if (r && !r.done && (m = i2["return"]))
|
|
4645
|
-
m.call(i2);
|
|
4646
|
-
} finally {
|
|
4647
|
-
if (e)
|
|
4648
|
-
throw e.error;
|
|
4649
|
-
}
|
|
4650
|
-
}
|
|
4651
|
-
return ar;
|
|
4652
|
-
};
|
|
4653
|
-
var __spreadArray$2 = function(to, from, pack) {
|
|
4654
|
-
if (pack || arguments.length === 2)
|
|
4655
|
-
for (var i2 = 0, l = from.length, ar; i2 < l; i2++) {
|
|
4656
|
-
if (ar || !(i2 in from)) {
|
|
4657
|
-
if (!ar)
|
|
4658
|
-
ar = Array.prototype.slice.call(from, 0, i2);
|
|
4659
|
-
ar[i2] = from[i2];
|
|
4660
|
-
}
|
|
4661
|
-
}
|
|
4662
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
4663
|
-
};
|
|
4664
|
-
var propsDoc$2 = {
|
|
4639
|
+
const propsDoc$2 = {
|
|
4665
4640
|
barFillColor1: "string",
|
|
4666
4641
|
barFillColor2: "string",
|
|
4667
4642
|
barFillColorHover: "string",
|
|
@@ -4674,51 +4649,84 @@ var propsDoc$2 = {
|
|
|
4674
4649
|
yMaxValue: "number",
|
|
4675
4650
|
yTickFormat: "(i: number) => string"
|
|
4676
4651
|
};
|
|
4677
|
-
|
|
4652
|
+
const propTypes$2 = __spreadProps(__spreadValues({}, spsGlobalPropTypes), {
|
|
4653
|
+
barFillColor1: propTypes$3.exports.string,
|
|
4654
|
+
barFillColor2: propTypes$3.exports.string,
|
|
4655
|
+
barFillColorHover: propTypes$3.exports.string,
|
|
4656
|
+
chartData: propTypes$3.exports.arrayOf(impl()),
|
|
4657
|
+
chartHeight: propTypes$3.exports.number,
|
|
4658
|
+
chartWidth: propTypes$3.exports.number,
|
|
4659
|
+
barSize: propTypes$3.exports.number,
|
|
4660
|
+
yAxis: impl(),
|
|
4661
|
+
xAxis: impl(),
|
|
4662
|
+
yMaxValue: propTypes$3.exports.number,
|
|
4663
|
+
yTickFormat: fun()
|
|
4664
|
+
});
|
|
4678
4665
|
function SpsBarChart(props) {
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4666
|
+
const {
|
|
4667
|
+
barFillColor1 = DSColors.colors.blue200,
|
|
4668
|
+
barFillColor2 = "#007DB880",
|
|
4669
|
+
barFillColorHover = DSColors.colors.blue300,
|
|
4670
|
+
chartData,
|
|
4671
|
+
chartHeight,
|
|
4672
|
+
chartWidth,
|
|
4673
|
+
barSize,
|
|
4674
|
+
yAxis = {
|
|
4675
|
+
tickValues: "value",
|
|
4676
|
+
tickCount: 3
|
|
4677
|
+
},
|
|
4678
|
+
xAxis = {
|
|
4679
|
+
tickValues: "label"
|
|
4680
|
+
},
|
|
4681
|
+
yMaxValue,
|
|
4682
|
+
yTickFormat
|
|
4683
|
+
} = props;
|
|
4684
|
+
const margin = {
|
|
4686
4685
|
top: 30,
|
|
4687
4686
|
bottom: 70,
|
|
4688
4687
|
left: 50,
|
|
4689
4688
|
right: 30
|
|
4690
4689
|
};
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
var y = function(d) {
|
|
4697
|
-
return d[yAxis.tickValues];
|
|
4698
|
-
};
|
|
4699
|
-
var xScale = createBandScale({
|
|
4690
|
+
const xMax = chartWidth - margin.left - margin.right;
|
|
4691
|
+
const yMax = chartHeight - margin.top - margin.bottom;
|
|
4692
|
+
const x = (d) => d[xAxis.tickValues];
|
|
4693
|
+
const y = (d) => d[yAxis.tickValues];
|
|
4694
|
+
const xScale = createBandScale({
|
|
4700
4695
|
range: [0, xMax],
|
|
4701
4696
|
round: true,
|
|
4702
4697
|
domain: chartData.map(x),
|
|
4703
4698
|
padding: 0.4
|
|
4704
4699
|
});
|
|
4705
|
-
|
|
4700
|
+
const yScale = createLinearScale({
|
|
4706
4701
|
range: [yMax, 0],
|
|
4707
4702
|
round: true,
|
|
4708
|
-
domain: [0, yMaxValue || Math.max
|
|
4703
|
+
domain: [0, yMaxValue || Math.max(...chartData.map(y))]
|
|
4709
4704
|
});
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4705
|
+
const compose = (scale, accessor) => (data) => scale(accessor(data));
|
|
4706
|
+
const xPoint = compose(xScale, x);
|
|
4707
|
+
const yPoint = compose(yScale, y);
|
|
4708
|
+
const colorGradientID = nanoid();
|
|
4709
|
+
return /* @__PURE__ */ React.createElement("svg", {
|
|
4710
|
+
width: chartWidth,
|
|
4711
|
+
height: chartHeight,
|
|
4712
|
+
className: "sps-chart-wrapper"
|
|
4713
|
+
}, /* @__PURE__ */ React.createElement(GridRows, {
|
|
4714
|
+
scale: yScale,
|
|
4715
|
+
left: margin.left,
|
|
4716
|
+
width: xMax,
|
|
4717
|
+
numTicks: yAxis.tickCount,
|
|
4718
|
+
stroke: DSColors.colors.gray400,
|
|
4719
|
+
strokeOpacity: 0.2
|
|
4720
|
+
}), /* @__PURE__ */ React.createElement(LinearGradient, {
|
|
4721
|
+
id: colorGradientID,
|
|
4722
|
+
from: barFillColor1,
|
|
4723
|
+
to: barFillColor2
|
|
4724
|
+
}), chartData.map((element, idx) => {
|
|
4725
|
+
const barHeight = yMax - yPoint(element);
|
|
4726
|
+
const barID = nanoid();
|
|
4727
|
+
return /* @__PURE__ */ React.createElement(Group, {
|
|
4728
|
+
key: idx
|
|
4729
|
+
}, /* @__PURE__ */ React.createElement(BarRounded, {
|
|
4722
4730
|
id: barID,
|
|
4723
4731
|
top: true,
|
|
4724
4732
|
radius: 4,
|
|
@@ -4726,24 +4734,36 @@ function SpsBarChart(props) {
|
|
|
4726
4734
|
y: yMax - barHeight,
|
|
4727
4735
|
height: barHeight,
|
|
4728
4736
|
width: barSize || xScale.bandwidth(),
|
|
4729
|
-
fill:
|
|
4730
|
-
onMouseEnter:
|
|
4731
|
-
|
|
4737
|
+
fill: `url(#${colorGradientID})`,
|
|
4738
|
+
onMouseEnter: (e) => {
|
|
4739
|
+
const targetElement = e.target;
|
|
4732
4740
|
targetElement.style.fill = barFillColorHover;
|
|
4733
4741
|
},
|
|
4734
|
-
onMouseLeave:
|
|
4735
|
-
|
|
4742
|
+
onMouseLeave: (e) => {
|
|
4743
|
+
const targetElement = e.target;
|
|
4736
4744
|
targetElement.style.fill = null;
|
|
4737
4745
|
}
|
|
4738
|
-
}), React.createElement(AxisLeft, {
|
|
4739
|
-
|
|
4746
|
+
}), /* @__PURE__ */ React.createElement(AxisLeft, {
|
|
4747
|
+
scale: yScale,
|
|
4748
|
+
left: margin.left,
|
|
4749
|
+
hideTicks: true,
|
|
4750
|
+
numTicks: yAxis.tickCount,
|
|
4751
|
+
tickFormat: yTickFormat || void 0,
|
|
4752
|
+
stroke: DSColors.colors.gray300,
|
|
4753
|
+
tickLabelProps: () => ({
|
|
4740
4754
|
textAnchor: "end",
|
|
4741
4755
|
fontSize: "12px",
|
|
4742
4756
|
fill: DSColors.colors.gray400,
|
|
4743
4757
|
fontWeight: "200"
|
|
4744
|
-
}
|
|
4745
|
-
}
|
|
4746
|
-
|
|
4758
|
+
})
|
|
4759
|
+
}), /* @__PURE__ */ React.createElement(AxisBottom, {
|
|
4760
|
+
top: yMax,
|
|
4761
|
+
scale: xScale,
|
|
4762
|
+
left: margin.left,
|
|
4763
|
+
hideTicks: true,
|
|
4764
|
+
hideAxisLine: true,
|
|
4765
|
+
stroke: DSColors.colors.gray300,
|
|
4766
|
+
tickLabelProps: () => ({
|
|
4747
4767
|
textAnchor: "middle",
|
|
4748
4768
|
fontSize: "12px",
|
|
4749
4769
|
fontWeight: "200",
|
|
@@ -4751,8 +4771,10 @@ function SpsBarChart(props) {
|
|
|
4751
4771
|
width: xScale.bandwidth() + xScale.bandwidth() / 2,
|
|
4752
4772
|
lineHeight: "15px",
|
|
4753
4773
|
verticalAnchor: "start"
|
|
4754
|
-
}
|
|
4755
|
-
}
|
|
4774
|
+
})
|
|
4775
|
+
}), /* @__PURE__ */ React.createElement(SpsTooltip, {
|
|
4776
|
+
for: barID
|
|
4777
|
+
}, element.label));
|
|
4756
4778
|
}));
|
|
4757
4779
|
}
|
|
4758
4780
|
Object.assign(SpsBarChart, {
|
|
@@ -4760,28 +4782,23 @@ Object.assign(SpsBarChart, {
|
|
|
4760
4782
|
propTypes: propTypes$2,
|
|
4761
4783
|
displayName: "SpsBarChart"
|
|
4762
4784
|
});
|
|
4763
|
-
|
|
4764
|
-
if (Object.defineProperty) {
|
|
4765
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
4766
|
-
} else {
|
|
4767
|
-
cooked.raw = raw;
|
|
4768
|
-
}
|
|
4769
|
-
return cooked;
|
|
4770
|
-
};
|
|
4771
|
-
var SpsBarChartExamples = {
|
|
4785
|
+
const SpsBarChartExamples = {
|
|
4772
4786
|
general: {
|
|
4773
4787
|
label: "General Usage",
|
|
4774
|
-
description:
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4788
|
+
description: ({ NavigateTo, Link }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ 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)."), /* @__PURE__ */ React.createElement("p", null, "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", " ", /* @__PURE__ */ React.createElement(NavigateTo, {
|
|
4789
|
+
to: "Tables"
|
|
4790
|
+
}, "Table"), "."), /* @__PURE__ */ React.createElement("h5", null, "Color"), /* @__PURE__ */ React.createElement("p", null, "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", " ", /* @__PURE__ */ React.createElement(Link, {
|
|
4791
|
+
to: "/style-and-layout/colors"
|
|
4792
|
+
}, "Colors"), " section."), /* @__PURE__ */ React.createElement("h5", null, "Interaction"), /* @__PURE__ */ 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."))
|
|
4778
4793
|
},
|
|
4779
4794
|
horizontal: {
|
|
4780
4795
|
label: "Horizontal Bar Chart",
|
|
4781
|
-
description: code
|
|
4796
|
+
description: code`
|
|
4797
|
+
<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>
|
|
4798
|
+
`,
|
|
4782
4799
|
examples: {
|
|
4783
4800
|
vertical: {
|
|
4784
|
-
react: code
|
|
4801
|
+
react: code`
|
|
4785
4802
|
function DemoComponent() {
|
|
4786
4803
|
const data = [
|
|
4787
4804
|
{ value: 69, label: "Aktie Sports" },
|
|
@@ -4820,87 +4837,19 @@ var SpsBarChartExamples = {
|
|
|
4820
4837
|
/>
|
|
4821
4838
|
)
|
|
4822
4839
|
}
|
|
4823
|
-
`
|
|
4824
|
-
function DemoComponent() {
|
|
4825
|
-
const data = [
|
|
4826
|
-
{ value: 69, label: "Aktie Sports" },
|
|
4827
|
-
{ value: 69, label: "Dicks Sporting Goods" },
|
|
4828
|
-
{ value: 64, label: "FGL Sports" },
|
|
4829
|
-
{ value: 62, label: "Foot Asylum" },
|
|
4830
|
-
{ value: 55, label: "Hervis" },
|
|
4831
|
-
{ value: 51, label: "Lovell Rugby" },
|
|
4832
|
-
{ value: 48, label: "Modells Sporting Goods" },
|
|
4833
|
-
{ value: 44, label: "Perry Sport" },
|
|
4834
|
-
{ value: 44, label: "Sportman Warhouse Australia" },
|
|
4835
|
-
{ value: 44, label: "Perry Sport 2" },
|
|
4836
|
-
]
|
|
4837
|
-
|
|
4838
|
-
xTickFormat = (i) => \\\`\\\${i}\\\${i !== 0 ? "%" : ""}\\\`
|
|
4839
|
-
|
|
4840
|
-
return (
|
|
4841
|
-
<SpsHorizontalBarChart
|
|
4842
|
-
chartData={data}
|
|
4843
|
-
chartHeight={523}
|
|
4844
|
-
chartWidth={838}
|
|
4845
|
-
barFillColor1 = "#32BE6F"
|
|
4846
|
-
barFillColor2 = "#32BE6F80"
|
|
4847
|
-
barFillColorHover = "#289858"
|
|
4848
|
-
yAxis={{
|
|
4849
|
-
tickValues: 'label',
|
|
4850
|
-
}}
|
|
4851
|
-
xAxis={{
|
|
4852
|
-
tickValues: 'value',
|
|
4853
|
-
tickCount: '10'
|
|
4854
|
-
}}
|
|
4855
|
-
marginLeft={135}
|
|
4856
|
-
xMaxValue={100}
|
|
4857
|
-
barSize={20}
|
|
4858
|
-
xTickFormat={xTickFormat}
|
|
4859
|
-
/>
|
|
4860
|
-
)
|
|
4861
|
-
}
|
|
4862
|
-
`])))
|
|
4840
|
+
`
|
|
4863
4841
|
}
|
|
4864
4842
|
}
|
|
4865
4843
|
},
|
|
4866
4844
|
vertical: {
|
|
4867
4845
|
label: "Vertical Bar Chart",
|
|
4868
|
-
description: code
|
|
4846
|
+
description: code`
|
|
4847
|
+
<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>
|
|
4848
|
+
<p>If the categories become too crowded along the X-axis, opt for a Horizontal Bar Chart instead.</p>
|
|
4849
|
+
`,
|
|
4869
4850
|
examples: {
|
|
4870
4851
|
vertical: {
|
|
4871
|
-
react: code
|
|
4872
|
-
function DemoComponent() {
|
|
4873
|
-
const data = [
|
|
4874
|
-
{ value: 112, label: "Aktie Sports" },
|
|
4875
|
-
{ value: 100, label: "Dicks Sporting Goods" },
|
|
4876
|
-
{ value: 90, label: "FGL Sports" },
|
|
4877
|
-
{ value: 82, label: "Foot Asylum" },
|
|
4878
|
-
{ value: 76, label: "Hervis" },
|
|
4879
|
-
{ value: 64, label: "Lovell Rugby" },
|
|
4880
|
-
{ value: 64, label: "Modells Sporting Goods" },
|
|
4881
|
-
]
|
|
4882
|
-
|
|
4883
|
-
return (
|
|
4884
|
-
<SpsBarChart
|
|
4885
|
-
chartData={data}
|
|
4886
|
-
chartHeight={364}
|
|
4887
|
-
chartWidth={838}
|
|
4888
|
-
barFillColor1 = "#9B4B87"
|
|
4889
|
-
barFillColor2 = "#9B4B8780"
|
|
4890
|
-
barFillColorHover = "#7C3C6C"
|
|
4891
|
-
yAxis={{
|
|
4892
|
-
tickValues: 'value',
|
|
4893
|
-
tickCount: '5',
|
|
4894
|
-
}}
|
|
4895
|
-
xAxis={{
|
|
4896
|
-
tickValues: 'label',
|
|
4897
|
-
}}
|
|
4898
|
-
yMaxValue={125}
|
|
4899
|
-
barSize={45}
|
|
4900
|
-
/>
|
|
4901
|
-
)
|
|
4902
|
-
}
|
|
4903
|
-
`], [`
|
|
4852
|
+
react: code`
|
|
4904
4853
|
function DemoComponent() {
|
|
4905
4854
|
const data = [
|
|
4906
4855
|
{ value: 112, label: "Aktie Sports" },
|
|
@@ -4932,57 +4881,12 @@ var SpsBarChartExamples = {
|
|
|
4932
4881
|
/>
|
|
4933
4882
|
)
|
|
4934
4883
|
}
|
|
4935
|
-
`
|
|
4884
|
+
`
|
|
4936
4885
|
}
|
|
4937
4886
|
}
|
|
4938
4887
|
}
|
|
4939
4888
|
};
|
|
4940
|
-
|
|
4941
|
-
var __assign = function() {
|
|
4942
|
-
__assign = Object.assign || function(t) {
|
|
4943
|
-
for (var s, i2 = 1, n = arguments.length; i2 < n; i2++) {
|
|
4944
|
-
s = arguments[i2];
|
|
4945
|
-
for (var p in s)
|
|
4946
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
4947
|
-
t[p] = s[p];
|
|
4948
|
-
}
|
|
4949
|
-
return t;
|
|
4950
|
-
};
|
|
4951
|
-
return __assign.apply(this, arguments);
|
|
4952
|
-
};
|
|
4953
|
-
var __read$1 = function(o, n) {
|
|
4954
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4955
|
-
if (!m)
|
|
4956
|
-
return o;
|
|
4957
|
-
var i2 = m.call(o), r, ar = [], e;
|
|
4958
|
-
try {
|
|
4959
|
-
while ((n === void 0 || n-- > 0) && !(r = i2.next()).done)
|
|
4960
|
-
ar.push(r.value);
|
|
4961
|
-
} catch (error) {
|
|
4962
|
-
e = { error };
|
|
4963
|
-
} finally {
|
|
4964
|
-
try {
|
|
4965
|
-
if (r && !r.done && (m = i2["return"]))
|
|
4966
|
-
m.call(i2);
|
|
4967
|
-
} finally {
|
|
4968
|
-
if (e)
|
|
4969
|
-
throw e.error;
|
|
4970
|
-
}
|
|
4971
|
-
}
|
|
4972
|
-
return ar;
|
|
4973
|
-
};
|
|
4974
|
-
var __spreadArray$1 = function(to, from, pack) {
|
|
4975
|
-
if (pack || arguments.length === 2)
|
|
4976
|
-
for (var i2 = 0, l = from.length, ar; i2 < l; i2++) {
|
|
4977
|
-
if (ar || !(i2 in from)) {
|
|
4978
|
-
if (!ar)
|
|
4979
|
-
ar = Array.prototype.slice.call(from, 0, i2);
|
|
4980
|
-
ar[i2] = from[i2];
|
|
4981
|
-
}
|
|
4982
|
-
}
|
|
4983
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
4984
|
-
};
|
|
4985
|
-
var propsDoc$1 = {
|
|
4889
|
+
const propsDoc$1 = {
|
|
4986
4890
|
barFillColor1: "string",
|
|
4987
4891
|
barFillColor2: "string",
|
|
4988
4892
|
barFillColorHover: "string",
|
|
@@ -4996,58 +4900,98 @@ var propsDoc$1 = {
|
|
|
4996
4900
|
xMaxValue: "number",
|
|
4997
4901
|
xTickFormat: "(i: number) => string"
|
|
4998
4902
|
};
|
|
4999
|
-
|
|
4903
|
+
const propTypes$1 = __spreadProps(__spreadValues({}, spsGlobalPropTypes), {
|
|
4904
|
+
barFillColor1: propTypes$3.exports.string,
|
|
4905
|
+
barFillColor2: propTypes$3.exports.string,
|
|
4906
|
+
barFillColorHover: propTypes$3.exports.string,
|
|
4907
|
+
chartData: propTypes$3.exports.arrayOf(impl()),
|
|
4908
|
+
chartHeight: propTypes$3.exports.number,
|
|
4909
|
+
chartWidth: propTypes$3.exports.number,
|
|
4910
|
+
barSize: propTypes$3.exports.number,
|
|
4911
|
+
yAxis: impl(),
|
|
4912
|
+
xAxis: impl(),
|
|
4913
|
+
marginLeft: propTypes$3.exports.number,
|
|
4914
|
+
xMaxValue: propTypes$3.exports.number,
|
|
4915
|
+
xTickFormat: fun()
|
|
4916
|
+
});
|
|
5000
4917
|
function SpsHorizontalBarChart(props) {
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
4918
|
+
const {
|
|
4919
|
+
barFillColor1 = DSColors.colors.blue200,
|
|
4920
|
+
barFillColor2 = "#007DB880",
|
|
4921
|
+
barFillColorHover = DSColors.colors.blue300,
|
|
4922
|
+
chartData,
|
|
4923
|
+
chartHeight,
|
|
4924
|
+
chartWidth,
|
|
4925
|
+
barSize,
|
|
4926
|
+
yAxis = {
|
|
4927
|
+
tickValues: "label"
|
|
4928
|
+
},
|
|
4929
|
+
xAxis = {
|
|
4930
|
+
tickValues: "value",
|
|
4931
|
+
tickCount: 3
|
|
4932
|
+
},
|
|
4933
|
+
marginLeft = 30,
|
|
4934
|
+
xMaxValue,
|
|
4935
|
+
xTickFormat
|
|
4936
|
+
} = props;
|
|
4937
|
+
const margin = {
|
|
5008
4938
|
top: 30,
|
|
5009
4939
|
bottom: 30,
|
|
5010
4940
|
left: marginLeft,
|
|
5011
4941
|
right: 30
|
|
5012
4942
|
};
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
var y = function(d) {
|
|
5019
|
-
return d[yAxis.tickValues];
|
|
5020
|
-
};
|
|
5021
|
-
var yScale = createBandScale({
|
|
4943
|
+
const xMax = chartWidth - margin.left - margin.right;
|
|
4944
|
+
const yMax = chartHeight - margin.top - margin.bottom;
|
|
4945
|
+
const x = (d) => d[xAxis.tickValues];
|
|
4946
|
+
const y = (d) => d[yAxis.tickValues];
|
|
4947
|
+
const yScale = createBandScale({
|
|
5022
4948
|
range: [0, yMax],
|
|
5023
4949
|
round: true,
|
|
5024
4950
|
domain: chartData.map(y),
|
|
5025
4951
|
padding: 0.4
|
|
5026
4952
|
});
|
|
5027
|
-
|
|
4953
|
+
const xScale = createLinearScale({
|
|
5028
4954
|
range: [0, xMax],
|
|
5029
4955
|
round: true,
|
|
5030
|
-
domain: [0, xMaxValue || Math.max
|
|
4956
|
+
domain: [0, xMaxValue || Math.max(...chartData.map(x))]
|
|
5031
4957
|
});
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
4958
|
+
const compose = (scale, accessor) => (data) => scale(accessor(data));
|
|
4959
|
+
const xPoint = compose(xScale, x);
|
|
4960
|
+
const yPoint = compose(yScale, y);
|
|
4961
|
+
const colorGradientID = nanoid();
|
|
4962
|
+
const bgColorGradientID = nanoid();
|
|
4963
|
+
return /* @__PURE__ */ React.createElement("svg", {
|
|
4964
|
+
width: chartWidth,
|
|
4965
|
+
height: chartHeight,
|
|
4966
|
+
className: "sps-chart-wrapper"
|
|
4967
|
+
}, /* @__PURE__ */ React.createElement(GridColumns, {
|
|
4968
|
+
scale: xScale,
|
|
4969
|
+
left: margin.left,
|
|
4970
|
+
height: yMax,
|
|
4971
|
+
stroke: DSColors.colors.gray400,
|
|
4972
|
+
strokeOpacity: 0.2
|
|
4973
|
+
}), /* @__PURE__ */ React.createElement(LinearGradient, {
|
|
4974
|
+
id: bgColorGradientID,
|
|
4975
|
+
from: "#D2D4D580",
|
|
4976
|
+
to: "#D2D4D5",
|
|
4977
|
+
vertical: false
|
|
4978
|
+
}), /* @__PURE__ */ React.createElement(LinearGradient, {
|
|
4979
|
+
id: colorGradientID,
|
|
4980
|
+
from: barFillColor2,
|
|
4981
|
+
to: barFillColor1,
|
|
4982
|
+
vertical: false
|
|
4983
|
+
}), chartData.map((element, idx) => {
|
|
4984
|
+
const barWidth = xPoint(element);
|
|
4985
|
+
const barID = nanoid();
|
|
4986
|
+
return /* @__PURE__ */ React.createElement(Group, {
|
|
4987
|
+
key: idx
|
|
4988
|
+
}, /* @__PURE__ */ React.createElement("rect", {
|
|
5045
4989
|
x: margin.left,
|
|
5046
4990
|
y: yPoint(element) + (barSize ? (yScale.bandwidth() - barSize) / 2 : 0),
|
|
5047
4991
|
height: barSize || yScale.bandwidth(),
|
|
5048
4992
|
width: xMax,
|
|
5049
|
-
fill:
|
|
5050
|
-
}), React.createElement(BarRounded, {
|
|
4993
|
+
fill: `url(#${bgColorGradientID})`
|
|
4994
|
+
}), /* @__PURE__ */ React.createElement(BarRounded, {
|
|
5051
4995
|
id: barID,
|
|
5052
4996
|
right: true,
|
|
5053
4997
|
radius: 4,
|
|
@@ -5055,32 +4999,46 @@ function SpsHorizontalBarChart(props) {
|
|
|
5055
4999
|
y: yPoint(element) + (barSize ? (yScale.bandwidth() - barSize) / 2 : 0),
|
|
5056
5000
|
height: barSize || yScale.bandwidth(),
|
|
5057
5001
|
width: barWidth,
|
|
5058
|
-
fill:
|
|
5059
|
-
onMouseEnter:
|
|
5060
|
-
|
|
5002
|
+
fill: `url(#${colorGradientID})`,
|
|
5003
|
+
onMouseEnter: (e) => {
|
|
5004
|
+
const targetElement = e.target;
|
|
5061
5005
|
targetElement.style.fill = barFillColorHover;
|
|
5062
5006
|
},
|
|
5063
|
-
onMouseLeave:
|
|
5064
|
-
|
|
5007
|
+
onMouseLeave: (e) => {
|
|
5008
|
+
const targetElement = e.target;
|
|
5065
5009
|
targetElement.style.fill = null;
|
|
5066
5010
|
}
|
|
5067
|
-
}), React.createElement(AxisLeft, {
|
|
5068
|
-
|
|
5011
|
+
}), /* @__PURE__ */ React.createElement(AxisLeft, {
|
|
5012
|
+
scale: yScale,
|
|
5013
|
+
left: margin.left,
|
|
5014
|
+
hideTicks: true,
|
|
5015
|
+
hideAxisLine: true,
|
|
5016
|
+
stroke: DSColors.colors.gray300,
|
|
5017
|
+
tickLabelProps: () => ({
|
|
5069
5018
|
textAnchor: "end",
|
|
5070
5019
|
fontSize: "12px",
|
|
5071
5020
|
fill: DSColors.colors.gray400,
|
|
5072
5021
|
fontWeight: "200",
|
|
5073
5022
|
width: margin.left,
|
|
5074
5023
|
verticalAnchor: "middle"
|
|
5075
|
-
}
|
|
5076
|
-
}
|
|
5077
|
-
|
|
5024
|
+
})
|
|
5025
|
+
}), /* @__PURE__ */ React.createElement(AxisBottom, {
|
|
5026
|
+
top: yMax,
|
|
5027
|
+
scale: xScale,
|
|
5028
|
+
left: margin.left,
|
|
5029
|
+
hideTicks: true,
|
|
5030
|
+
numTicks: xAxis.tickCount,
|
|
5031
|
+
tickFormat: xTickFormat || void 0,
|
|
5032
|
+
stroke: DSColors.colors.gray300,
|
|
5033
|
+
tickLabelProps: () => ({
|
|
5078
5034
|
textAnchor: "middle",
|
|
5079
5035
|
fontSize: "12px",
|
|
5080
5036
|
fontWeight: "200",
|
|
5081
5037
|
fill: DSColors.colors.gray400
|
|
5082
|
-
}
|
|
5083
|
-
}
|
|
5038
|
+
})
|
|
5039
|
+
}), /* @__PURE__ */ React.createElement(SpsTooltip, {
|
|
5040
|
+
for: barID
|
|
5041
|
+
}, element.label));
|
|
5084
5042
|
}));
|
|
5085
5043
|
}
|
|
5086
5044
|
Object.assign(SpsHorizontalBarChart, {
|
|
@@ -5454,39 +5412,7 @@ Legend.propTypes = {
|
|
|
5454
5412
|
function Ordinal(props) {
|
|
5455
5413
|
return /* @__PURE__ */ React__default.createElement(Legend, props);
|
|
5456
5414
|
}
|
|
5457
|
-
|
|
5458
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5459
|
-
if (!m)
|
|
5460
|
-
return o;
|
|
5461
|
-
var i2 = m.call(o), r, ar = [], e;
|
|
5462
|
-
try {
|
|
5463
|
-
while ((n === void 0 || n-- > 0) && !(r = i2.next()).done)
|
|
5464
|
-
ar.push(r.value);
|
|
5465
|
-
} catch (error) {
|
|
5466
|
-
e = { error };
|
|
5467
|
-
} finally {
|
|
5468
|
-
try {
|
|
5469
|
-
if (r && !r.done && (m = i2["return"]))
|
|
5470
|
-
m.call(i2);
|
|
5471
|
-
} finally {
|
|
5472
|
-
if (e)
|
|
5473
|
-
throw e.error;
|
|
5474
|
-
}
|
|
5475
|
-
}
|
|
5476
|
-
return ar;
|
|
5477
|
-
};
|
|
5478
|
-
var __spreadArray = function(to, from, pack) {
|
|
5479
|
-
if (pack || arguments.length === 2)
|
|
5480
|
-
for (var i2 = 0, l = from.length, ar; i2 < l; i2++) {
|
|
5481
|
-
if (ar || !(i2 in from)) {
|
|
5482
|
-
if (!ar)
|
|
5483
|
-
ar = Array.prototype.slice.call(from, 0, i2);
|
|
5484
|
-
ar[i2] = from[i2];
|
|
5485
|
-
}
|
|
5486
|
-
}
|
|
5487
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
5488
|
-
};
|
|
5489
|
-
var propsDoc = {
|
|
5415
|
+
const propsDoc = {
|
|
5490
5416
|
chartData: "ChartDataProps[]",
|
|
5491
5417
|
chartHeight: "number",
|
|
5492
5418
|
chartWidth: "number",
|
|
@@ -5494,7 +5420,7 @@ var propsDoc = {
|
|
|
5494
5420
|
goal: "number",
|
|
5495
5421
|
total: "number"
|
|
5496
5422
|
};
|
|
5497
|
-
|
|
5423
|
+
const propTypes = {
|
|
5498
5424
|
chartData: propTypes$3.exports.arrayOf(impl()),
|
|
5499
5425
|
chartHeight: propTypes$3.exports.number,
|
|
5500
5426
|
chartWidth: propTypes$3.exports.number,
|
|
@@ -5503,116 +5429,233 @@ var propTypes = {
|
|
|
5503
5429
|
total: propTypes$3.exports.number
|
|
5504
5430
|
};
|
|
5505
5431
|
function SpsStackedHorizontalBarChart(props) {
|
|
5506
|
-
|
|
5507
|
-
|
|
5432
|
+
const {
|
|
5433
|
+
chartData,
|
|
5434
|
+
chartHeight,
|
|
5435
|
+
chartWidth,
|
|
5436
|
+
goal,
|
|
5437
|
+
target,
|
|
5438
|
+
total
|
|
5439
|
+
} = props;
|
|
5440
|
+
const margin = {
|
|
5508
5441
|
top: 25,
|
|
5509
5442
|
bottom: 40,
|
|
5510
5443
|
left: 30,
|
|
5511
5444
|
right: 30
|
|
5512
5445
|
};
|
|
5513
5446
|
function hexToRGB(hex2, alpha) {
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5447
|
+
const r = parseInt(hex2.slice(1, 3), 16);
|
|
5448
|
+
const g = parseInt(hex2.slice(3, 5), 16);
|
|
5449
|
+
const b = parseInt(hex2.slice(5, 7), 16);
|
|
5517
5450
|
if (alpha) {
|
|
5518
|
-
return
|
|
5451
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
5519
5452
|
}
|
|
5520
|
-
return
|
|
5521
|
-
}
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
var xScale = createLinearScale({
|
|
5453
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
5454
|
+
}
|
|
5455
|
+
const colors = chartData.map((c) => c.color);
|
|
5456
|
+
const keys = chartData.map((c) => c.label);
|
|
5457
|
+
const values = chartData.map((c) => c.value);
|
|
5458
|
+
const valuesSum = values.reduce((pv, cv) => pv + cv, 0);
|
|
5459
|
+
const relativeValues = values.map((c) => Math.round(c / valuesSum * 100 * 10) / 10);
|
|
5460
|
+
const xScale = createLinearScale({
|
|
5529
5461
|
domain: [0, 100],
|
|
5530
5462
|
nice: true
|
|
5531
5463
|
});
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
var yScale = createBandScale({
|
|
5537
|
-
domain: data,
|
|
5464
|
+
const absoluteData = [chartData.reduce((obj, item) => Object.assign(obj, { [item.label]: item.value }), {})];
|
|
5465
|
+
const relativeData = [chartData.reduce((obj, item, index) => Object.assign(obj, { [item.label]: relativeValues[index] }), {})];
|
|
5466
|
+
const yScale = createBandScale({
|
|
5467
|
+
domain: absoluteData,
|
|
5538
5468
|
padding: 0.2
|
|
5539
5469
|
});
|
|
5540
|
-
|
|
5541
|
-
domain: keys.map(
|
|
5542
|
-
|
|
5543
|
-
}),
|
|
5544
|
-
range: __spreadArray([], __read(colors), false)
|
|
5470
|
+
const colorScale = createOrdinalScale({
|
|
5471
|
+
domain: keys.map((c) => `${c}: ${relativeData[0][c]}%`),
|
|
5472
|
+
range: [...colors]
|
|
5545
5473
|
});
|
|
5546
|
-
|
|
5547
|
-
|
|
5474
|
+
const xMax = chartWidth - margin.left - margin.right;
|
|
5475
|
+
const yMax = chartHeight - margin.top - margin.bottom;
|
|
5548
5476
|
xScale.rangeRound([0, xMax]);
|
|
5549
5477
|
yScale.rangeRound([yMax, 0]);
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5478
|
+
const tickFormat2 = (i2) => `${i2}%`;
|
|
5479
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5480
|
+
style: { width: chartWidth },
|
|
5481
|
+
className: "position-relative"
|
|
5482
|
+
}, /* @__PURE__ */ React.createElement(Ordinal, {
|
|
5483
|
+
className: "fs-12 lh-18 gray600",
|
|
5484
|
+
scale: colorScale,
|
|
5485
|
+
direction: "row",
|
|
5486
|
+
shape: "rect",
|
|
5487
|
+
shapeWidth: 30,
|
|
5488
|
+
shapeHeight: 4,
|
|
5489
|
+
shapeMargin: "0 5px 0 0",
|
|
5490
|
+
shapeStyle: () => ({ borderRadius: "2px" }),
|
|
5491
|
+
labelMargin: "0",
|
|
5492
|
+
itemMargin: "0 10px 0 10px",
|
|
5493
|
+
style: {
|
|
5494
|
+
display: "flex",
|
|
5495
|
+
justifyContent: "center",
|
|
5496
|
+
fontSize: "16px"
|
|
5497
|
+
}
|
|
5498
|
+
}), goal && target && total && /* @__PURE__ */ React.createElement("div", {
|
|
5499
|
+
className: "position-absolute",
|
|
5500
|
+
style: {
|
|
5501
|
+
top: "26px",
|
|
5502
|
+
width: `${chartWidth - margin.left - margin.right}px`,
|
|
5503
|
+
margin: `0 ${margin.left}px`,
|
|
5504
|
+
height: "12px"
|
|
5505
|
+
}
|
|
5506
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
5507
|
+
className: "sps-icon sps-icon-chevron-down green200 fs-14 position-absolute",
|
|
5508
|
+
style: { left: `calc(${total}% - 5px)` }
|
|
5509
|
+
}), /* @__PURE__ */ React.createElement("i", {
|
|
5510
|
+
className: "sps-icon sps-icon-chevron-down gray600 fs-14 position-absolute",
|
|
5511
|
+
style: { left: `calc(${target}% - 5px)` }
|
|
5512
|
+
}), /* @__PURE__ */ React.createElement("i", {
|
|
5513
|
+
className: "sps-icon sps-icon-chevron-down red200 fs-14 position-absolute",
|
|
5514
|
+
style: { left: `calc(${goal}% - 5px)` }
|
|
5515
|
+
})), /* @__PURE__ */ React.createElement("svg", {
|
|
5516
|
+
width: chartWidth,
|
|
5517
|
+
height: chartHeight
|
|
5518
|
+
}, /* @__PURE__ */ React.createElement(Group, {
|
|
5519
|
+
top: margin.top,
|
|
5520
|
+
left: margin.left
|
|
5521
|
+
}, /* @__PURE__ */ React.createElement(BarStackHorizontal, {
|
|
5522
|
+
data: relativeData,
|
|
5523
|
+
keys,
|
|
5524
|
+
height: yMax,
|
|
5525
|
+
y: () => "",
|
|
5526
|
+
xScale,
|
|
5527
|
+
yScale,
|
|
5528
|
+
color: colorScale
|
|
5529
|
+
}, (barStacks) => barStacks.map((barStack) => barStack.bars.map((bar) => {
|
|
5530
|
+
let width = null;
|
|
5531
|
+
if (bar.x === 0 || barStacks.length - 1 === barStack.index) {
|
|
5532
|
+
width = bar.width - 1.5;
|
|
5533
|
+
} else {
|
|
5534
|
+
width = bar.width - 3;
|
|
5535
|
+
}
|
|
5536
|
+
if (width < 0) {
|
|
5537
|
+
width = 0;
|
|
5538
|
+
}
|
|
5539
|
+
return /* @__PURE__ */ React.createElement(Group, {
|
|
5540
|
+
key: `barstack-horizontal-${barStack.index}-${bar.index}`
|
|
5541
|
+
}, /* @__PURE__ */ React.createElement(LinearGradient, {
|
|
5542
|
+
id: `gradient-${barStack.index}`,
|
|
5543
|
+
vertical: false,
|
|
5544
|
+
from: hexToRGB(bar.color, 0.5),
|
|
5545
|
+
to: bar.color
|
|
5546
|
+
}), /* @__PURE__ */ React.createElement("rect", {
|
|
5547
|
+
id: bar.key,
|
|
5548
|
+
x: bar.x !== 0 ? bar.x + 1.5 : bar.x,
|
|
5549
|
+
y: bar.y,
|
|
5550
|
+
width,
|
|
5551
|
+
height: 20,
|
|
5552
|
+
fill: `url(#gradient-${barStack.index})`
|
|
5553
|
+
}, /* @__PURE__ */ React.createElement(SpsTooltip, {
|
|
5554
|
+
for: bar.key
|
|
5555
|
+
}, bar.key, /* @__PURE__ */ React.createElement("div", {
|
|
5556
|
+
className: "text-center"
|
|
5557
|
+
}, absoluteData[0][barStack.key]))));
|
|
5558
|
+
}))), /* @__PURE__ */ React.createElement(AxisBottom, {
|
|
5559
|
+
top: yMax + 6,
|
|
5560
|
+
tickFormat: tickFormat2,
|
|
5561
|
+
scale: xScale,
|
|
5562
|
+
stroke: DSColors.colors.gray400,
|
|
5563
|
+
tickStroke: DSColors.colors.gray400,
|
|
5564
|
+
tickLength: 4,
|
|
5565
|
+
tickLineProps: {
|
|
5566
|
+
y1: -11,
|
|
5567
|
+
y2: 5
|
|
5568
|
+
},
|
|
5569
|
+
tickLabelProps: () => ({
|
|
5577
5570
|
fill: DSColors.colors.gray400,
|
|
5578
5571
|
fontSize: 12,
|
|
5579
5572
|
textAnchor: "middle"
|
|
5580
|
-
}
|
|
5581
|
-
}
|
|
5573
|
+
})
|
|
5574
|
+
}))), goal && target && total && /* @__PURE__ */ React.createElement("footer", {
|
|
5575
|
+
className: "fs-12 lh-18 gray600 d-flex justify-content-center"
|
|
5576
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5577
|
+
className: "d-flex align-items-center"
|
|
5578
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
5579
|
+
className: "sps-icon sps-icon-chevron-down green200 fs-14 mr-1"
|
|
5580
|
+
}), "Current Total:", /* @__PURE__ */ React.createElement("span", {
|
|
5581
|
+
className: "sps-text-semibold gray600 ml-1"
|
|
5582
|
+
}, total, "%")), /* @__PURE__ */ React.createElement("span", {
|
|
5583
|
+
className: "ml-3 d-flex align-items-center"
|
|
5584
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
5585
|
+
className: "sps-icon sps-icon-chevron-down gray600 fs-14 mr-1"
|
|
5586
|
+
}), "Current Target:", /* @__PURE__ */ React.createElement("span", {
|
|
5587
|
+
className: "sps-text-semibold gray600 ml-1"
|
|
5588
|
+
}, target, "%")), /* @__PURE__ */ React.createElement("span", {
|
|
5589
|
+
className: "ml-3 d-flex align-items-center"
|
|
5590
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
5591
|
+
className: "sps-icon sps-icon-chevron-down red200 fs-14 mr-1"
|
|
5592
|
+
}), "Goal:", /* @__PURE__ */ React.createElement("span", {
|
|
5593
|
+
className: "sps-text-semibold gray600 ml-1"
|
|
5594
|
+
}, goal, "%"))));
|
|
5582
5595
|
}
|
|
5583
5596
|
Object.assign(SpsStackedHorizontalBarChart, {
|
|
5584
5597
|
props: propsDoc,
|
|
5585
5598
|
propTypes,
|
|
5586
5599
|
displayName: "SpsStackedHorizontalBarChart"
|
|
5587
5600
|
});
|
|
5588
|
-
|
|
5589
|
-
if (Object.defineProperty) {
|
|
5590
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
5591
|
-
} else {
|
|
5592
|
-
cooked.raw = raw;
|
|
5593
|
-
}
|
|
5594
|
-
return cooked;
|
|
5595
|
-
};
|
|
5596
|
-
var SpsStackedHorizontalBarChartExamples = {
|
|
5601
|
+
const SpsStackedHorizontalBarChartExamples = {
|
|
5597
5602
|
basic: {
|
|
5598
5603
|
label: "Basic",
|
|
5599
|
-
description: code
|
|
5604
|
+
description: code`
|
|
5605
|
+
<p>Stacked horizontal bar chart example.</p>
|
|
5606
|
+
`,
|
|
5600
5607
|
examples: {
|
|
5601
5608
|
basic: {
|
|
5602
|
-
react: code
|
|
5609
|
+
react: code`
|
|
5610
|
+
function DemoComponent() {
|
|
5611
|
+
const data = [
|
|
5612
|
+
{label: 'Label 1', value: 0.9, color: '#6c5efb'},
|
|
5613
|
+
{label: 'Label 2', value: 7, color: '#ff9632'},
|
|
5614
|
+
{label: 'Label 3', value: 15, color: '#a44afe'},
|
|
5615
|
+
{label: 'Label 4', value: 0, color: '#32be6f'},
|
|
5616
|
+
{label: 'Label 5', value: 10, color: '#a5a9ab'}
|
|
5617
|
+
];
|
|
5618
|
+
|
|
5619
|
+
return (
|
|
5620
|
+
<SpsStackedHorizontalBarChart
|
|
5621
|
+
chartData={data}
|
|
5622
|
+
chartHeight={100}
|
|
5623
|
+
chartWidth={800}
|
|
5624
|
+
/>
|
|
5625
|
+
)
|
|
5626
|
+
}
|
|
5627
|
+
`
|
|
5603
5628
|
},
|
|
5604
5629
|
vertical: {
|
|
5605
|
-
react: code
|
|
5630
|
+
react: code`
|
|
5631
|
+
function DemoComponent() {
|
|
5632
|
+
const data = [
|
|
5633
|
+
{label: 'Label 1', value: 10, color: '#6c5efb'},
|
|
5634
|
+
{label: 'Label 2', value: 7, color: '#ff9632'},
|
|
5635
|
+
{label: 'Label 3', value: 35, color: '#a44afe'},
|
|
5636
|
+
{label: 'Label 4', value: 29, color: '#32be6f'},
|
|
5637
|
+
{label: 'Label 5', value: 19, color: '#a5a9ab'}
|
|
5638
|
+
];
|
|
5639
|
+
|
|
5640
|
+
return (
|
|
5641
|
+
<SpsStackedHorizontalBarChart
|
|
5642
|
+
chartData={data}
|
|
5643
|
+
chartHeight={100}
|
|
5644
|
+
chartWidth={800}
|
|
5645
|
+
total={81}
|
|
5646
|
+
target={67}
|
|
5647
|
+
goal={99}
|
|
5648
|
+
/>
|
|
5649
|
+
)
|
|
5650
|
+
}
|
|
5651
|
+
`
|
|
5606
5652
|
}
|
|
5607
5653
|
}
|
|
5608
5654
|
}
|
|
5609
5655
|
};
|
|
5610
|
-
|
|
5611
|
-
var MANIFEST = {
|
|
5656
|
+
const MANIFEST = {
|
|
5612
5657
|
"Bar Chart": {
|
|
5613
|
-
description:
|
|
5614
|
-
return React.createElement("p", null, "Bar Charts are a data visualization used to compare sets of data to more easily analyze questions or identify gaps oriented toward user goals. ", React.createElement("br", null), "Each chart should focus on answering a single question about the dataset.");
|
|
5615
|
-
},
|
|
5658
|
+
description: () => /* @__PURE__ */ React.createElement("p", null, "Bar Charts are a data visualization used to compare sets of data to more easily analyze questions or identify gaps oriented toward user goals. ", /* @__PURE__ */ React.createElement("br", null), "Each chart should focus on answering a single question about the dataset."),
|
|
5616
5659
|
components: [SpsBarChart, SpsHorizontalBarChart],
|
|
5617
5660
|
examples: SpsBarChartExamples
|
|
5618
5661
|
},
|