victory-histogram 36.8.2 → 36.8.3
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/CHANGELOG.md +6 -0
- package/dist/victory-histogram.js +258 -398
- package/dist/victory-histogram.min.js +1 -1
- package/es/helper-methods.d.ts +6 -0
- package/es/helper-methods.js +35 -30
- package/es/index.d.ts +2 -46
- package/es/index.js +1 -1
- package/es/victory-histogram.d.ts +133 -0
- package/es/victory-histogram.js +28 -43
- package/lib/helper-methods.d.ts +6 -0
- package/lib/helper-methods.js +34 -31
- package/lib/index.d.ts +2 -46
- package/lib/index.js +11 -8
- package/lib/victory-histogram.d.ts +133 -0
- package/lib/victory-histogram.js +27 -48
- package/package.json +7 -4
- package/src/{helper-methods.js → helper-methods.ts} +65 -44
- package/src/index.ts +1 -0
- package/src/{victory-histogram.js → victory-histogram.tsx} +52 -37
- package/src/index.d.ts +0 -46
- package/src/index.js +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { VictoryHistogramProps } from "./victory-histogram";
|
|
2
|
+
export declare const getFormattedData: (...args: any[]) => any;
|
|
3
|
+
export declare const getData: (props: VictoryHistogramProps) => any;
|
|
4
|
+
export declare const getDomain: (props: VictoryHistogramProps, axis: "x" | "y") => any;
|
|
5
|
+
export declare const getBaseProps: (initialProps: any, fallbackProps: any) => any;
|
|
6
|
+
//# sourceMappingURL=helper-methods.d.ts.map
|
package/es/helper-methods.js
CHANGED
|
@@ -51,9 +51,9 @@ var dataOrBinsContainDates = function (_ref) {
|
|
|
51
51
|
bins = _ref.bins,
|
|
52
52
|
x = _ref.x;
|
|
53
53
|
var xAccessor = Helpers.createAccessor(x || "x");
|
|
54
|
-
var dataIsDates = data.some(function (datum) {
|
|
54
|
+
var dataIsDates = (data === null || data === void 0 ? void 0 : data.some(function (datum) {
|
|
55
55
|
return xAccessor(datum) instanceof Date;
|
|
56
|
-
});
|
|
56
|
+
})) || false;
|
|
57
57
|
var binsHasDates = Array.isArray(bins) && bins.some(function (bin) {
|
|
58
58
|
return bin instanceof Date;
|
|
59
59
|
});
|
|
@@ -113,19 +113,21 @@ export var getFormattedData = cacheLastValue(function (_ref3) {
|
|
|
113
113
|
dataOrBinsContainsDates: dataOrBinsContainsDates
|
|
114
114
|
});
|
|
115
115
|
var foo = binFunc(data);
|
|
116
|
-
|
|
116
|
+
|
|
117
|
+
var binnedData = _toConsumableArray(foo).filter(function (_ref4) {
|
|
117
118
|
var x0 = _ref4.x0,
|
|
118
119
|
x1 = _ref4.x1;
|
|
119
120
|
|
|
120
|
-
if (
|
|
121
|
+
if (x0 instanceof Date && x1 instanceof Date) {
|
|
121
122
|
return new Date(x0).getTime() !== new Date(x1).getTime();
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
return x0 !== x1;
|
|
125
126
|
});
|
|
127
|
+
|
|
126
128
|
var formattedData = binnedData.map(function (bin) {
|
|
127
|
-
var x0 = dataOrBinsContainsDates ? new Date(bin.x0) : bin.x0;
|
|
128
|
-
var x1 = dataOrBinsContainsDates ? new Date(bin.x1) : bin.x1;
|
|
129
|
+
var x0 = dataOrBinsContainsDates ? new Date(bin.x0) : bin.x0 || 0;
|
|
130
|
+
var x1 = dataOrBinsContainsDates ? new Date(bin.x1) : bin.x1 || 0;
|
|
129
131
|
return {
|
|
130
132
|
x0: x0,
|
|
131
133
|
x1: x1,
|
|
@@ -140,7 +142,7 @@ export var getData = function (props) {
|
|
|
140
142
|
var bins = props.bins,
|
|
141
143
|
data = props.data,
|
|
142
144
|
x = props.x;
|
|
143
|
-
var dataIsPreformatted = data.some(function (_ref5) {
|
|
145
|
+
var dataIsPreformatted = data === null || data === void 0 ? void 0 : data.some(function (_ref5) {
|
|
144
146
|
var _y = _ref5._y;
|
|
145
147
|
return !_isNil(_y);
|
|
146
148
|
});
|
|
@@ -155,6 +157,8 @@ export var getData = function (props) {
|
|
|
155
157
|
}));
|
|
156
158
|
};
|
|
157
159
|
export var getDomain = function (props, axis) {
|
|
160
|
+
var _props$data;
|
|
161
|
+
|
|
158
162
|
var data = getData(props);
|
|
159
163
|
|
|
160
164
|
if (!data.length) {
|
|
@@ -174,7 +178,7 @@ export var getDomain = function (props, axis) {
|
|
|
174
178
|
}), "x");
|
|
175
179
|
}
|
|
176
180
|
|
|
177
|
-
return props.data.length ? Domain.getDomainWithZero(_objectSpread(_objectSpread({}, props), {}, {
|
|
181
|
+
return (_props$data = props.data) !== null && _props$data !== void 0 && _props$data.length ? Domain.getDomainWithZero(_objectSpread(_objectSpread({}, props), {}, {
|
|
178
182
|
data: data
|
|
179
183
|
}), "y") : [0, 1];
|
|
180
184
|
};
|
|
@@ -204,28 +208,29 @@ var getCalculatedValues = function (props) {
|
|
|
204
208
|
};
|
|
205
209
|
};
|
|
206
210
|
|
|
207
|
-
export var getBaseProps = function (
|
|
208
|
-
var modifiedProps = Helpers.modifyProps(
|
|
209
|
-
|
|
210
|
-
var
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
211
|
+
export var getBaseProps = function (initialProps, fallbackProps) {
|
|
212
|
+
var modifiedProps = Helpers.modifyProps(initialProps, fallbackProps, "histogram");
|
|
213
|
+
|
|
214
|
+
var props = _assign({}, modifiedProps, getCalculatedValues(modifiedProps));
|
|
215
|
+
|
|
216
|
+
var binSpacing = props.binSpacing,
|
|
217
|
+
cornerRadius = props.cornerRadius,
|
|
218
|
+
data = props.data,
|
|
219
|
+
domain = props.domain,
|
|
220
|
+
events = props.events,
|
|
221
|
+
height = props.height,
|
|
222
|
+
horizontal = props.horizontal,
|
|
223
|
+
padding = props.padding,
|
|
224
|
+
scale = props.scale,
|
|
225
|
+
sharedEvents = props.sharedEvents,
|
|
226
|
+
standalone = props.standalone,
|
|
227
|
+
style = props.style,
|
|
228
|
+
theme = props.theme,
|
|
229
|
+
width = props.width,
|
|
230
|
+
labels = props.labels,
|
|
231
|
+
name = props.name,
|
|
232
|
+
getPath = props.getPath,
|
|
233
|
+
disableInlineStyles = props.disableInlineStyles;
|
|
229
234
|
var initialChildProps = {
|
|
230
235
|
parent: {
|
|
231
236
|
horizontal: horizontal,
|
package/es/index.d.ts
CHANGED
|
@@ -1,46 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
EventPropTypeInterface,
|
|
4
|
-
NumberOrCallback,
|
|
5
|
-
StringOrNumberOrCallback,
|
|
6
|
-
VictoryCommonProps,
|
|
7
|
-
VictoryDatableProps,
|
|
8
|
-
VictoryMultiLabelableProps,
|
|
9
|
-
VictoryStyleInterface,
|
|
10
|
-
} from "victory-core";
|
|
11
|
-
|
|
12
|
-
export type VictoryHistogramTargetType = "data" | "labels" | "parent";
|
|
13
|
-
|
|
14
|
-
export interface VictoryHistogramProps
|
|
15
|
-
extends Omit<VictoryCommonProps, "polar">,
|
|
16
|
-
Omit<VictoryDatableProps, "y" | "y0">,
|
|
17
|
-
VictoryMultiLabelableProps {
|
|
18
|
-
binSpacing?: number;
|
|
19
|
-
bins?: number | number[] | Date[];
|
|
20
|
-
cornerRadius?:
|
|
21
|
-
| NumberOrCallback
|
|
22
|
-
| {
|
|
23
|
-
top?: NumberOrCallback;
|
|
24
|
-
topLeft?: NumberOrCallback;
|
|
25
|
-
topRight?: NumberOrCallback;
|
|
26
|
-
bottom?: NumberOrCallback;
|
|
27
|
-
bottomLeft?: NumberOrCallback;
|
|
28
|
-
bottomRight?: NumberOrCallback;
|
|
29
|
-
};
|
|
30
|
-
events?: EventPropTypeInterface<
|
|
31
|
-
VictoryHistogramTargetType,
|
|
32
|
-
number | string | number[] | string[]
|
|
33
|
-
>[];
|
|
34
|
-
eventKey?: StringOrNumberOrCallback;
|
|
35
|
-
horizontal?: boolean;
|
|
36
|
-
style?: VictoryStyleInterface;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Draw SVG histogram charts with React. VictoryHistogram is a composable component, so it doesn't include axes
|
|
41
|
-
* Check out VictoryChart for complete histogram charts and more.
|
|
42
|
-
*/
|
|
43
|
-
export class VictoryHistogram extends React.Component<
|
|
44
|
-
VictoryHistogramProps,
|
|
45
|
-
any
|
|
46
|
-
> {}
|
|
1
|
+
export * from "./victory-histogram";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./victory-histogram";
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { EventPropTypeInterface, NumberOrCallback, StringOrNumberOrCallback, VictoryCommonProps, VictoryDatableProps, VictoryMultiLabelableProps, VictoryStyleInterface, EventsMixinClass } from "victory-core";
|
|
3
|
+
export declare type VictoryHistogramTargetType = "data" | "labels" | "parent";
|
|
4
|
+
export interface VictoryHistogramProps extends Omit<VictoryCommonProps, "polar">, Omit<VictoryDatableProps, "y" | "y0">, VictoryMultiLabelableProps {
|
|
5
|
+
binSpacing?: number;
|
|
6
|
+
bins?: number | number[] | Date[];
|
|
7
|
+
cornerRadius?: NumberOrCallback | {
|
|
8
|
+
top?: NumberOrCallback;
|
|
9
|
+
topLeft?: NumberOrCallback;
|
|
10
|
+
topRight?: NumberOrCallback;
|
|
11
|
+
bottom?: NumberOrCallback;
|
|
12
|
+
bottomLeft?: NumberOrCallback;
|
|
13
|
+
bottomRight?: NumberOrCallback;
|
|
14
|
+
};
|
|
15
|
+
events?: EventPropTypeInterface<VictoryHistogramTargetType, number | string | number[] | string[]>[];
|
|
16
|
+
eventKey?: StringOrNumberOrCallback;
|
|
17
|
+
horizontal?: boolean;
|
|
18
|
+
style?: VictoryStyleInterface;
|
|
19
|
+
}
|
|
20
|
+
interface VictoryHistogramBase extends EventsMixinClass<VictoryHistogramProps> {
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Draw SVG histogram charts with React. VictoryHistogram is a composable component, so it doesn't include axes
|
|
24
|
+
* Check out VictoryChart for complete histogram charts and more.
|
|
25
|
+
*/
|
|
26
|
+
declare class VictoryHistogramBase extends React.Component<VictoryHistogramProps> {
|
|
27
|
+
static animationWhitelist: string[];
|
|
28
|
+
static displayName: string;
|
|
29
|
+
static role: string;
|
|
30
|
+
static defaultTransitions: {
|
|
31
|
+
onLoad: {
|
|
32
|
+
duration: number;
|
|
33
|
+
before: () => {
|
|
34
|
+
_y: number;
|
|
35
|
+
_y1: number;
|
|
36
|
+
_y0: number;
|
|
37
|
+
};
|
|
38
|
+
after: (datum: any) => {
|
|
39
|
+
_y: any;
|
|
40
|
+
_y1: any;
|
|
41
|
+
_y0: any;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
onExit: {
|
|
45
|
+
duration: number;
|
|
46
|
+
before: () => {
|
|
47
|
+
_y: number;
|
|
48
|
+
yOffset: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
onEnter: {
|
|
52
|
+
duration: number;
|
|
53
|
+
before: () => {
|
|
54
|
+
_y: number;
|
|
55
|
+
_y1: number;
|
|
56
|
+
_y0: number;
|
|
57
|
+
};
|
|
58
|
+
after: (datum: any) => {
|
|
59
|
+
_y: any;
|
|
60
|
+
_y1: any;
|
|
61
|
+
_y0: any;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
static getFormattedData: (...args: any[]) => any;
|
|
66
|
+
static defaultProps: VictoryHistogramProps;
|
|
67
|
+
static getDomain: (props: VictoryHistogramProps, axis: "y" | "x") => any;
|
|
68
|
+
static getData: (props: VictoryHistogramProps) => any;
|
|
69
|
+
static getBaseProps: (props: VictoryHistogramProps) => any;
|
|
70
|
+
static expectedComponents: Partial<keyof VictoryHistogramProps>[];
|
|
71
|
+
shouldAnimate(): boolean;
|
|
72
|
+
render(): React.ReactElement;
|
|
73
|
+
}
|
|
74
|
+
export declare const VictoryHistogram: {
|
|
75
|
+
new (props: import("victory-core").EventMixinCommonProps): {
|
|
76
|
+
state: {};
|
|
77
|
+
getEventState: (eventKey: string | number, namespace: string, childType?: string | undefined) => any;
|
|
78
|
+
getScopedEvents: (events: any, namespace: any, childType: any, baseProps: any) => {};
|
|
79
|
+
getEvents: (p: any, target: any, eventKey: any) => any;
|
|
80
|
+
externalMutations: {} | undefined;
|
|
81
|
+
calculatedState: {};
|
|
82
|
+
globalEvents: {};
|
|
83
|
+
prevGlobalEventKeys: string[];
|
|
84
|
+
boundGlobalEvents: {};
|
|
85
|
+
shouldComponentUpdate(nextProps: import("victory-core").EventMixinCommonProps): boolean;
|
|
86
|
+
componentDidMount(): void;
|
|
87
|
+
componentDidUpdate(prevProps: any): void;
|
|
88
|
+
componentWillUnmount(): void;
|
|
89
|
+
addGlobalListener(key: any): void;
|
|
90
|
+
removeGlobalListener(key: any): void;
|
|
91
|
+
getStateChanges(props: any): {};
|
|
92
|
+
applyExternalMutations(props: any, externalMutations: any): void;
|
|
93
|
+
getCalculatedValues(props: any): import("victory-core").EventMixinCalculatedValues;
|
|
94
|
+
getExternalMutations(props: import("victory-core").EventMixinCommonProps): {} | undefined;
|
|
95
|
+
cacheValues(obj: any): void;
|
|
96
|
+
getBaseProps(props: any, getSharedEventState: any): Record<string, object>;
|
|
97
|
+
getAllEvents(props: any): any;
|
|
98
|
+
getComponentProps(component: React.ReactNode, type: string, index: string | number): any;
|
|
99
|
+
renderContainer(component: any, children: any): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
100
|
+
animateComponent(props: import("victory-core").EventMixinCommonProps, defaultAnimationWhitelist: string[]): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
101
|
+
renderContinuousData(props: import("victory-core").EventMixinCommonProps): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
102
|
+
renderData(props: any, shouldRenderDatum?: ((datum: any) => boolean) | undefined): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
103
|
+
context: unknown;
|
|
104
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<import("victory-core").EventMixinCommonProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
105
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
106
|
+
render(): React.ReactNode;
|
|
107
|
+
readonly props: Readonly<import("victory-core").EventMixinCommonProps>;
|
|
108
|
+
refs: {
|
|
109
|
+
[key: string]: React.ReactInstance;
|
|
110
|
+
};
|
|
111
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
112
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<import("victory-core").EventMixinCommonProps>, prevState: Readonly<{}>): any;
|
|
113
|
+
componentWillMount?(): void;
|
|
114
|
+
UNSAFE_componentWillMount?(): void;
|
|
115
|
+
componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
|
|
116
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
|
|
117
|
+
componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
118
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
119
|
+
componentEvents: import("victory-core/lib/victory-util/events").ComponentEvent[];
|
|
120
|
+
getSharedEventState: (key: string, value: string) => unknown;
|
|
121
|
+
baseProps: Record<string, object>;
|
|
122
|
+
dataKeys: string[];
|
|
123
|
+
hasEvents: unknown;
|
|
124
|
+
events: unknown;
|
|
125
|
+
};
|
|
126
|
+
getBaseProps?(props: import("victory-core").EventMixinCommonProps): Record<string, object>;
|
|
127
|
+
role?: string | undefined;
|
|
128
|
+
expectedComponents?: string[] | undefined;
|
|
129
|
+
getChildren?: ((props: import("victory-core").EventMixinCommonProps, childComponents?: React.ReactNode[] | undefined, calculatedProps?: import("victory-core").EventMixinCommonProps | undefined) => void) | undefined;
|
|
130
|
+
animationWhitelist?: string[] | undefined;
|
|
131
|
+
} & typeof VictoryHistogramBase;
|
|
132
|
+
export {};
|
|
133
|
+
//# sourceMappingURL=victory-histogram.d.ts.map
|
package/es/victory-histogram.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
1
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
2
|
|
|
9
3
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -25,28 +19,32 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
25
19
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
26
20
|
|
|
27
21
|
import React from "react";
|
|
28
|
-
import PropTypes from "prop-types";
|
|
29
22
|
import { Bar } from "victory-bar";
|
|
30
|
-
import { Helpers, VictoryLabel, VictoryContainer, VictoryTheme,
|
|
23
|
+
import { Helpers, VictoryLabel, VictoryContainer, VictoryTheme, addEvents, UserProps } from "victory-core";
|
|
31
24
|
import { getBaseProps, getData, getDomain, getFormattedData } from "./helper-methods";
|
|
32
25
|
var fallbackProps = {
|
|
33
26
|
width: 450,
|
|
34
27
|
height: 300,
|
|
35
28
|
padding: 50
|
|
36
29
|
};
|
|
37
|
-
var defaultData = [];
|
|
38
|
-
export var VictoryHistogram = /*#__PURE__*/function (_React$Component) {
|
|
39
|
-
_inherits(VictoryHistogram, _React$Component);
|
|
30
|
+
var defaultData = []; // eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
40
31
|
|
|
41
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Draw SVG histogram charts with React. VictoryHistogram is a composable component, so it doesn't include axes
|
|
34
|
+
* Check out VictoryChart for complete histogram charts and more.
|
|
35
|
+
*/
|
|
36
|
+
var VictoryHistogramBase = /*#__PURE__*/function (_React$Component) {
|
|
37
|
+
_inherits(VictoryHistogramBase, _React$Component);
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
var _super = _createSuper(VictoryHistogramBase);
|
|
40
|
+
|
|
41
|
+
function VictoryHistogramBase() {
|
|
42
|
+
_classCallCheck(this, VictoryHistogramBase);
|
|
45
43
|
|
|
46
44
|
return _super.apply(this, arguments);
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
_createClass(
|
|
47
|
+
_createClass(VictoryHistogramBase, [{
|
|
50
48
|
key: "shouldAnimate",
|
|
51
49
|
value: // Overridden in native versions
|
|
52
50
|
function shouldAnimate() {
|
|
@@ -55,8 +53,8 @@ export var VictoryHistogram = /*#__PURE__*/function (_React$Component) {
|
|
|
55
53
|
}, {
|
|
56
54
|
key: "render",
|
|
57
55
|
value: function render() {
|
|
58
|
-
var animationWhitelist =
|
|
59
|
-
role =
|
|
56
|
+
var animationWhitelist = VictoryHistogramBase.animationWhitelist,
|
|
57
|
+
role = VictoryHistogramBase.role;
|
|
60
58
|
var props = Helpers.modifyProps(this.props, fallbackProps, role);
|
|
61
59
|
|
|
62
60
|
if (this.shouldAnimate()) {
|
|
@@ -69,12 +67,13 @@ export var VictoryHistogram = /*#__PURE__*/function (_React$Component) {
|
|
|
69
67
|
}
|
|
70
68
|
}]);
|
|
71
69
|
|
|
72
|
-
return
|
|
70
|
+
return VictoryHistogramBase;
|
|
73
71
|
}(React.Component);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
|
|
73
|
+
VictoryHistogramBase.animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
|
|
74
|
+
VictoryHistogramBase.displayName = "VictoryHistogram";
|
|
75
|
+
VictoryHistogramBase.role = "histogram";
|
|
76
|
+
VictoryHistogramBase.defaultTransitions = {
|
|
78
77
|
onLoad: {
|
|
79
78
|
duration: 2000,
|
|
80
79
|
before: function () {
|
|
@@ -119,22 +118,8 @@ VictoryHistogram.defaultTransitions = {
|
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
binSpacing: CustomPropTypes.nonNegative,
|
|
125
|
-
bins: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.instanceOf(Date)])), CustomPropTypes.nonNegative]),
|
|
126
|
-
cornerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.func, PropTypes.shape({
|
|
127
|
-
top: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
128
|
-
topLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
129
|
-
topRight: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
130
|
-
bottom: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
131
|
-
bottomLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
132
|
-
bottomRight: PropTypes.oneOfType([PropTypes.number, PropTypes.func])
|
|
133
|
-
})]),
|
|
134
|
-
getPath: PropTypes.func,
|
|
135
|
-
horizontal: PropTypes.bool
|
|
136
|
-
});
|
|
137
|
-
VictoryHistogram.defaultProps = {
|
|
121
|
+
VictoryHistogramBase.getFormattedData = getFormattedData;
|
|
122
|
+
VictoryHistogramBase.defaultProps = {
|
|
138
123
|
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
|
|
139
124
|
data: defaultData,
|
|
140
125
|
dataComponent: /*#__PURE__*/React.createElement(Bar, null),
|
|
@@ -147,12 +132,12 @@ VictoryHistogram.defaultProps = {
|
|
|
147
132
|
standalone: true,
|
|
148
133
|
theme: VictoryTheme.grayscale
|
|
149
134
|
};
|
|
150
|
-
|
|
151
|
-
|
|
135
|
+
VictoryHistogramBase.getDomain = getDomain;
|
|
136
|
+
VictoryHistogramBase.getData = getData;
|
|
152
137
|
|
|
153
|
-
|
|
138
|
+
VictoryHistogramBase.getBaseProps = function (props) {
|
|
154
139
|
return getBaseProps(props, fallbackProps);
|
|
155
140
|
};
|
|
156
141
|
|
|
157
|
-
|
|
158
|
-
export
|
|
142
|
+
VictoryHistogramBase.expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
|
|
143
|
+
export var VictoryHistogram = addEvents(VictoryHistogramBase);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { VictoryHistogramProps } from "./victory-histogram";
|
|
2
|
+
export declare const getFormattedData: (...args: any[]) => any;
|
|
3
|
+
export declare const getData: (props: VictoryHistogramProps) => any;
|
|
4
|
+
export declare const getDomain: (props: VictoryHistogramProps, axis: "x" | "y") => any;
|
|
5
|
+
export declare const getBaseProps: (initialProps: any, fallbackProps: any) => any;
|
|
6
|
+
//# sourceMappingURL=helper-methods.d.ts.map
|
package/lib/helper-methods.js
CHANGED
|
@@ -71,9 +71,9 @@ var dataOrBinsContainDates = function (_ref) {
|
|
|
71
71
|
|
|
72
72
|
var xAccessor = _victoryCore.Helpers.createAccessor(x || "x");
|
|
73
73
|
|
|
74
|
-
var dataIsDates = data.some(function (datum) {
|
|
74
|
+
var dataIsDates = (data === null || data === void 0 ? void 0 : data.some(function (datum) {
|
|
75
75
|
return xAccessor(datum) instanceof Date;
|
|
76
|
-
});
|
|
76
|
+
})) || false;
|
|
77
77
|
var binsHasDates = Array.isArray(bins) && bins.some(function (bin) {
|
|
78
78
|
return bin instanceof Date;
|
|
79
79
|
});
|
|
@@ -135,19 +135,21 @@ var getFormattedData = cacheLastValue(function (_ref3) {
|
|
|
135
135
|
dataOrBinsContainsDates: dataOrBinsContainsDates
|
|
136
136
|
});
|
|
137
137
|
var foo = binFunc(data);
|
|
138
|
-
|
|
138
|
+
|
|
139
|
+
var binnedData = _toConsumableArray(foo).filter(function (_ref4) {
|
|
139
140
|
var x0 = _ref4.x0,
|
|
140
141
|
x1 = _ref4.x1;
|
|
141
142
|
|
|
142
|
-
if (
|
|
143
|
+
if (x0 instanceof Date && x1 instanceof Date) {
|
|
143
144
|
return new Date(x0).getTime() !== new Date(x1).getTime();
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
return x0 !== x1;
|
|
147
148
|
});
|
|
149
|
+
|
|
148
150
|
var formattedData = binnedData.map(function (bin) {
|
|
149
|
-
var x0 = dataOrBinsContainsDates ? new Date(bin.x0) : bin.x0;
|
|
150
|
-
var x1 = dataOrBinsContainsDates ? new Date(bin.x1) : bin.x1;
|
|
151
|
+
var x0 = dataOrBinsContainsDates ? new Date(bin.x0) : bin.x0 || 0;
|
|
152
|
+
var x1 = dataOrBinsContainsDates ? new Date(bin.x1) : bin.x1 || 0;
|
|
151
153
|
return {
|
|
152
154
|
x0: x0,
|
|
153
155
|
x1: x1,
|
|
@@ -164,7 +166,7 @@ var getData = function (props) {
|
|
|
164
166
|
var bins = props.bins,
|
|
165
167
|
data = props.data,
|
|
166
168
|
x = props.x;
|
|
167
|
-
var dataIsPreformatted = data.some(function (_ref5) {
|
|
169
|
+
var dataIsPreformatted = data === null || data === void 0 ? void 0 : data.some(function (_ref5) {
|
|
168
170
|
var _y = _ref5._y;
|
|
169
171
|
return !(0, _isNil2.default)(_y);
|
|
170
172
|
});
|
|
@@ -182,6 +184,8 @@ var getData = function (props) {
|
|
|
182
184
|
exports.getData = getData;
|
|
183
185
|
|
|
184
186
|
var getDomain = function (props, axis) {
|
|
187
|
+
var _props$data;
|
|
188
|
+
|
|
185
189
|
var data = getData(props);
|
|
186
190
|
|
|
187
191
|
if (!data.length) {
|
|
@@ -201,7 +205,7 @@ var getDomain = function (props, axis) {
|
|
|
201
205
|
}), "x");
|
|
202
206
|
}
|
|
203
207
|
|
|
204
|
-
return props.data.length ? _victoryCore.Domain.getDomainWithZero(_objectSpread(_objectSpread({}, props), {}, {
|
|
208
|
+
return (_props$data = props.data) !== null && _props$data !== void 0 && _props$data.length ? _victoryCore.Domain.getDomainWithZero(_objectSpread(_objectSpread({}, props), {}, {
|
|
205
209
|
data: data
|
|
206
210
|
}), "y") : [0, 1];
|
|
207
211
|
};
|
|
@@ -235,29 +239,28 @@ var getCalculatedValues = function (props) {
|
|
|
235
239
|
};
|
|
236
240
|
};
|
|
237
241
|
|
|
238
|
-
var getBaseProps = function (
|
|
239
|
-
var modifiedProps = _victoryCore.Helpers.modifyProps(
|
|
240
|
-
|
|
241
|
-
props = (0, _assign2.default)({}, modifiedProps, getCalculatedValues(modifiedProps));
|
|
242
|
-
var
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
disableInlineStyles = _props.disableInlineStyles;
|
|
242
|
+
var getBaseProps = function (initialProps, fallbackProps) {
|
|
243
|
+
var modifiedProps = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "histogram");
|
|
244
|
+
|
|
245
|
+
var props = (0, _assign2.default)({}, modifiedProps, getCalculatedValues(modifiedProps));
|
|
246
|
+
var binSpacing = props.binSpacing,
|
|
247
|
+
cornerRadius = props.cornerRadius,
|
|
248
|
+
data = props.data,
|
|
249
|
+
domain = props.domain,
|
|
250
|
+
events = props.events,
|
|
251
|
+
height = props.height,
|
|
252
|
+
horizontal = props.horizontal,
|
|
253
|
+
padding = props.padding,
|
|
254
|
+
scale = props.scale,
|
|
255
|
+
sharedEvents = props.sharedEvents,
|
|
256
|
+
standalone = props.standalone,
|
|
257
|
+
style = props.style,
|
|
258
|
+
theme = props.theme,
|
|
259
|
+
width = props.width,
|
|
260
|
+
labels = props.labels,
|
|
261
|
+
name = props.name,
|
|
262
|
+
getPath = props.getPath,
|
|
263
|
+
disableInlineStyles = props.disableInlineStyles;
|
|
261
264
|
var initialChildProps = {
|
|
262
265
|
parent: {
|
|
263
266
|
horizontal: horizontal,
|
package/lib/index.d.ts
CHANGED
|
@@ -1,46 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
EventPropTypeInterface,
|
|
4
|
-
NumberOrCallback,
|
|
5
|
-
StringOrNumberOrCallback,
|
|
6
|
-
VictoryCommonProps,
|
|
7
|
-
VictoryDatableProps,
|
|
8
|
-
VictoryMultiLabelableProps,
|
|
9
|
-
VictoryStyleInterface,
|
|
10
|
-
} from "victory-core";
|
|
11
|
-
|
|
12
|
-
export type VictoryHistogramTargetType = "data" | "labels" | "parent";
|
|
13
|
-
|
|
14
|
-
export interface VictoryHistogramProps
|
|
15
|
-
extends Omit<VictoryCommonProps, "polar">,
|
|
16
|
-
Omit<VictoryDatableProps, "y" | "y0">,
|
|
17
|
-
VictoryMultiLabelableProps {
|
|
18
|
-
binSpacing?: number;
|
|
19
|
-
bins?: number | number[] | Date[];
|
|
20
|
-
cornerRadius?:
|
|
21
|
-
| NumberOrCallback
|
|
22
|
-
| {
|
|
23
|
-
top?: NumberOrCallback;
|
|
24
|
-
topLeft?: NumberOrCallback;
|
|
25
|
-
topRight?: NumberOrCallback;
|
|
26
|
-
bottom?: NumberOrCallback;
|
|
27
|
-
bottomLeft?: NumberOrCallback;
|
|
28
|
-
bottomRight?: NumberOrCallback;
|
|
29
|
-
};
|
|
30
|
-
events?: EventPropTypeInterface<
|
|
31
|
-
VictoryHistogramTargetType,
|
|
32
|
-
number | string | number[] | string[]
|
|
33
|
-
>[];
|
|
34
|
-
eventKey?: StringOrNumberOrCallback;
|
|
35
|
-
horizontal?: boolean;
|
|
36
|
-
style?: VictoryStyleInterface;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Draw SVG histogram charts with React. VictoryHistogram is a composable component, so it doesn't include axes
|
|
41
|
-
* Check out VictoryChart for complete histogram charts and more.
|
|
42
|
-
*/
|
|
43
|
-
export class VictoryHistogram extends React.Component<
|
|
44
|
-
VictoryHistogramProps,
|
|
45
|
-
any
|
|
46
|
-
> {}
|
|
1
|
+
export * from "./victory-histogram";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "VictoryHistogram", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _victoryHistogram.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
|
|
13
|
-
var _victoryHistogram =
|
|
7
|
+
var _victoryHistogram = require("./victory-histogram");
|
|
14
8
|
|
|
15
|
-
function
|
|
9
|
+
Object.keys(_victoryHistogram).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _victoryHistogram[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _victoryHistogram[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|