@spscommerce/ds-react-charts 3.12.4 → 3.16.0
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/bar/SpsBarChart.d.ts +4 -4
- package/lib/bar/SpsBarChart.examples.d.ts +1 -1
- package/lib/bar/SpsBarChartComponents.d.ts +8 -8
- package/lib/bar/SpsBarChartHelperFunctions.d.ts +2 -2
- package/lib/index.cjs.js +331 -423
- package/lib/index.d.ts +4 -3
- package/lib/index.esm.js +328 -421
- package/lib/manifest.d.ts +2 -0
- package/package.json +8 -8
- package/rollup.config.js +24 -0
package/lib/bar/SpsBarChart.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { AxisDomain } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { AxisDomain } from 'recharts';
|
|
3
3
|
export interface BarChartProps {
|
|
4
4
|
isHorizontalBarChart?: boolean;
|
|
5
5
|
chartHeight: number;
|
|
6
6
|
chartWidth: number;
|
|
7
7
|
yAxis: {
|
|
8
|
-
type:
|
|
8
|
+
type: 'number' | 'category';
|
|
9
9
|
domain?: [AxisDomain, AxisDomain];
|
|
10
10
|
tickValues?: number[] | string[];
|
|
11
11
|
tickCount?: number;
|
|
12
12
|
};
|
|
13
13
|
xAxis: {
|
|
14
|
-
type:
|
|
14
|
+
type: 'number' | 'category';
|
|
15
15
|
domain?: [AxisDomain, AxisDomain];
|
|
16
16
|
tickValues?: number[] | string[];
|
|
17
17
|
tickCount?: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DSReactExamples } from
|
|
1
|
+
import { DSReactExamples } from '@spscommerce/ds-shared';
|
|
2
2
|
export declare const SpsBarChartExamples: DSReactExamples;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { ChartDataObject } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartDataObject } from './SpsBarChart';
|
|
3
3
|
/**
|
|
4
4
|
* Creates a percentage axis tick on the X axis with proper styling.
|
|
5
5
|
* Can be passed to tick in the XAxis Recharts component within SpsBarChart.
|
|
@@ -7,7 +7,7 @@ import { ChartDataObject } from "./SpsBarChart";
|
|
|
7
7
|
* @param x - X value for placement on the SVG, provided by Recharts.
|
|
8
8
|
* @param y - Y value for placement on the SVG, provided by Recharts.
|
|
9
9
|
*/
|
|
10
|
-
export declare const PercentXAxisTick: ({ payload, x, y }: any) => React.ReactElement
|
|
10
|
+
export declare const PercentXAxisTick: ({ payload, x, y }: any) => React.ReactElement;
|
|
11
11
|
/**
|
|
12
12
|
* Creates axis tick on the X axis with proper styling.
|
|
13
13
|
* Can be passed to tick in the XAxis Recharts component within SpsBarChart.
|
|
@@ -16,7 +16,7 @@ export declare const PercentXAxisTick: ({ payload, x, y }: any) => React.ReactEl
|
|
|
16
16
|
* @param x - X value for placement on the SVG, provided by Recharts.
|
|
17
17
|
* @param y - Y value for placement on the SVG, provided by Recharts.
|
|
18
18
|
*/
|
|
19
|
-
export declare const SpsDefaultXAxisTick: ({ payload, x, y }: any) => React.ReactElement
|
|
19
|
+
export declare const SpsDefaultXAxisTick: ({ payload, x, y }: any) => React.ReactElement;
|
|
20
20
|
/**
|
|
21
21
|
* Creates axis tick on the Y axis with proper styling.
|
|
22
22
|
* Can be passed to tick in the YAxis Recharts component within SpsBarChart.
|
|
@@ -25,7 +25,7 @@ export declare const SpsDefaultXAxisTick: ({ payload, x, y }: any) => React.Reac
|
|
|
25
25
|
* @param x - X value for placement on the SVG, provided by Recharts.
|
|
26
26
|
* @param y - Y value for placement on the SVG, provided by Recharts.
|
|
27
27
|
*/
|
|
28
|
-
export declare const SpsDefaultYAxisTick: ({ payload, x, y }: any) => React.ReactElement
|
|
28
|
+
export declare const SpsDefaultYAxisTick: ({ payload, x, y }: any) => React.ReactElement;
|
|
29
29
|
/**
|
|
30
30
|
* The tooltip for each bar rendered with proper styling.
|
|
31
31
|
* Is passed into the toolTipWrapper from the ToolTipHandler.
|
|
@@ -35,7 +35,7 @@ export declare const SpsDefaultYAxisTick: ({ payload, x, y }: any) => React.Reac
|
|
|
35
35
|
* @param label - Title of the toolTip, comes from the label provided in the ChartData.
|
|
36
36
|
* @param width - Calculated width of the toolTip for positioning of the caret.
|
|
37
37
|
*/
|
|
38
|
-
export declare const SpsDefaultChartTooltip: ({ descriptions, label, width }: any) => React.ReactElement
|
|
38
|
+
export declare const SpsDefaultChartTooltip: ({ descriptions, label, width }: any) => React.ReactElement;
|
|
39
39
|
/**
|
|
40
40
|
* Wraps the toolTip in a foreign object so HTML elements can be displayed and
|
|
41
41
|
* positioned within the SVG. Calculates the width of the toolTip for positioning
|
|
@@ -53,6 +53,6 @@ export declare const ToolTipWrapper: ({ x, barWidth, y, isHorizontalBarChart, cu
|
|
|
53
53
|
barWidth: number;
|
|
54
54
|
y: number;
|
|
55
55
|
isHorizontalBarChart: boolean;
|
|
56
|
-
customToolTip: React.ReactElement
|
|
56
|
+
customToolTip: React.ReactElement;
|
|
57
57
|
chartData: ChartDataObject;
|
|
58
|
-
}) => React.ReactElement
|
|
58
|
+
}) => React.ReactElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChartDataObject } from
|
|
1
|
+
import { ChartDataObject } from './SpsBarChart';
|
|
2
2
|
/**
|
|
3
3
|
* Handler for wrapping text on the x and y axis. Adds words one at a time to a
|
|
4
4
|
* tspan, if tspan node becomes longer than the given width it removes the
|
|
@@ -26,4 +26,4 @@ export declare const adjustAxisDY: (textGroup: any, textHeight: number) => void;
|
|
|
26
26
|
* @param identifier - Identifier for the chart, used to differentiate the
|
|
27
27
|
* gradients if multiple charts are rendered on a single page
|
|
28
28
|
*/
|
|
29
|
-
export declare const gradientCalculator: (defs: any, data: ChartDataObject
|
|
29
|
+
export declare const gradientCalculator: (defs: any, data: Array<ChartDataObject>, isHorizontal: boolean, fillColor: string, identifier: string) => void;
|
package/lib/index.cjs.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var EventEmitter = require('events');
|
|
7
7
|
var dsColors = require('@spscommerce/ds-colors');
|
|
8
|
-
var utils
|
|
8
|
+
var utils = require('@spscommerce/utils');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
11
|
|
|
@@ -65,10 +65,14 @@ function __read(o, n) {
|
|
|
65
65
|
return ar;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function
|
|
69
|
-
for (var
|
|
70
|
-
ar
|
|
71
|
-
|
|
68
|
+
function __spreadArray(to, from, pack) {
|
|
69
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
70
|
+
if (ar || !(i in from)) {
|
|
71
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
72
|
+
ar[i] = from[i];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
function __makeTemplateObject(cooked, raw) {
|
|
@@ -78,21 +82,6 @@ function __makeTemplateObject(cooked, raw) {
|
|
|
78
82
|
|
|
79
83
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
80
84
|
|
|
81
|
-
function getAugmentedNamespace(n) {
|
|
82
|
-
if (n.__esModule) return n;
|
|
83
|
-
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
84
|
-
Object.keys(n).forEach(function (k) {
|
|
85
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
86
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
get: function () {
|
|
89
|
-
return n[k];
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
return a;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
85
|
var _global = {exports: {}};
|
|
97
86
|
|
|
98
87
|
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
@@ -2243,7 +2232,7 @@ var PropTypes = propTypes$5.exports;
|
|
|
2243
2232
|
var classnames = {exports: {}};
|
|
2244
2233
|
|
|
2245
2234
|
/*!
|
|
2246
|
-
Copyright (c)
|
|
2235
|
+
Copyright (c) 2018 Jed Watson.
|
|
2247
2236
|
Licensed under the MIT License (MIT), see
|
|
2248
2237
|
http://jedwatson.github.io/classnames
|
|
2249
2238
|
*/
|
|
@@ -2255,7 +2244,7 @@ var classnames = {exports: {}};
|
|
|
2255
2244
|
|
|
2256
2245
|
var hasOwn = {}.hasOwnProperty;
|
|
2257
2246
|
|
|
2258
|
-
function classNames
|
|
2247
|
+
function classNames() {
|
|
2259
2248
|
var classes = [];
|
|
2260
2249
|
|
|
2261
2250
|
for (var i = 0; i < arguments.length; i++) {
|
|
@@ -2266,16 +2255,22 @@ var classnames = {exports: {}};
|
|
|
2266
2255
|
|
|
2267
2256
|
if (argType === 'string' || argType === 'number') {
|
|
2268
2257
|
classes.push(arg);
|
|
2269
|
-
} else if (Array.isArray(arg)
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2258
|
+
} else if (Array.isArray(arg)) {
|
|
2259
|
+
if (arg.length) {
|
|
2260
|
+
var inner = classNames.apply(null, arg);
|
|
2261
|
+
if (inner) {
|
|
2262
|
+
classes.push(inner);
|
|
2263
|
+
}
|
|
2273
2264
|
}
|
|
2274
2265
|
} else if (argType === 'object') {
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2266
|
+
if (arg.toString === Object.prototype.toString) {
|
|
2267
|
+
for (var key in arg) {
|
|
2268
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
2269
|
+
classes.push(key);
|
|
2270
|
+
}
|
|
2278
2271
|
}
|
|
2272
|
+
} else {
|
|
2273
|
+
classes.push(arg.toString());
|
|
2279
2274
|
}
|
|
2280
2275
|
}
|
|
2281
2276
|
}
|
|
@@ -10622,15 +10617,54 @@ var now$2 = function() {
|
|
|
10622
10617
|
|
|
10623
10618
|
var now_1 = now$2;
|
|
10624
10619
|
|
|
10625
|
-
|
|
10620
|
+
/** Used to match a single whitespace character. */
|
|
10621
|
+
|
|
10622
|
+
var reWhitespace = /\s/;
|
|
10623
|
+
|
|
10624
|
+
/**
|
|
10625
|
+
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
|
|
10626
|
+
* character of `string`.
|
|
10627
|
+
*
|
|
10628
|
+
* @private
|
|
10629
|
+
* @param {string} string The string to inspect.
|
|
10630
|
+
* @returns {number} Returns the index of the last non-whitespace character.
|
|
10631
|
+
*/
|
|
10632
|
+
function trimmedEndIndex$1(string) {
|
|
10633
|
+
var index = string.length;
|
|
10634
|
+
|
|
10635
|
+
while (index-- && reWhitespace.test(string.charAt(index))) {}
|
|
10636
|
+
return index;
|
|
10637
|
+
}
|
|
10638
|
+
|
|
10639
|
+
var _trimmedEndIndex = trimmedEndIndex$1;
|
|
10640
|
+
|
|
10641
|
+
var trimmedEndIndex = _trimmedEndIndex;
|
|
10642
|
+
|
|
10643
|
+
/** Used to match leading whitespace. */
|
|
10644
|
+
var reTrimStart = /^\s+/;
|
|
10645
|
+
|
|
10646
|
+
/**
|
|
10647
|
+
* The base implementation of `_.trim`.
|
|
10648
|
+
*
|
|
10649
|
+
* @private
|
|
10650
|
+
* @param {string} string The string to trim.
|
|
10651
|
+
* @returns {string} Returns the trimmed string.
|
|
10652
|
+
*/
|
|
10653
|
+
function baseTrim$1(string) {
|
|
10654
|
+
return string
|
|
10655
|
+
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
|
|
10656
|
+
: string;
|
|
10657
|
+
}
|
|
10658
|
+
|
|
10659
|
+
var _baseTrim = baseTrim$1;
|
|
10660
|
+
|
|
10661
|
+
var baseTrim = _baseTrim,
|
|
10662
|
+
isObject$2 = isObject_1,
|
|
10626
10663
|
isSymbol$1 = isSymbol_1;
|
|
10627
10664
|
|
|
10628
10665
|
/** Used as references for various `Number` constants. */
|
|
10629
10666
|
var NAN = 0 / 0;
|
|
10630
10667
|
|
|
10631
|
-
/** Used to match leading and trailing whitespace. */
|
|
10632
|
-
var reTrim = /^\s+|\s+$/g;
|
|
10633
|
-
|
|
10634
10668
|
/** Used to detect bad signed hexadecimal string values. */
|
|
10635
10669
|
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
10636
10670
|
|
|
@@ -10680,7 +10714,7 @@ function toNumber$2(value) {
|
|
|
10680
10714
|
if (typeof value != 'string') {
|
|
10681
10715
|
return value === 0 ? value : +value;
|
|
10682
10716
|
}
|
|
10683
|
-
value = value
|
|
10717
|
+
value = baseTrim(value);
|
|
10684
10718
|
var isBinary = reIsBinary.test(value);
|
|
10685
10719
|
return (isBinary || reIsOctal.test(value))
|
|
10686
10720
|
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
|
@@ -11004,6 +11038,9 @@ function range$3(a, b, str) {
|
|
|
11004
11038
|
var i = ai;
|
|
11005
11039
|
|
|
11006
11040
|
if (ai >= 0 && bi > 0) {
|
|
11041
|
+
if(a===b) {
|
|
11042
|
+
return [ai, bi];
|
|
11043
|
+
}
|
|
11007
11044
|
begs = [];
|
|
11008
11045
|
left = str.length;
|
|
11009
11046
|
|
|
@@ -12600,10 +12637,6 @@ function flatMap(collection, iteratee) {
|
|
|
12600
12637
|
|
|
12601
12638
|
var flatMap_1 = flatMap;
|
|
12602
12639
|
|
|
12603
|
-
var lib = {};
|
|
12604
|
-
|
|
12605
|
-
var getNiceTickValues$1 = {};
|
|
12606
|
-
|
|
12607
12640
|
/*
|
|
12608
12641
|
* decimal.js-light v2.5.1
|
|
12609
12642
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
@@ -14590,28 +14623,17 @@ ONE = new Decimal(1);
|
|
|
14590
14623
|
|
|
14591
14624
|
var Decimal$1 = Decimal;
|
|
14592
14625
|
|
|
14593
|
-
|
|
14594
|
-
__proto__: null,
|
|
14595
|
-
get Decimal () { return Decimal; },
|
|
14596
|
-
'default': Decimal$1
|
|
14597
|
-
});
|
|
14626
|
+
function _toConsumableArray$5(arr) { return _arrayWithoutHoles$5(arr) || _iterableToArray$5(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$5(); }
|
|
14598
14627
|
|
|
14599
|
-
|
|
14628
|
+
function _nonIterableSpread$5() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14600
14629
|
|
|
14601
|
-
var
|
|
14630
|
+
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
|
14602
14631
|
|
|
14603
|
-
|
|
14604
|
-
value: true
|
|
14605
|
-
});
|
|
14606
|
-
utils.memoize = utils.reverse = utils.compose = utils.map = utils.range = utils.curry = utils.PLACE_HOLDER = void 0;
|
|
14607
|
-
|
|
14608
|
-
function _toConsumableArray$5(arr) { return _arrayWithoutHoles$5(arr) || _iterableToArray$5(arr) || _nonIterableSpread$5(); }
|
|
14632
|
+
function _iterableToArray$5(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
14609
14633
|
|
|
14610
|
-
function
|
|
14634
|
+
function _arrayWithoutHoles$5(arr) { if (Array.isArray(arr)) return _arrayLikeToArray$1(arr); }
|
|
14611
14635
|
|
|
14612
|
-
function
|
|
14613
|
-
|
|
14614
|
-
function _arrayWithoutHoles$5(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
|
14636
|
+
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14615
14637
|
|
|
14616
14638
|
var identity$4 = function identity(i) {
|
|
14617
14639
|
return i;
|
|
@@ -14620,7 +14642,6 @@ var identity$4 = function identity(i) {
|
|
|
14620
14642
|
var PLACE_HOLDER = {
|
|
14621
14643
|
'@@functional/placeholder': true
|
|
14622
14644
|
};
|
|
14623
|
-
utils.PLACE_HOLDER = PLACE_HOLDER;
|
|
14624
14645
|
|
|
14625
14646
|
var isPlaceHolder = function isPlaceHolder(val) {
|
|
14626
14647
|
return val === PLACE_HOLDER;
|
|
@@ -14670,9 +14691,6 @@ var curryN = function curryN(n, fn) {
|
|
|
14670
14691
|
var curry = function curry(fn) {
|
|
14671
14692
|
return curryN(fn.length, fn);
|
|
14672
14693
|
};
|
|
14673
|
-
|
|
14674
|
-
utils.curry = curry;
|
|
14675
|
-
|
|
14676
14694
|
var range$2 = function range(begin, end) {
|
|
14677
14695
|
var arr = [];
|
|
14678
14696
|
|
|
@@ -14682,8 +14700,6 @@ var range$2 = function range(begin, end) {
|
|
|
14682
14700
|
|
|
14683
14701
|
return arr;
|
|
14684
14702
|
};
|
|
14685
|
-
|
|
14686
|
-
utils.range = range$2;
|
|
14687
14703
|
var map$3 = curry(function (fn, arr) {
|
|
14688
14704
|
if (Array.isArray(arr)) {
|
|
14689
14705
|
return arr.map(fn);
|
|
@@ -14693,8 +14709,6 @@ var map$3 = curry(function (fn, arr) {
|
|
|
14693
14709
|
return arr[key];
|
|
14694
14710
|
}).map(fn);
|
|
14695
14711
|
});
|
|
14696
|
-
utils.map = map$3;
|
|
14697
|
-
|
|
14698
14712
|
var compose = function compose() {
|
|
14699
14713
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
14700
14714
|
args[_key3] = arguments[_key3];
|
|
@@ -14714,9 +14728,6 @@ var compose = function compose() {
|
|
|
14714
14728
|
}, firstFn.apply(void 0, arguments));
|
|
14715
14729
|
};
|
|
14716
14730
|
};
|
|
14717
|
-
|
|
14718
|
-
utils.compose = compose;
|
|
14719
|
-
|
|
14720
14731
|
var reverse = function reverse(arr) {
|
|
14721
14732
|
if (Array.isArray(arr)) {
|
|
14722
14733
|
return arr.reverse();
|
|
@@ -14725,9 +14736,6 @@ var reverse = function reverse(arr) {
|
|
|
14725
14736
|
|
|
14726
14737
|
return arr.split('').reverse.join('');
|
|
14727
14738
|
};
|
|
14728
|
-
|
|
14729
|
-
utils.reverse = reverse;
|
|
14730
|
-
|
|
14731
14739
|
var memoize = function memoize(fn) {
|
|
14732
14740
|
var lastArgs = null;
|
|
14733
14741
|
var lastResult = null;
|
|
@@ -14748,27 +14756,11 @@ var memoize = function memoize(fn) {
|
|
|
14748
14756
|
};
|
|
14749
14757
|
};
|
|
14750
14758
|
|
|
14751
|
-
utils.memoize = memoize;
|
|
14752
|
-
|
|
14753
|
-
var arithmetic = {};
|
|
14754
|
-
|
|
14755
|
-
Object.defineProperty(arithmetic, "__esModule", {
|
|
14756
|
-
value: true
|
|
14757
|
-
});
|
|
14758
|
-
arithmetic.default = void 0;
|
|
14759
|
-
|
|
14760
|
-
var _decimal$1 = _interopRequireDefault$1(require$$0);
|
|
14761
|
-
|
|
14762
|
-
var _utils$1 = utils;
|
|
14763
|
-
|
|
14764
|
-
function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14765
|
-
|
|
14766
14759
|
/**
|
|
14767
14760
|
* @fileOverview 一些公用的运算方法
|
|
14768
14761
|
* @author xile611
|
|
14769
14762
|
* @date 2015-09-17
|
|
14770
14763
|
*/
|
|
14771
|
-
|
|
14772
14764
|
/**
|
|
14773
14765
|
* 获取数值的位数
|
|
14774
14766
|
* 其中绝对值属于区间[0.1, 1), 得到的值为0
|
|
@@ -14778,13 +14770,14 @@ function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : {
|
|
|
14778
14770
|
* @param {Number} value 数值
|
|
14779
14771
|
* @return {Integer} 位数
|
|
14780
14772
|
*/
|
|
14773
|
+
|
|
14781
14774
|
function getDigitCount(value) {
|
|
14782
14775
|
var result;
|
|
14783
14776
|
|
|
14784
14777
|
if (value === 0) {
|
|
14785
14778
|
result = 1;
|
|
14786
14779
|
} else {
|
|
14787
|
-
result = Math.floor(new
|
|
14780
|
+
result = Math.floor(new Decimal$1(value).abs().log(10).toNumber()) + 1;
|
|
14788
14781
|
}
|
|
14789
14782
|
|
|
14790
14783
|
return result;
|
|
@@ -14801,7 +14794,7 @@ function getDigitCount(value) {
|
|
|
14801
14794
|
|
|
14802
14795
|
|
|
14803
14796
|
function rangeStep(start, end, step) {
|
|
14804
|
-
var num = new
|
|
14797
|
+
var num = new Decimal$1(start);
|
|
14805
14798
|
var i = 0;
|
|
14806
14799
|
var result = []; // magic number to prevent infinite loop
|
|
14807
14800
|
|
|
@@ -14823,7 +14816,7 @@ function rangeStep(start, end, step) {
|
|
|
14823
14816
|
*/
|
|
14824
14817
|
|
|
14825
14818
|
|
|
14826
|
-
var interpolateNumber$1 =
|
|
14819
|
+
var interpolateNumber$1 = curry(function (a, b, t) {
|
|
14827
14820
|
var newA = +a;
|
|
14828
14821
|
var newB = +b;
|
|
14829
14822
|
return newA + t * (newB - newA);
|
|
@@ -14837,7 +14830,7 @@ var interpolateNumber$1 = (0, _utils$1.curry)(function (a, b, t) {
|
|
|
14837
14830
|
* @return {Number} 当x在 a ~ b这个范围内时,返回值属于[0, 1]
|
|
14838
14831
|
*/
|
|
14839
14832
|
|
|
14840
|
-
var uninterpolateNumber =
|
|
14833
|
+
var uninterpolateNumber = curry(function (a, b, x) {
|
|
14841
14834
|
var diff = b - +a;
|
|
14842
14835
|
diff = diff || Infinity;
|
|
14843
14836
|
return (x - a) / diff;
|
|
@@ -14852,49 +14845,38 @@ var uninterpolateNumber = (0, _utils$1.curry)(function (a, b, x) {
|
|
|
14852
14845
|
* 当x不在 a ~ b这个区间时,会截断到 a ~ b 这个区间
|
|
14853
14846
|
*/
|
|
14854
14847
|
|
|
14855
|
-
var uninterpolateTruncation =
|
|
14848
|
+
var uninterpolateTruncation = curry(function (a, b, x) {
|
|
14856
14849
|
var diff = b - +a;
|
|
14857
14850
|
diff = diff || Infinity;
|
|
14858
14851
|
return Math.max(0, Math.min(1, (x - a) / diff));
|
|
14859
14852
|
});
|
|
14860
|
-
var
|
|
14853
|
+
var Arithmetic = {
|
|
14861
14854
|
rangeStep: rangeStep,
|
|
14862
14855
|
getDigitCount: getDigitCount,
|
|
14863
14856
|
interpolateNumber: interpolateNumber$1,
|
|
14864
14857
|
uninterpolateNumber: uninterpolateNumber,
|
|
14865
14858
|
uninterpolateTruncation: uninterpolateTruncation
|
|
14866
14859
|
};
|
|
14867
|
-
arithmetic.default = _default;
|
|
14868
|
-
|
|
14869
|
-
Object.defineProperty(getNiceTickValues$1, "__esModule", {
|
|
14870
|
-
value: true
|
|
14871
|
-
});
|
|
14872
|
-
getNiceTickValues$1.getTickValuesFixedDomain = getNiceTickValues$1.getTickValues = getNiceTickValues$1.getNiceTickValues = void 0;
|
|
14873
|
-
|
|
14874
|
-
var _decimal = _interopRequireDefault(require$$0);
|
|
14875
14860
|
|
|
14876
|
-
|
|
14861
|
+
function _toConsumableArray$4(arr) { return _arrayWithoutHoles$4(arr) || _iterableToArray$4(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread$4(); }
|
|
14877
14862
|
|
|
14878
|
-
|
|
14863
|
+
function _nonIterableSpread$4() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14879
14864
|
|
|
14880
|
-
function
|
|
14865
|
+
function _iterableToArray$4(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
14881
14866
|
|
|
14882
|
-
function
|
|
14867
|
+
function _arrayWithoutHoles$4(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
14883
14868
|
|
|
14884
|
-
function
|
|
14869
|
+
function _slicedToArray$2(arr, i) { return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest$2(); }
|
|
14885
14870
|
|
|
14886
|
-
function
|
|
14871
|
+
function _nonIterableRest$2() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14887
14872
|
|
|
14888
|
-
function
|
|
14873
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14889
14874
|
|
|
14890
|
-
function
|
|
14875
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14891
14876
|
|
|
14892
|
-
function
|
|
14893
|
-
|
|
14894
|
-
function _iterableToArrayLimit$2(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
14877
|
+
function _iterableToArrayLimit$2(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
14895
14878
|
|
|
14896
14879
|
function _arrayWithHoles$2(arr) { if (Array.isArray(arr)) return arr; }
|
|
14897
|
-
|
|
14898
14880
|
/**
|
|
14899
14881
|
* Calculate a interval of a minimum value and a maximum value
|
|
14900
14882
|
*
|
|
@@ -14902,6 +14884,7 @@ function _arrayWithHoles$2(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
14902
14884
|
* @param {Number} max The maximum value
|
|
14903
14885
|
* @return {Array} An interval
|
|
14904
14886
|
*/
|
|
14887
|
+
|
|
14905
14888
|
function getValidInterval(_ref) {
|
|
14906
14889
|
var _ref2 = _slicedToArray$2(_ref, 2),
|
|
14907
14890
|
min = _ref2[0],
|
|
@@ -14930,20 +14913,19 @@ function getValidInterval(_ref) {
|
|
|
14930
14913
|
|
|
14931
14914
|
function getFormatStep(roughStep, allowDecimals, correctionFactor) {
|
|
14932
14915
|
if (roughStep.lte(0)) {
|
|
14933
|
-
return new
|
|
14916
|
+
return new Decimal$1(0);
|
|
14934
14917
|
}
|
|
14935
14918
|
|
|
14936
|
-
var digitCount =
|
|
14919
|
+
var digitCount = Arithmetic.getDigitCount(roughStep.toNumber()); // The ratio between the rough step and the smallest number which has a bigger
|
|
14937
14920
|
// order of magnitudes than the rough step
|
|
14938
14921
|
|
|
14939
|
-
|
|
14940
|
-
var digitCountValue = new _decimal.default(10).pow(digitCount);
|
|
14922
|
+
var digitCountValue = new Decimal$1(10).pow(digitCount);
|
|
14941
14923
|
var stepRatio = roughStep.div(digitCountValue); // When an integer and a float multiplied, the accuracy of result may be wrong
|
|
14942
14924
|
|
|
14943
14925
|
var stepRatioScale = digitCount !== 1 ? 0.05 : 0.1;
|
|
14944
|
-
var amendStepRatio = new
|
|
14926
|
+
var amendStepRatio = new Decimal$1(Math.ceil(stepRatio.div(stepRatioScale).toNumber())).add(correctionFactor).mul(stepRatioScale);
|
|
14945
14927
|
var formatStep = amendStepRatio.mul(digitCountValue);
|
|
14946
|
-
return allowDecimals ? formatStep : new
|
|
14928
|
+
return allowDecimals ? formatStep : new Decimal$1(Math.ceil(formatStep));
|
|
14947
14929
|
}
|
|
14948
14930
|
/**
|
|
14949
14931
|
* calculate the ticks when the minimum value equals to the maximum value
|
|
@@ -14958,29 +14940,29 @@ function getFormatStep(roughStep, allowDecimals, correctionFactor) {
|
|
|
14958
14940
|
function getTickOfSingleValue(value, tickCount, allowDecimals) {
|
|
14959
14941
|
var step = 1; // calculate the middle value of ticks
|
|
14960
14942
|
|
|
14961
|
-
var middle = new
|
|
14943
|
+
var middle = new Decimal$1(value);
|
|
14962
14944
|
|
|
14963
14945
|
if (!middle.isint() && allowDecimals) {
|
|
14964
14946
|
var absVal = Math.abs(value);
|
|
14965
14947
|
|
|
14966
14948
|
if (absVal < 1) {
|
|
14967
14949
|
// The step should be a float number when the difference is smaller than 1
|
|
14968
|
-
step = new
|
|
14969
|
-
middle = new
|
|
14950
|
+
step = new Decimal$1(10).pow(Arithmetic.getDigitCount(value) - 1);
|
|
14951
|
+
middle = new Decimal$1(Math.floor(middle.div(step).toNumber())).mul(step);
|
|
14970
14952
|
} else if (absVal > 1) {
|
|
14971
14953
|
// Return the maximum integer which is smaller than 'value' when 'value' is greater than 1
|
|
14972
|
-
middle = new
|
|
14954
|
+
middle = new Decimal$1(Math.floor(value));
|
|
14973
14955
|
}
|
|
14974
14956
|
} else if (value === 0) {
|
|
14975
|
-
middle = new
|
|
14957
|
+
middle = new Decimal$1(Math.floor((tickCount - 1) / 2));
|
|
14976
14958
|
} else if (!allowDecimals) {
|
|
14977
|
-
middle = new
|
|
14959
|
+
middle = new Decimal$1(Math.floor(value));
|
|
14978
14960
|
}
|
|
14979
14961
|
|
|
14980
14962
|
var middleIndex = Math.floor((tickCount - 1) / 2);
|
|
14981
|
-
var fn =
|
|
14982
|
-
return middle.add(new
|
|
14983
|
-
}),
|
|
14963
|
+
var fn = compose(map$3(function (n) {
|
|
14964
|
+
return middle.add(new Decimal$1(n - middleIndex).mul(step)).toNumber();
|
|
14965
|
+
}), range$2);
|
|
14984
14966
|
return fn(0, tickCount);
|
|
14985
14967
|
}
|
|
14986
14968
|
/**
|
|
@@ -15001,28 +14983,28 @@ function calculateStep(min, max, tickCount, allowDecimals) {
|
|
|
15001
14983
|
// dirty hack (for recharts' test)
|
|
15002
14984
|
if (!Number.isFinite((max - min) / (tickCount - 1))) {
|
|
15003
14985
|
return {
|
|
15004
|
-
step: new
|
|
15005
|
-
tickMin: new
|
|
15006
|
-
tickMax: new
|
|
14986
|
+
step: new Decimal$1(0),
|
|
14987
|
+
tickMin: new Decimal$1(0),
|
|
14988
|
+
tickMax: new Decimal$1(0)
|
|
15007
14989
|
};
|
|
15008
14990
|
} // The step which is easy to understand between two ticks
|
|
15009
14991
|
|
|
15010
14992
|
|
|
15011
|
-
var step = getFormatStep(new
|
|
14993
|
+
var step = getFormatStep(new Decimal$1(max).sub(min).div(tickCount - 1), allowDecimals, correctionFactor); // A medial value of ticks
|
|
15012
14994
|
|
|
15013
14995
|
var middle; // When 0 is inside the interval, 0 should be a tick
|
|
15014
14996
|
|
|
15015
14997
|
if (min <= 0 && max >= 0) {
|
|
15016
|
-
middle = new
|
|
14998
|
+
middle = new Decimal$1(0);
|
|
15017
14999
|
} else {
|
|
15018
15000
|
// calculate the middle value
|
|
15019
|
-
middle = new
|
|
15001
|
+
middle = new Decimal$1(min).add(max).div(2); // minus modulo value
|
|
15020
15002
|
|
|
15021
|
-
middle = middle.sub(new
|
|
15003
|
+
middle = middle.sub(new Decimal$1(middle).mod(step));
|
|
15022
15004
|
}
|
|
15023
15005
|
|
|
15024
15006
|
var belowCount = Math.ceil(middle.sub(min).div(step).toNumber());
|
|
15025
|
-
var upCount = Math.ceil(new
|
|
15007
|
+
var upCount = Math.ceil(new Decimal$1(max).sub(middle).div(step).toNumber());
|
|
15026
15008
|
var scaleCount = belowCount + upCount + 1;
|
|
15027
15009
|
|
|
15028
15010
|
if (scaleCount > tickCount) {
|
|
@@ -15038,8 +15020,8 @@ function calculateStep(min, max, tickCount, allowDecimals) {
|
|
|
15038
15020
|
|
|
15039
15021
|
return {
|
|
15040
15022
|
step: step,
|
|
15041
|
-
tickMin: middle.sub(new
|
|
15042
|
-
tickMax: middle.add(new
|
|
15023
|
+
tickMin: middle.sub(new Decimal$1(belowCount).mul(step)),
|
|
15024
|
+
tickMax: middle.add(new Decimal$1(upCount).mul(step))
|
|
15043
15025
|
};
|
|
15044
15026
|
}
|
|
15045
15027
|
/**
|
|
@@ -15068,13 +15050,13 @@ function getNiceTickValuesFn(_ref3) {
|
|
|
15068
15050
|
cormax = _getValidInterval2[1];
|
|
15069
15051
|
|
|
15070
15052
|
if (cormin === -Infinity || cormax === Infinity) {
|
|
15071
|
-
var _values = cormax === Infinity ? [cormin].concat(_toConsumableArray$4(
|
|
15053
|
+
var _values = cormax === Infinity ? [cormin].concat(_toConsumableArray$4(range$2(0, tickCount - 1).map(function () {
|
|
15072
15054
|
return Infinity;
|
|
15073
|
-
}))) : _toConsumableArray$4(
|
|
15055
|
+
}))) : [].concat(_toConsumableArray$4(range$2(0, tickCount - 1).map(function () {
|
|
15074
15056
|
return -Infinity;
|
|
15075
|
-
}))
|
|
15057
|
+
})), [cormax]);
|
|
15076
15058
|
|
|
15077
|
-
return min > max ?
|
|
15059
|
+
return min > max ? reverse(_values) : _values;
|
|
15078
15060
|
}
|
|
15079
15061
|
|
|
15080
15062
|
if (cormin === cormax) {
|
|
@@ -15087,51 +15069,8 @@ function getNiceTickValuesFn(_ref3) {
|
|
|
15087
15069
|
tickMin = _calculateStep.tickMin,
|
|
15088
15070
|
tickMax = _calculateStep.tickMax;
|
|
15089
15071
|
|
|
15090
|
-
var values =
|
|
15091
|
-
|
|
15092
|
-
return min > max ? (0, _utils.reverse)(values) : values;
|
|
15093
|
-
}
|
|
15094
|
-
/**
|
|
15095
|
-
* Calculate the ticks of an interval, the count of ticks won't be guraranteed
|
|
15096
|
-
*
|
|
15097
|
-
* @param {Number} min, max min: The minimum value, max: The maximum value
|
|
15098
|
-
* @param {Integer} tickCount The count of ticks
|
|
15099
|
-
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
|
|
15100
|
-
* @return {Array} ticks
|
|
15101
|
-
*/
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
function getTickValuesFn(_ref5) {
|
|
15105
|
-
var _ref6 = _slicedToArray$2(_ref5, 2),
|
|
15106
|
-
min = _ref6[0],
|
|
15107
|
-
max = _ref6[1];
|
|
15108
|
-
|
|
15109
|
-
var tickCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
|
|
15110
|
-
var allowDecimals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
15111
|
-
// More than two ticks should be return
|
|
15112
|
-
var count = Math.max(tickCount, 2);
|
|
15113
|
-
|
|
15114
|
-
var _getValidInterval3 = getValidInterval([min, max]),
|
|
15115
|
-
_getValidInterval4 = _slicedToArray$2(_getValidInterval3, 2),
|
|
15116
|
-
cormin = _getValidInterval4[0],
|
|
15117
|
-
cormax = _getValidInterval4[1];
|
|
15118
|
-
|
|
15119
|
-
if (cormin === -Infinity || cormax === Infinity) {
|
|
15120
|
-
return [min, max];
|
|
15121
|
-
}
|
|
15122
|
-
|
|
15123
|
-
if (cormin === cormax) {
|
|
15124
|
-
return getTickOfSingleValue(cormin, tickCount, allowDecimals);
|
|
15125
|
-
}
|
|
15126
|
-
|
|
15127
|
-
var step = getFormatStep(new _decimal.default(cormax).sub(cormin).div(count - 1), allowDecimals, 0);
|
|
15128
|
-
var fn = (0, _utils.compose)((0, _utils.map)(function (n) {
|
|
15129
|
-
return new _decimal.default(cormin).add(new _decimal.default(n).mul(step)).toNumber();
|
|
15130
|
-
}), _utils.range);
|
|
15131
|
-
var values = fn(0, count).filter(function (entry) {
|
|
15132
|
-
return entry >= cormin && entry <= cormax;
|
|
15133
|
-
});
|
|
15134
|
-
return min > max ? (0, _utils.reverse)(values) : values;
|
|
15072
|
+
var values = Arithmetic.rangeStep(tickMin, tickMax.add(new Decimal$1(0.1).mul(step)), step);
|
|
15073
|
+
return min > max ? reverse(values) : values;
|
|
15135
15074
|
}
|
|
15136
15075
|
/**
|
|
15137
15076
|
* Calculate the ticks of an interval, the count of ticks won't be guraranteed,
|
|
@@ -15166,46 +15105,13 @@ function getTickValuesFixedDomainFn(_ref7, tickCount) {
|
|
|
15166
15105
|
}
|
|
15167
15106
|
|
|
15168
15107
|
var count = Math.max(tickCount, 2);
|
|
15169
|
-
var step = getFormatStep(new
|
|
15170
|
-
|
|
15171
|
-
|
|
15172
|
-
|
|
15173
|
-
return min > max ? (0, _utils.reverse)(values) : values;
|
|
15108
|
+
var step = getFormatStep(new Decimal$1(cormax).sub(cormin).div(count - 1), allowDecimals, 0);
|
|
15109
|
+
var values = [].concat(_toConsumableArray$4(Arithmetic.rangeStep(new Decimal$1(cormin), new Decimal$1(cormax).sub(new Decimal$1(0.99).mul(step)), step)), [cormax]);
|
|
15110
|
+
return min > max ? reverse(values) : values;
|
|
15174
15111
|
}
|
|
15175
15112
|
|
|
15176
|
-
var getNiceTickValues =
|
|
15177
|
-
|
|
15178
|
-
var getTickValues = (0, _utils.memoize)(getTickValuesFn);
|
|
15179
|
-
getNiceTickValues$1.getTickValues = getTickValues;
|
|
15180
|
-
var getTickValuesFixedDomain = (0, _utils.memoize)(getTickValuesFixedDomainFn);
|
|
15181
|
-
getNiceTickValues$1.getTickValuesFixedDomain = getTickValuesFixedDomain;
|
|
15182
|
-
|
|
15183
|
-
(function (exports) {
|
|
15184
|
-
|
|
15185
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15186
|
-
value: true
|
|
15187
|
-
});
|
|
15188
|
-
Object.defineProperty(exports, "getTickValues", {
|
|
15189
|
-
enumerable: true,
|
|
15190
|
-
get: function get() {
|
|
15191
|
-
return _getNiceTickValues.getTickValues;
|
|
15192
|
-
}
|
|
15193
|
-
});
|
|
15194
|
-
Object.defineProperty(exports, "getNiceTickValues", {
|
|
15195
|
-
enumerable: true,
|
|
15196
|
-
get: function get() {
|
|
15197
|
-
return _getNiceTickValues.getNiceTickValues;
|
|
15198
|
-
}
|
|
15199
|
-
});
|
|
15200
|
-
Object.defineProperty(exports, "getTickValuesFixedDomain", {
|
|
15201
|
-
enumerable: true,
|
|
15202
|
-
get: function get() {
|
|
15203
|
-
return _getNiceTickValues.getTickValuesFixedDomain;
|
|
15204
|
-
}
|
|
15205
|
-
});
|
|
15206
|
-
|
|
15207
|
-
var _getNiceTickValues = getNiceTickValues$1;
|
|
15208
|
-
}(lib));
|
|
15113
|
+
var getNiceTickValues = memoize(getNiceTickValuesFn);
|
|
15114
|
+
var getTickValuesFixedDomain = memoize(getTickValuesFixedDomainFn);
|
|
15209
15115
|
|
|
15210
15116
|
function ascending$1(a, b) {
|
|
15211
15117
|
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
@@ -19611,7 +19517,7 @@ var getTicksOfScale = function getTicksOfScale(scale, opts) {
|
|
|
19611
19517
|
if (tickCount && type === 'number' && originalDomain && (originalDomain[0] === 'auto' || originalDomain[1] === 'auto')) {
|
|
19612
19518
|
// Calculate the ticks by the number of grid when the axis is a number axis
|
|
19613
19519
|
var domain = scale.domain();
|
|
19614
|
-
var tickValues =
|
|
19520
|
+
var tickValues = getNiceTickValues(domain, tickCount, allowDecimals);
|
|
19615
19521
|
scale.domain(calculateDomainOfTicks(tickValues, type));
|
|
19616
19522
|
return {
|
|
19617
19523
|
niceTicks: tickValues
|
|
@@ -19621,7 +19527,7 @@ var getTicksOfScale = function getTicksOfScale(scale, opts) {
|
|
|
19621
19527
|
if (tickCount && type === 'number') {
|
|
19622
19528
|
var _domain = scale.domain();
|
|
19623
19529
|
|
|
19624
|
-
var _tickValues =
|
|
19530
|
+
var _tickValues = getTickValuesFixedDomain(_domain, tickCount, allowDecimals);
|
|
19625
19531
|
|
|
19626
19532
|
return {
|
|
19627
19533
|
niceTicks: _tickValues
|
|
@@ -27121,128 +27027,6 @@ var RechartsBarChart = generateCategoricalChart({
|
|
|
27121
27027
|
formatAxisMap: formatAxisMap
|
|
27122
27028
|
});
|
|
27123
27029
|
|
|
27124
|
-
var fontFamily = "Source Sans Pro,Helvetica,Arial,sans-serif";
|
|
27125
|
-
/**
|
|
27126
|
-
* Creates a percentage axis tick on the X axis with proper styling.
|
|
27127
|
-
* Can be passed to tick in the XAxis Recharts component within SpsBarChart.
|
|
27128
|
-
* @param payload - Payload containing value to be displayed, provided by Recharts.
|
|
27129
|
-
* @param x - X value for placement on the SVG, provided by Recharts.
|
|
27130
|
-
* @param y - Y value for placement on the SVG, provided by Recharts.
|
|
27131
|
-
*/
|
|
27132
|
-
var PercentXAxisTick = function (_a) {
|
|
27133
|
-
var payload = _a.payload, x = _a.x, y = _a.y;
|
|
27134
|
-
return (React__namespace.createElement(Text, { verticalAnchor: "start", width: 30, height: 30, x: x, y: y, stroke: "none", textAnchor: "middle", style: {
|
|
27135
|
-
fill: dsColors.colors.gray500,
|
|
27136
|
-
fontFamily: fontFamily,
|
|
27137
|
-
fontWeight: 400,
|
|
27138
|
-
} }, payload.value.toString() + "%"));
|
|
27139
|
-
};
|
|
27140
|
-
/**
|
|
27141
|
-
* Creates axis tick on the X axis with proper styling.
|
|
27142
|
-
* Can be passed to tick in the XAxis Recharts component within SpsBarChart.
|
|
27143
|
-
* Is the default X Axis tick in SpsBarChart.
|
|
27144
|
-
* @param payload - Payload containing value to be displayed, provided by Recharts.
|
|
27145
|
-
* @param x - X value for placement on the SVG, provided by Recharts.
|
|
27146
|
-
* @param y - Y value for placement on the SVG, provided by Recharts.
|
|
27147
|
-
*/
|
|
27148
|
-
var SpsDefaultXAxisTick = function (_a) {
|
|
27149
|
-
var payload = _a.payload, x = _a.x, y = _a.y;
|
|
27150
|
-
return (React__namespace.createElement("text", { x: x, y: y, dy: "0.75rem", stroke: "none", textAnchor: "middle", style: {
|
|
27151
|
-
fill: dsColors.colors.gray500,
|
|
27152
|
-
fontFamily: fontFamily,
|
|
27153
|
-
fontWeight: 400,
|
|
27154
|
-
}, className: "default-x-axis" }, payload.value.toString()));
|
|
27155
|
-
};
|
|
27156
|
-
/**
|
|
27157
|
-
* Creates axis tick on the Y axis with proper styling.
|
|
27158
|
-
* Can be passed to tick in the YAxis Recharts component within SpsBarChart.
|
|
27159
|
-
* Is the default Y Axis tick in SpsBarChart
|
|
27160
|
-
* @param payload - Payload containing value to be displayed, provided by Recharts.
|
|
27161
|
-
* @param x - X value for placement on the SVG, provided by Recharts.
|
|
27162
|
-
* @param y - Y value for placement on the SVG, provided by Recharts.
|
|
27163
|
-
*/
|
|
27164
|
-
var SpsDefaultYAxisTick = function (_a) {
|
|
27165
|
-
var payload = _a.payload, x = _a.x, y = _a.y;
|
|
27166
|
-
return (React__namespace.createElement("text", { x: x, y: y, stroke: "none", textAnchor: "end", style: {
|
|
27167
|
-
fill: dsColors.colors.gray500,
|
|
27168
|
-
fontFamily: fontFamily,
|
|
27169
|
-
fontWeight: 500,
|
|
27170
|
-
}, className: "default-y-axis" }, payload.value.toString()));
|
|
27171
|
-
};
|
|
27172
|
-
/**
|
|
27173
|
-
* The tooltip for each bar rendered with proper styling.
|
|
27174
|
-
* Is passed into the toolTipWrapper from the ToolTipHandler.
|
|
27175
|
-
* Is the default customTooltip in SpsBarChart
|
|
27176
|
-
* @param descriptions - Array containing any toolTip content wanted.
|
|
27177
|
-
* Each entry is a new line.
|
|
27178
|
-
* @param label - Title of the toolTip, comes from the label provided in the ChartData.
|
|
27179
|
-
* @param width - Calculated width of the toolTip for positioning of the caret.
|
|
27180
|
-
*/
|
|
27181
|
-
var SpsDefaultChartTooltip = function (_a) {
|
|
27182
|
-
var descriptions = _a.descriptions, label = _a.label, width = _a.width;
|
|
27183
|
-
return (React__namespace.createElement("div", { style: {
|
|
27184
|
-
backgroundColor: dsColors.colors.gray600,
|
|
27185
|
-
color: dsColors.colors.white,
|
|
27186
|
-
fontSize: "0.875rem",
|
|
27187
|
-
width: "auto",
|
|
27188
|
-
height: "auto",
|
|
27189
|
-
padding: "1.25rem",
|
|
27190
|
-
borderRadius: ".1875rem",
|
|
27191
|
-
whiteSpace: "normal",
|
|
27192
|
-
} },
|
|
27193
|
-
React__namespace.createElement("span", { className: "sps-tooltip__title d-block" }, label),
|
|
27194
|
-
descriptions &&
|
|
27195
|
-
descriptions.map(function (data, index) {
|
|
27196
|
-
return (React__namespace.createElement("span", { key: index, className: "sps-tooltip__body d-block" }, data));
|
|
27197
|
-
}),
|
|
27198
|
-
React__namespace.createElement("span", { className: "sps-tooltip__caret", style: { bottom: "-0.313rem", left: width / 2 - 5 } })));
|
|
27199
|
-
};
|
|
27200
|
-
/**
|
|
27201
|
-
* Wraps the toolTip in a foreign object so HTML elements can be displayed and
|
|
27202
|
-
* positioned within the SVG. Calculates the width of the toolTip for positioning
|
|
27203
|
-
* relative to the corresponding bar.
|
|
27204
|
-
* @param x - X value of the corresponding bar.
|
|
27205
|
-
* @param barWidth - Width of corresponding bar, in px.
|
|
27206
|
-
* @param y - Y value of the corresponding bar.
|
|
27207
|
-
* @param isHorizontalBarChart - Whether or not the toolTip position should
|
|
27208
|
-
* be calculated for a horizontal graph.
|
|
27209
|
-
* @param customToolTip - Custom Tooltip to be wrapped and rendered.
|
|
27210
|
-
* @param chartData - Data to be provided to the toolTip
|
|
27211
|
-
*/
|
|
27212
|
-
var ToolTipWrapper = function (_a) {
|
|
27213
|
-
var x = _a.x, barWidth = _a.barWidth, y = _a.y, isHorizontalBarChart = _a.isHorizontalBarChart, customToolTip = _a.customToolTip, chartData = _a.chartData;
|
|
27214
|
-
var toolTip = React.useRef(null);
|
|
27215
|
-
var _b = __read(React.useState(0), 2), toolTipWidth = _b[0], setToolTipWidth = _b[1];
|
|
27216
|
-
React.useEffect(function () {
|
|
27217
|
-
var width = toolTip.current ? toolTip.current.offsetWidth : 0;
|
|
27218
|
-
setToolTipWidth(width);
|
|
27219
|
-
}, [toolTip.current]);
|
|
27220
|
-
if (isHorizontalBarChart) {
|
|
27221
|
-
return (React__namespace.createElement("g", null,
|
|
27222
|
-
React__namespace.createElement("foreignObject", { height: 300, width: 300, x: x + barWidth - toolTipWidth / 2, y: y - 300, textAnchor: "middle", style: { position: "relative" } },
|
|
27223
|
-
React__namespace.createElement("div", { style: {
|
|
27224
|
-
position: "absolute",
|
|
27225
|
-
bottom: "0.625rem",
|
|
27226
|
-
}, ref: toolTip }, React__namespace.cloneElement(customToolTip, {
|
|
27227
|
-
descriptions: chartData.descriptions,
|
|
27228
|
-
label: chartData.label,
|
|
27229
|
-
width: toolTipWidth,
|
|
27230
|
-
})))));
|
|
27231
|
-
}
|
|
27232
|
-
else {
|
|
27233
|
-
return (React__namespace.createElement("g", null,
|
|
27234
|
-
React__namespace.createElement("foreignObject", { height: 300, width: 300, x: x + barWidth / 2 - toolTipWidth / 2, y: y - 300, textAnchor: "middle", style: { position: "relative" } },
|
|
27235
|
-
React__namespace.createElement("div", { style: {
|
|
27236
|
-
position: "absolute",
|
|
27237
|
-
bottom: "0.625rem",
|
|
27238
|
-
}, ref: toolTip }, React__namespace.cloneElement(customToolTip, {
|
|
27239
|
-
descriptions: chartData.descriptions,
|
|
27240
|
-
label: chartData.label,
|
|
27241
|
-
width: toolTipWidth,
|
|
27242
|
-
})))));
|
|
27243
|
-
}
|
|
27244
|
-
};
|
|
27245
|
-
|
|
27246
27030
|
var noop = {value: function() {}};
|
|
27247
27031
|
|
|
27248
27032
|
function dispatch() {
|
|
@@ -29152,6 +28936,124 @@ function selection_transition(name) {
|
|
|
29152
28936
|
selection.prototype.interrupt = selection_interrupt;
|
|
29153
28937
|
selection.prototype.transition = selection_transition;
|
|
29154
28938
|
|
|
28939
|
+
var fontFamily = 'Source Sans Pro,Helvetica,Arial,sans-serif';
|
|
28940
|
+
/**
|
|
28941
|
+
* Creates a percentage axis tick on the X axis with proper styling.
|
|
28942
|
+
* Can be passed to tick in the XAxis Recharts component within SpsBarChart.
|
|
28943
|
+
* @param payload - Payload containing value to be displayed, provided by Recharts.
|
|
28944
|
+
* @param x - X value for placement on the SVG, provided by Recharts.
|
|
28945
|
+
* @param y - Y value for placement on the SVG, provided by Recharts.
|
|
28946
|
+
*/
|
|
28947
|
+
var PercentXAxisTick = function (_a) {
|
|
28948
|
+
var payload = _a.payload, x = _a.x, y = _a.y;
|
|
28949
|
+
return (React__namespace.createElement(Text, { verticalAnchor: "start", width: 30, height: 30, x: x, y: y, stroke: "none", textAnchor: "middle", style: {
|
|
28950
|
+
fill: dsColors.colors.gray500,
|
|
28951
|
+
fontFamily: fontFamily,
|
|
28952
|
+
fontWeight: 400,
|
|
28953
|
+
} }, payload.value.toString() + "%"));
|
|
28954
|
+
};
|
|
28955
|
+
/**
|
|
28956
|
+
* Creates axis tick on the X axis with proper styling.
|
|
28957
|
+
* Can be passed to tick in the XAxis Recharts component within SpsBarChart.
|
|
28958
|
+
* Is the default X Axis tick in SpsBarChart.
|
|
28959
|
+
* @param payload - Payload containing value to be displayed, provided by Recharts.
|
|
28960
|
+
* @param x - X value for placement on the SVG, provided by Recharts.
|
|
28961
|
+
* @param y - Y value for placement on the SVG, provided by Recharts.
|
|
28962
|
+
*/
|
|
28963
|
+
var SpsDefaultXAxisTick = function (_a) {
|
|
28964
|
+
var payload = _a.payload, x = _a.x, y = _a.y;
|
|
28965
|
+
return (React__namespace.createElement("text", { x: x, y: y, dy: "0.75rem", stroke: "none", textAnchor: "middle", style: {
|
|
28966
|
+
fill: dsColors.colors.gray500,
|
|
28967
|
+
fontFamily: fontFamily,
|
|
28968
|
+
fontWeight: 400,
|
|
28969
|
+
}, className: "default-x-axis" }, payload.value.toString()));
|
|
28970
|
+
};
|
|
28971
|
+
/**
|
|
28972
|
+
* Creates axis tick on the Y axis with proper styling.
|
|
28973
|
+
* Can be passed to tick in the YAxis Recharts component within SpsBarChart.
|
|
28974
|
+
* Is the default Y Axis tick in SpsBarChart
|
|
28975
|
+
* @param payload - Payload containing value to be displayed, provided by Recharts.
|
|
28976
|
+
* @param x - X value for placement on the SVG, provided by Recharts.
|
|
28977
|
+
* @param y - Y value for placement on the SVG, provided by Recharts.
|
|
28978
|
+
*/
|
|
28979
|
+
var SpsDefaultYAxisTick = function (_a) {
|
|
28980
|
+
var payload = _a.payload, x = _a.x, y = _a.y;
|
|
28981
|
+
return (React__namespace.createElement("text", { x: x, y: y, stroke: "none", textAnchor: "end", style: {
|
|
28982
|
+
fill: dsColors.colors.gray500,
|
|
28983
|
+
fontFamily: fontFamily,
|
|
28984
|
+
fontWeight: 500,
|
|
28985
|
+
}, className: "default-y-axis" }, payload.value.toString()));
|
|
28986
|
+
};
|
|
28987
|
+
/**
|
|
28988
|
+
* The tooltip for each bar rendered with proper styling.
|
|
28989
|
+
* Is passed into the toolTipWrapper from the ToolTipHandler.
|
|
28990
|
+
* Is the default customTooltip in SpsBarChart
|
|
28991
|
+
* @param descriptions - Array containing any toolTip content wanted.
|
|
28992
|
+
* Each entry is a new line.
|
|
28993
|
+
* @param label - Title of the toolTip, comes from the label provided in the ChartData.
|
|
28994
|
+
* @param width - Calculated width of the toolTip for positioning of the caret.
|
|
28995
|
+
*/
|
|
28996
|
+
var SpsDefaultChartTooltip = function (_a) {
|
|
28997
|
+
var descriptions = _a.descriptions, label = _a.label, width = _a.width;
|
|
28998
|
+
return (React__namespace.createElement("div", { style: {
|
|
28999
|
+
backgroundColor: dsColors.colors.gray600,
|
|
29000
|
+
color: dsColors.colors.white,
|
|
29001
|
+
fontSize: '0.875rem',
|
|
29002
|
+
width: 'auto',
|
|
29003
|
+
height: 'auto',
|
|
29004
|
+
padding: '1.25rem',
|
|
29005
|
+
borderRadius: '.1875rem',
|
|
29006
|
+
whiteSpace: 'normal',
|
|
29007
|
+
} },
|
|
29008
|
+
React__namespace.createElement("span", { className: "sps-tooltip__title d-block" }, label),
|
|
29009
|
+
descriptions
|
|
29010
|
+
&& descriptions.map(function (data, index) { return (React__namespace.createElement("span", { key: index, className: "sps-tooltip__body d-block" }, data)); }),
|
|
29011
|
+
React__namespace.createElement("span", { className: "sps-tooltip__caret", style: { bottom: '-0.313rem', left: width / 2 - 5 } })));
|
|
29012
|
+
};
|
|
29013
|
+
/**
|
|
29014
|
+
* Wraps the toolTip in a foreign object so HTML elements can be displayed and
|
|
29015
|
+
* positioned within the SVG. Calculates the width of the toolTip for positioning
|
|
29016
|
+
* relative to the corresponding bar.
|
|
29017
|
+
* @param x - X value of the corresponding bar.
|
|
29018
|
+
* @param barWidth - Width of corresponding bar, in px.
|
|
29019
|
+
* @param y - Y value of the corresponding bar.
|
|
29020
|
+
* @param isHorizontalBarChart - Whether or not the toolTip position should
|
|
29021
|
+
* be calculated for a horizontal graph.
|
|
29022
|
+
* @param customToolTip - Custom Tooltip to be wrapped and rendered.
|
|
29023
|
+
* @param chartData - Data to be provided to the toolTip
|
|
29024
|
+
*/
|
|
29025
|
+
var ToolTipWrapper = function (_a) {
|
|
29026
|
+
var x = _a.x, barWidth = _a.barWidth, y = _a.y, isHorizontalBarChart = _a.isHorizontalBarChart, customToolTip = _a.customToolTip, chartData = _a.chartData;
|
|
29027
|
+
var toolTip = React.useRef(null);
|
|
29028
|
+
var _b = __read(React.useState(0), 2), toolTipWidth = _b[0], setToolTipWidth = _b[1];
|
|
29029
|
+
React.useEffect(function () {
|
|
29030
|
+
var width = toolTip.current ? toolTip.current.offsetWidth : 0;
|
|
29031
|
+
setToolTipWidth(width);
|
|
29032
|
+
}, [toolTip.current]);
|
|
29033
|
+
if (isHorizontalBarChart) {
|
|
29034
|
+
return (React__namespace.createElement("g", null,
|
|
29035
|
+
React__namespace.createElement("foreignObject", { height: 300, width: 300, x: x + barWidth - toolTipWidth / 2, y: y - 300, textAnchor: "middle", style: { position: 'relative' } },
|
|
29036
|
+
React__namespace.createElement("div", { style: {
|
|
29037
|
+
position: 'absolute',
|
|
29038
|
+
bottom: '0.625rem',
|
|
29039
|
+
}, ref: toolTip }, React__namespace.cloneElement(customToolTip, {
|
|
29040
|
+
descriptions: chartData.descriptions,
|
|
29041
|
+
label: chartData.label,
|
|
29042
|
+
width: toolTipWidth,
|
|
29043
|
+
})))));
|
|
29044
|
+
}
|
|
29045
|
+
return (React__namespace.createElement("g", null,
|
|
29046
|
+
React__namespace.createElement("foreignObject", { height: 300, width: 300, x: x + barWidth / 2 - toolTipWidth / 2, y: y - 300, textAnchor: "middle", style: { position: 'relative' } },
|
|
29047
|
+
React__namespace.createElement("div", { style: {
|
|
29048
|
+
position: 'absolute',
|
|
29049
|
+
bottom: '0.625rem',
|
|
29050
|
+
}, ref: toolTip }, React__namespace.cloneElement(customToolTip, {
|
|
29051
|
+
descriptions: chartData.descriptions,
|
|
29052
|
+
label: chartData.label,
|
|
29053
|
+
width: toolTipWidth,
|
|
29054
|
+
})))));
|
|
29055
|
+
};
|
|
29056
|
+
|
|
29155
29057
|
var defaultLineHeight = 1.1; // ems,
|
|
29156
29058
|
var defaultDY = 0.275; // ems
|
|
29157
29059
|
var twoLinesDY = defaultDY * -1;
|
|
@@ -29169,39 +29071,41 @@ var wrapText = function (textGroup, width, isYAxis) {
|
|
|
29169
29071
|
textGroup.each(function () {
|
|
29170
29072
|
var text = select(this);
|
|
29171
29073
|
var words = text.text().split(/\s+/).reverse();
|
|
29172
|
-
var word
|
|
29074
|
+
var word;
|
|
29075
|
+
var line = [];
|
|
29076
|
+
var lineNumber = 0;
|
|
29173
29077
|
var lineNumberLimit = isYAxis ? 2 : 3;
|
|
29174
29078
|
var lineHeight = defaultLineHeight;
|
|
29175
|
-
var x = text.attr(
|
|
29176
|
-
var y = text.attr(
|
|
29177
|
-
var dy = parseFloat(text.attr(
|
|
29079
|
+
var x = text.attr('x') ? text.attr('x') : 0;
|
|
29080
|
+
var y = text.attr('y') ? text.attr('y') : 0;
|
|
29081
|
+
var dy = parseFloat(text.attr('dy')) || defaultDY;
|
|
29178
29082
|
var tspan = text
|
|
29179
29083
|
.text(null)
|
|
29180
|
-
.append(
|
|
29181
|
-
.attr(
|
|
29182
|
-
.attr(
|
|
29183
|
-
.attr(
|
|
29184
|
-
.attr(
|
|
29084
|
+
.append('tspan')
|
|
29085
|
+
.attr('x', x)
|
|
29086
|
+
.attr('y', y)
|
|
29087
|
+
.attr('dy', dy + "em")
|
|
29088
|
+
.attr('anchor', isYAxis ? 'end' : 'middle');
|
|
29185
29089
|
while ((word = words.pop())) {
|
|
29186
29090
|
line.push(word);
|
|
29187
|
-
tspan.text(line.join(
|
|
29188
|
-
if (tspan
|
|
29189
|
-
tspan.node().getBoundingClientRect()
|
|
29190
|
-
tspan.node().getBoundingClientRect().width > width
|
|
29191
|
-
line.length > 1) {
|
|
29091
|
+
tspan.text(line.join(' '));
|
|
29092
|
+
if (tspan
|
|
29093
|
+
&& tspan.node().getBoundingClientRect()
|
|
29094
|
+
&& tspan.node().getBoundingClientRect().width > width
|
|
29095
|
+
&& line.length > 1) {
|
|
29192
29096
|
line.pop();
|
|
29193
29097
|
if (lineNumber >= lineNumberLimit) {
|
|
29194
|
-
tspan.text(line.join(
|
|
29098
|
+
tspan.text(line.join(' ') + "...");
|
|
29195
29099
|
break;
|
|
29196
29100
|
}
|
|
29197
|
-
tspan.text(line.join(
|
|
29101
|
+
tspan.text(line.join(' '));
|
|
29198
29102
|
line = [word];
|
|
29199
29103
|
tspan = text
|
|
29200
|
-
.append(
|
|
29201
|
-
.attr(
|
|
29202
|
-
.attr(
|
|
29203
|
-
.attr(
|
|
29204
|
-
.attr(
|
|
29104
|
+
.append('tspan')
|
|
29105
|
+
.attr('x', x)
|
|
29106
|
+
.attr('y', y)
|
|
29107
|
+
.attr('dy', (++lineNumber * lineHeight + dy).toFixed(3) + "em")
|
|
29108
|
+
.attr('anchor', isYAxis ? 'end' : 'middle')
|
|
29205
29109
|
.text(lineNumber === lineNumberLimit && words.length > 0 ? word + "..." : word);
|
|
29206
29110
|
}
|
|
29207
29111
|
}
|
|
@@ -29219,11 +29123,9 @@ var adjustAxisDY = function (textGroup, textHeight) {
|
|
|
29219
29123
|
var height = text.node().getBoundingClientRect && text.node().getBoundingClientRect().height;
|
|
29220
29124
|
var startDY = height > textHeight * 3 ? threeLinesDY : twoLinesDY;
|
|
29221
29125
|
if (height > textHeight * 2) {
|
|
29222
|
-
text.selectAll(
|
|
29223
|
-
|
|
29224
|
-
|
|
29225
|
-
: (startDY + i * defaultLineHeight).toFixed(3) + "em";
|
|
29226
|
-
});
|
|
29126
|
+
text.selectAll('tspan').attr('dy', function (d, i) { return (i === 0
|
|
29127
|
+
? startDY + "em"
|
|
29128
|
+
: (startDY + i * defaultLineHeight).toFixed(3) + "em"); });
|
|
29227
29129
|
}
|
|
29228
29130
|
});
|
|
29229
29131
|
};
|
|
@@ -29238,78 +29140,78 @@ var adjustAxisDY = function (textGroup, textHeight) {
|
|
|
29238
29140
|
* gradients if multiple charts are rendered on a single page
|
|
29239
29141
|
*/
|
|
29240
29142
|
var gradientCalculator = function (defs, data, isHorizontal, fillColor, identifier) {
|
|
29241
|
-
var max = Math.max.apply(Math,
|
|
29143
|
+
var max = Math.max.apply(Math, __spreadArray([], __read(data.map(function (a) { return a.value; }))));
|
|
29242
29144
|
data.forEach(function (element, index) {
|
|
29243
29145
|
var valueDividedByMax = isNaN(element.value / max) ? 0 : element.value / max;
|
|
29244
29146
|
if (isHorizontal) {
|
|
29245
29147
|
var linearGradient = defs
|
|
29246
|
-
.append(
|
|
29247
|
-
.attr(
|
|
29148
|
+
.append('linearGradient')
|
|
29149
|
+
.attr('id', "gradient-" + identifier + "-" + index);
|
|
29248
29150
|
linearGradient
|
|
29249
|
-
.append(
|
|
29250
|
-
.attr(
|
|
29251
|
-
.attr(
|
|
29252
|
-
.attr(
|
|
29151
|
+
.append('stop')
|
|
29152
|
+
.attr('stop-color', fillColor)
|
|
29153
|
+
.attr('offset', '0%')
|
|
29154
|
+
.attr('stop-opacity', 0.5);
|
|
29253
29155
|
linearGradient
|
|
29254
|
-
.append(
|
|
29255
|
-
.attr(
|
|
29256
|
-
.attr(
|
|
29257
|
-
.attr(
|
|
29156
|
+
.append('stop')
|
|
29157
|
+
.attr('stop-color', fillColor)
|
|
29158
|
+
.attr('offset', '100%')
|
|
29159
|
+
.attr('stop-opacity', Math.max(0.5, valueDividedByMax));
|
|
29258
29160
|
}
|
|
29259
29161
|
else {
|
|
29260
29162
|
var linearGradient = defs
|
|
29261
|
-
.append(
|
|
29262
|
-
.attr(
|
|
29263
|
-
.attr(
|
|
29163
|
+
.append('linearGradient')
|
|
29164
|
+
.attr('id', "gradient-" + identifier + "-" + index)
|
|
29165
|
+
.attr('gradientTransform', 'rotate(90)');
|
|
29264
29166
|
linearGradient
|
|
29265
|
-
.append(
|
|
29266
|
-
.attr(
|
|
29267
|
-
.attr(
|
|
29268
|
-
.attr(
|
|
29167
|
+
.append('stop')
|
|
29168
|
+
.attr('stop-color', fillColor)
|
|
29169
|
+
.attr('offset', '0%')
|
|
29170
|
+
.attr('stop-opacity', Math.max(0.5, valueDividedByMax));
|
|
29269
29171
|
linearGradient
|
|
29270
|
-
.append(
|
|
29271
|
-
.attr(
|
|
29272
|
-
.attr(
|
|
29273
|
-
.attr(
|
|
29172
|
+
.append('stop')
|
|
29173
|
+
.attr('stop-color', fillColor)
|
|
29174
|
+
.attr('offset', Math.max(50, valueDividedByMax * 100) + "%")
|
|
29175
|
+
.attr('stop-opacity', 0.5);
|
|
29274
29176
|
linearGradient
|
|
29275
|
-
.append(
|
|
29276
|
-
.attr(
|
|
29277
|
-
.attr(
|
|
29278
|
-
.attr(
|
|
29177
|
+
.append('stop')
|
|
29178
|
+
.attr('stop-color', fillColor)
|
|
29179
|
+
.attr('offset', '100%')
|
|
29180
|
+
.attr('stop-opacity', 0.5);
|
|
29279
29181
|
}
|
|
29280
29182
|
});
|
|
29281
29183
|
};
|
|
29282
29184
|
|
|
29283
29185
|
var SpsBarChart = function (_a) {
|
|
29284
|
-
var xAxis = _a.xAxis, yAxis = _a.yAxis, chartData = _a.chartData, chartHeight = _a.chartHeight, identifier = _a.identifier, chartWidth = _a.chartWidth, _b = _a.isHorizontalBarChart, isHorizontalBarChart = _b === void 0 ? false : _b, _c = _a.customXAxis, customXAxis = _c === void 0 ? React__namespace.createElement(SpsDefaultXAxisTick, null) : _c, _d = _a.customYAxis, customYAxis = _d === void 0 ? React__namespace.createElement(SpsDefaultYAxisTick, null) : _d, _e = _a.barFillColor, barFillColor = _e === void 0 ? dsColors.colors.blue200 : _e, _f = _a.customToolTip, customToolTip = _f === void 0 ? React__namespace.createElement(SpsDefaultChartTooltip, null) : _f, _g = _a.barSize, barSize = _g === void 0 ? 40 : _g, _h = _a.barCategoryGap, barCategoryGap = _h === void 0 ? 20 : _h, _j = _a.margins, margins = _j === void 0 ? {
|
|
29186
|
+
var xAxis = _a.xAxis, yAxis = _a.yAxis, chartData = _a.chartData, chartHeight = _a.chartHeight, identifier = _a.identifier, chartWidth = _a.chartWidth, _b = _a.isHorizontalBarChart, isHorizontalBarChart = _b === void 0 ? false : _b, _c = _a.customXAxis, customXAxis = _c === void 0 ? React__namespace.createElement(SpsDefaultXAxisTick, null) : _c, _d = _a.customYAxis, customYAxis = _d === void 0 ? React__namespace.createElement(SpsDefaultYAxisTick, null) : _d, _e = _a.barFillColor, barFillColor = _e === void 0 ? dsColors.colors.blue200 : _e, _f = _a.customToolTip, customToolTip = _f === void 0 ? React__namespace.createElement(SpsDefaultChartTooltip, null) : _f, _g = _a.barSize, barSize = _g === void 0 ? 40 : _g, _h = _a.barCategoryGap, barCategoryGap = _h === void 0 ? 20 : _h, _j = _a.margins, margins = _j === void 0 ? {
|
|
29187
|
+
bottom: 30, left: 0, top: 40, right: 10,
|
|
29188
|
+
} : _j, _k = _a.barHoverFill, barHoverFill = _k === void 0 ? dsColors.colors.blue300 : _k;
|
|
29285
29189
|
var _l = __read(React.useState(null), 2), isToolTipActive = _l[0], setIsToolTipActive = _l[1];
|
|
29286
29190
|
var defaultTextHeight = 12; // px
|
|
29287
29191
|
var leftMarginSpacing = 20; // px
|
|
29288
29192
|
React.useEffect(function () {
|
|
29289
29193
|
select("#" + identifier)
|
|
29290
|
-
.select(
|
|
29291
|
-
.selectAll(
|
|
29194
|
+
.select('.recharts-surface')
|
|
29195
|
+
.selectAll('.default-y-axis')
|
|
29292
29196
|
.call(wrapText, margins.left + leftMarginSpacing, isHorizontalBarChart);
|
|
29293
29197
|
select("#" + identifier)
|
|
29294
|
-
.select(
|
|
29295
|
-
.selectAll(
|
|
29198
|
+
.select('.recharts-surface')
|
|
29199
|
+
.selectAll('.default-y-axis')
|
|
29296
29200
|
.call(adjustAxisDY, defaultTextHeight);
|
|
29297
29201
|
select("#" + identifier)
|
|
29298
|
-
.select(
|
|
29299
|
-
.selectAll(
|
|
29202
|
+
.select('.recharts-surface')
|
|
29203
|
+
.selectAll('.default-x-axis')
|
|
29300
29204
|
.call(wrapText, barSize, isHorizontalBarChart);
|
|
29301
29205
|
select("#" + identifier)
|
|
29302
|
-
.select(
|
|
29303
|
-
.append(
|
|
29206
|
+
.select('.recharts-surface')
|
|
29207
|
+
.append('defs')
|
|
29304
29208
|
.call(gradientCalculator, chartData, isHorizontalBarChart, barFillColor, identifier);
|
|
29305
29209
|
}, [chartData, barFillColor, isHorizontalBarChart, barSize, margins.left, identifier]);
|
|
29306
29210
|
/**
|
|
29307
29211
|
* Grabs the generated gradient for the bar from the SVG defs.
|
|
29308
29212
|
* @param index - Index of bar, used to grab correct gradient
|
|
29309
29213
|
*/
|
|
29310
|
-
var getGradient = function (index) {
|
|
29311
|
-
return "url(#gradient-" + identifier + "-" + index + ")";
|
|
29312
|
-
};
|
|
29214
|
+
var getGradient = function (index) { return "url(#gradient-" + identifier + "-" + index + ")"; };
|
|
29313
29215
|
/**
|
|
29314
29216
|
* Handler to render the toolTipWrapper on mouse over of corresponding bar.
|
|
29315
29217
|
* @param index - Index of bar, used to identify active bar and provide
|
|
@@ -29326,39 +29228,45 @@ var SpsBarChart = function (_a) {
|
|
|
29326
29228
|
};
|
|
29327
29229
|
return (React__namespace.createElement("div", { className: "sps-chart" },
|
|
29328
29230
|
React__namespace.createElement("div", { id: identifier },
|
|
29329
|
-
React__namespace.createElement(RechartsBarChart, { data: chartData, layout: isHorizontalBarChart ?
|
|
29231
|
+
React__namespace.createElement(RechartsBarChart, { data: chartData, layout: isHorizontalBarChart ? 'vertical' : 'horizontal', barSize: barSize, barCategoryGap: barCategoryGap, margin: margins, height: chartHeight, width: chartWidth },
|
|
29330
29232
|
React__namespace.createElement(CartesianGrid, { vertical: isHorizontalBarChart, horizontal: !isHorizontalBarChart, stroke: dsColors.colors.gray300 }),
|
|
29331
|
-
React__namespace.createElement(XAxis, { dataKey: isHorizontalBarChart ?
|
|
29332
|
-
React__namespace.createElement(YAxis, { dataKey: isHorizontalBarChart ?
|
|
29233
|
+
React__namespace.createElement(XAxis, { dataKey: isHorizontalBarChart ? 'value' : 'label', type: xAxis.type, domain: xAxis.domain, ticks: xAxis.tickValues, tickCount: xAxis.tickCount, tick: customXAxis, allowDataOverflow: false, interval: 0, tickLine: false, stroke: dsColors.colors.gray300 }),
|
|
29234
|
+
React__namespace.createElement(YAxis, { dataKey: isHorizontalBarChart ? 'label' : 'value', type: yAxis.type, domain: yAxis.domain, ticks: yAxis.tickValues, tickCount: yAxis.tickCount, tick: customYAxis, allowDataOverflow: false, interval: 0, tickLine: false, stroke: dsColors.colors.gray300 }),
|
|
29333
29235
|
React__namespace.createElement(Bar, { dataKey: "value", radius: isHorizontalBarChart ? [0, 4, 4, 0] : [4, 4, 0, 0], background: isHorizontalBarChart && {
|
|
29334
29236
|
fill: dsColors.colors.gray200,
|
|
29335
|
-
opacity:
|
|
29237
|
+
opacity: '.6',
|
|
29336
29238
|
}, onMouseEnter: function (props, index) {
|
|
29337
29239
|
setIsToolTipActive(index);
|
|
29338
29240
|
}, onMouseLeave: function () {
|
|
29339
29241
|
setIsToolTipActive(null);
|
|
29340
29242
|
} },
|
|
29341
|
-
chartData.map(function (entry, index) {
|
|
29342
|
-
|
|
29343
|
-
|
|
29344
|
-
: getGradient(index) }));
|
|
29345
|
-
}),
|
|
29243
|
+
chartData.map(function (entry, index) { return (React__namespace.createElement(Cell, { cursor: "pointer", key: "cell-" + index, fill: index === isToolTipActive
|
|
29244
|
+
? barHoverFill
|
|
29245
|
+
: getGradient(index) })); }),
|
|
29346
29246
|
React__namespace.createElement(LabelList, { dataKey: "label", content: ToolTipHandler }))))));
|
|
29347
29247
|
};
|
|
29348
29248
|
|
|
29349
29249
|
var SpsBarChartExamples = {
|
|
29350
29250
|
vertical: {
|
|
29351
|
-
label:
|
|
29352
|
-
description: utils
|
|
29251
|
+
label: 'Vertical',
|
|
29252
|
+
description: utils.code(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <p>Vertical bar chart example.</p>\n "], ["\n <p>Vertical bar chart example.</p>\n "]))),
|
|
29353
29253
|
examples: {
|
|
29354
29254
|
vertical: {
|
|
29355
|
-
react: utils
|
|
29255
|
+
react: utils.code(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n function DemoComponent() {\n const data = [{connections: 100, role: 'retailer', name: 'company 1'}, {connections: 150, role: 'retailer', name: 'company 2'}, {connections: 200, role: 'retailer', name: 'company 3'}, {connections: 220, role: 'retailer', name: 'company 4'}, {connections: 300, role: 'retailer', name: 'company 5'}]\n const chartData = data.map((retailer) => {\n return {\n label: retailer.name,\n value: parseInt(retailer.connections),\n }\n })\n return (\n <SpsBarChart\n chartData={chartData}\n xAxis=\"{ type: 'category' }\"\n yAxis=\"{\n type: 'number',\n domain: [0, 'auto'],\n tickCount: 8,\n }\"\n chartHeight={400}\n chartWidth={800}\n identifier=\"original-blue\"\n />\n\n )\n }\n "], ["\n function DemoComponent() {\n const data = [{connections: 100, role: 'retailer', name: 'company 1'}, {connections: 150, role: 'retailer', name: 'company 2'}, {connections: 200, role: 'retailer', name: 'company 3'}, {connections: 220, role: 'retailer', name: 'company 4'}, {connections: 300, role: 'retailer', name: 'company 5'}]\n const chartData = data.map((retailer) => {\n return {\n label: retailer.name,\n value: parseInt(retailer.connections),\n }\n })\n return (\n <SpsBarChart\n chartData={chartData}\n xAxis=\"{ type: 'category' }\"\n yAxis=\"{\n type: 'number',\n domain: [0, 'auto'],\n tickCount: 8,\n }\"\n chartHeight={400}\n chartWidth={800}\n identifier=\"original-blue\"\n />\n\n )\n }\n "]))),
|
|
29356
29256
|
},
|
|
29357
29257
|
},
|
|
29358
29258
|
},
|
|
29359
29259
|
};
|
|
29360
29260
|
var templateObject_1, templateObject_2;
|
|
29361
29261
|
|
|
29262
|
+
var MANIFEST = {
|
|
29263
|
+
'Bar Chart': {
|
|
29264
|
+
components: [SpsBarChart],
|
|
29265
|
+
examples: SpsBarChartExamples,
|
|
29266
|
+
},
|
|
29267
|
+
};
|
|
29268
|
+
|
|
29269
|
+
exports.MANIFEST = MANIFEST;
|
|
29362
29270
|
exports.PercentXAxisTick = PercentXAxisTick;
|
|
29363
29271
|
exports.SpsBarChart = SpsBarChart;
|
|
29364
29272
|
exports.SpsBarChartExamples = SpsBarChartExamples;
|