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