victory-core
Advanced tools
Comparing version 35.3.3 to 35.3.4
@@ -88,9 +88,9 @@ import * as React from "react"; | ||
export interface CallbackArgs { | ||
active: boolean; | ||
data: any; | ||
datum: any; | ||
horizontal: boolean; | ||
active?: boolean; | ||
data?: any; | ||
datum?: any; | ||
horizontal?: boolean; | ||
index: number | string; | ||
x: number; | ||
y: number; | ||
x?: number; | ||
y?: number; | ||
scale?: { | ||
@@ -100,4 +100,9 @@ x?: D3Scale; | ||
}; | ||
tick?: any; | ||
ticks?: any; | ||
text?: any; | ||
} | ||
export type OrientationTypes = "top" | "bottom" | "left" | "right"; | ||
export type VictoryStringOrNumberCallback = (args: CallbackArgs) => string | number; | ||
@@ -107,2 +112,3 @@ export type VictoryNumberCallback = (args: CallbackArgs) => number; | ||
export type VictoryPaddingCallback = (args: CallbackArgs) => number | BlockProps; | ||
export type VictoryOrientationCallback = (args: CallbackArgs) => OrientationTypes; | ||
export type StringOrNumberOrCallback = string | number | VictoryStringOrNumberCallback; | ||
@@ -112,7 +118,6 @@ export type NumberOrCallback = number | VictoryNumberCallback; | ||
export type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback; | ||
export type OrientationOrCallback = OrientationTypes | VictoryOrientationCallback; | ||
export type SliceNumberOrCallback<T, P = null> = number | ((props: Omit<T, P>) => number); | ||
export type VictoryStyleObject = { [K in keyof React.CSSProperties]: StringOrNumberOrCallback }; | ||
export type StringOrNumberOrList = string | number | (string | number)[]; | ||
@@ -125,4 +130,11 @@ | ||
export type OrientationTypes = "top" | "bottom" | "left" | "right"; | ||
export type VictoryStyleObject = { [K in keyof React.CSSProperties]: StringOrNumberOrCallback }; | ||
export type LabelProps = React.CSSProperties & { | ||
angle?: number; | ||
verticalAnchor?: VerticalAnchorType; | ||
}; | ||
export type VictoryLabelStyleObject = { [K in keyof LabelProps]: StringOrNumberOrCallback }; | ||
/** | ||
@@ -134,3 +146,3 @@ * Style interface used in components/themeing | ||
data?: VictoryStyleObject; | ||
labels?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
border?: VictoryStyleObject; | ||
@@ -158,7 +170,6 @@ } | ||
export type TickLabelProps = React.CSSProperties & { | ||
angle?: number; | ||
verticalAnchor?: VerticalAnchorType; | ||
}; | ||
export type TickProps = React.CSSProperties & { size?: number }; | ||
export type VictoryTickStyleObject = { [K in keyof TickProps]: StringOrNumberOrCallback }; | ||
export interface VictoryAxisCommonProps { | ||
@@ -172,20 +183,8 @@ axisComponent?: React.ReactElement; | ||
style?: { | ||
parent?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
axis?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
axisLabel?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
grid?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
ticks?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
tickLabels?: { | ||
[K in keyof TickLabelProps]: string | number | ((tick?: any) => string | number); | ||
}; | ||
parent?: VictoryStyleObject; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
@@ -212,3 +211,3 @@ tickComponent?: React.ReactElement; | ||
backgroundComponent?: React.ReactElement; | ||
backgroundStyle?: React.CSSProperties | React.CSSProperties[]; | ||
backgroundStyle?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
backgroundPadding?: PaddingProps | PaddingProps[]; | ||
@@ -230,3 +229,3 @@ capHeight?: StringOrNumberOrCallback; | ||
renderInPortal?: boolean; | ||
style?: React.CSSProperties | React.CSSProperties[]; | ||
style?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
tabIndex?: NumberOrCallback; | ||
@@ -323,14 +322,2 @@ text?: string[] | StringOrNumberOrCallback; | ||
// #region Victory Theme | ||
export type ThemeBaseProps = { | ||
width?: number; | ||
height?: number; | ||
colorScale?: string[]; | ||
padding?: number; | ||
offsetX?: number; | ||
offsetY?: number; | ||
}; | ||
export type TickProps = React.CSSProperties & { size?: number }; | ||
// Note: Many SVG attributes are missed in CSSProperties interface | ||
@@ -340,40 +327,44 @@ export interface VictoryThemeDefinition { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
axis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
offsetX?: number; | ||
offsetY?: number; | ||
} & VictoryCommonThemeProps; | ||
bar?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
boxplot?: { | ||
style?: { | ||
max?: React.CSSProperties; | ||
maxLabels?: React.CSSProperties; | ||
median?: React.CSSProperties; | ||
medianLabels?: React.CSSProperties; | ||
min?: React.CSSProperties; | ||
minLabels?: React.CSSProperties; | ||
q1?: React.CSSProperties; | ||
q1Labels?: React.CSSProperties; | ||
q3?: React.CSSProperties; | ||
q3Labels?: React.CSSProperties; | ||
max?: VictoryStyleObject; | ||
maxLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
median?: VictoryStyleObject; | ||
medianLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
min?: VictoryStyleObject; | ||
minLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
q1?: VictoryStyleObject; | ||
q1Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
q3?: VictoryStyleObject; | ||
q3Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
boxWidth?: number; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
candlestick?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
@@ -384,104 +375,123 @@ candleColors?: { | ||
}; | ||
} & ThemeBaseProps; | ||
chart?: ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
chart?: VictoryCommonThemeProps; | ||
dependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
offsetX?: number; | ||
offsetY?: number; | ||
orientation?: OrientationTypes; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
errorbar?: { | ||
borderWidth?: number; | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
group?: ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
group?: VictoryCommonThemeProps; | ||
independentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
offsetX?: number; | ||
offsetY?: number; | ||
orientation?: OrientationTypes; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
legend?: { | ||
gutter?: number; | ||
orientation?: "vertical" | "horizontal"; | ||
titleOrientation?: OrientationTypes; | ||
gutter?: number | BlockProps; | ||
rowGutter?: number | BlockProps; | ||
orientation?: string; | ||
titleOrientation?: string; | ||
style?: { | ||
data?: React.CSSProperties & { | ||
type?: ScatterSymbolType; | ||
data?: VictoryStyleObject & { | ||
type?: string; | ||
}; | ||
labels?: React.CSSProperties; | ||
title?: React.CSSProperties; | ||
border?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
title?: VictoryLabelStyleObject; | ||
}; | ||
} & ThemeBaseProps; | ||
itemsPerRow?: number; | ||
x?: number; | ||
y?: number; | ||
centerTitle?: boolean; | ||
borderPadding?: number | BlockProps; | ||
} & VictoryCommonThemeProps; | ||
line?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
pie?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
polarAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
polarDependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
polarIndependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
scatter?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
stack?: ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
stack?: VictoryCommonThemeProps; | ||
tooltip?: { | ||
style?: React.CSSProperties; | ||
flyoutStyle?: React.CSSProperties; | ||
cornerRadius?: number; | ||
pointerLength?: number; | ||
flyoutPadding?: number; | ||
style?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
flyoutStyle?: VictoryStyleObject; | ||
cornerRadius?: NumberOrCallback; | ||
pointerLength?: NumberOrCallback; | ||
flyoutPadding?: PaddingOrCallback; | ||
flyoutWidth?: NumberOrCallback; | ||
flyoutHeight?: NumberOrCallback; | ||
orientation?: OrientationOrCallback; | ||
pointerOrientation?: OrientationOrCallback; | ||
}; | ||
voronoi?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
flyout?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
flyout?: VictoryStyleObject; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
} | ||
@@ -624,4 +634,5 @@ | ||
export interface VictoryCommonProps { | ||
export interface VictoryCommonThemeProps { | ||
animate?: boolean | AnimatePropTypeInterface; | ||
colorScale?: ColorScalePropType; | ||
containerComponent?: React.ReactElement; | ||
@@ -651,2 +662,5 @@ domainPadding?: DomainPaddingPropType; | ||
width?: number; | ||
} | ||
export interface VictoryCommonProps extends VictoryCommonThemeProps { | ||
theme?: VictoryThemeDefinition; | ||
@@ -653,0 +667,0 @@ } |
@@ -0,1 +1,3 @@ | ||
import _keys from "lodash/keys"; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -58,3 +60,3 @@ | ||
return Object.keys(this.map).map(function (key) { | ||
return _keys(this.map).map(function (key) { | ||
var el = _this2.map[key]; | ||
@@ -61,0 +63,0 @@ return el ? React.cloneElement(el, { |
@@ -0,1 +1,2 @@ | ||
import _keys from "lodash/keys"; | ||
import _includes from "lodash/includes"; | ||
@@ -128,5 +129,5 @@ import _uniq from "lodash/uniq"; | ||
if (eventReturn.eventKey === "all") { | ||
return baseProps[childName] ? _without(Object.keys(baseProps[childName]), "parent") : _without(Object.keys(baseProps), "parent"); | ||
return baseProps[childName] ? _without(_keys(baseProps[childName]), "parent") : _without(_keys(baseProps), "parent"); | ||
} else if (eventReturn.eventKey === undefined && eventKey === "parent") { | ||
return baseProps[childName] ? Object.keys(baseProps[childName]) : Object.keys(baseProps); | ||
return baseProps[childName] ? _keys(baseProps[childName]) : _keys(baseProps); | ||
} | ||
@@ -163,3 +164,3 @@ | ||
if (state[key] && !Object.keys(state[key]).length) { | ||
if (state[key] && !_keys(state[key]).length) { | ||
delete state[key]; | ||
@@ -191,3 +192,3 @@ } | ||
var allChildNames = childNames === "all" ? _without(Object.keys(baseProps), "parent") : childNames; | ||
var allChildNames = childNames === "all" ? _without(_keys(baseProps), "parent") : childNames; | ||
return Array.isArray(allChildNames) ? allChildNames.reduce(function (memo, childName) { | ||
@@ -238,3 +239,3 @@ return _assign(memo, getReturnByChild(childName)); | ||
return Object.keys(events).reduce(function (memo, event) { | ||
return _keys(events).reduce(function (memo, event) { | ||
memo[event] = onEvent; | ||
@@ -249,3 +250,3 @@ return memo; | ||
getPartialEvents: function (events, eventKey, childProps) { | ||
return events ? Object.keys(events).reduce(function (memo, eventName) { | ||
return events ? _keys(events).reduce(function (memo, eventName) { | ||
var appliedEvent = function (evt) { | ||
@@ -317,3 +318,5 @@ return events[eventName](evt, childProps, eventKey, eventName); | ||
baseState = baseState || {}; | ||
var eventKeys = Object.keys(baseProps); | ||
var eventKeys = _keys(baseProps); | ||
return eventKeys.reduce(function (memo, eventKey) { | ||
@@ -335,3 +338,3 @@ var keyState = baseState[eventKey] || {}; | ||
// will be used. (i.e. labels) | ||
var targets = _uniq(Object.keys(keyProps).concat(Object.keys(keyState))); | ||
var targets = _uniq(_keys(keyProps).concat(_keys(keyState))); | ||
@@ -338,0 +341,0 @@ memo[eventKey] = targets.reduce(function (m, target) { |
@@ -0,1 +1,2 @@ | ||
import _keys from "lodash/keys"; | ||
import _assign from "lodash/assign"; | ||
@@ -39,3 +40,3 @@ import _pick from "lodash/pick"; | ||
* @param {Object} originalObject: created object will be based on this object | ||
* @param {Array<String>} keys: an array of keys to omit from the new object | ||
* @param {Array<String>} ks: an array of keys to omit from the new object | ||
* @returns {Object} new object with same properties as originalObject | ||
@@ -46,3 +47,3 @@ */ | ||
function omit(originalObject) { | ||
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var ks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
// code based on babel's _objectWithoutProperties | ||
@@ -52,3 +53,3 @@ var newObject = {}; | ||
for (var key in originalObject) { | ||
if (keys.indexOf(key) >= 0) { | ||
if (ks.indexOf(key) >= 0) { | ||
continue; | ||
@@ -183,3 +184,3 @@ } | ||
function evaluateStyle(style, props) { | ||
if (!style || !Object.keys(style).some(function (value) { | ||
if (!style || !_keys(style).some(function (value) { | ||
return _isFunction(style[value]); | ||
@@ -190,3 +191,3 @@ })) { | ||
return Object.keys(style).reduce(function (prev, curr) { | ||
return _keys(style).reduce(function (prev, curr) { | ||
prev[curr] = evaluateProp(style[curr], props); | ||
@@ -193,0 +194,0 @@ return prev; |
@@ -18,3 +18,4 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
this.loop = this.loop.bind(this); | ||
this.timer = timer(this.loop); | ||
this.timer = null; | ||
this.activeSubscriptions = 0; | ||
} | ||
@@ -42,3 +43,5 @@ | ||
value: function start() { | ||
this.timer.start(); | ||
if (!this.timer) { | ||
this.timer = timer(this.loop); | ||
} | ||
} | ||
@@ -48,3 +51,6 @@ }, { | ||
value: function stop() { | ||
this.timer.stop(); | ||
if (this.timer) { | ||
this.timer.stop(); | ||
this.timer = null; | ||
} | ||
} | ||
@@ -55,3 +61,3 @@ }, { | ||
duration = this.shouldAnimate ? duration : 0; | ||
return this.subscribers.push({ | ||
var subscriptionID = this.subscribers.push({ | ||
startTime: now(), | ||
@@ -61,2 +67,5 @@ callback: callback, | ||
}); | ||
this.activeSubscriptions++; | ||
this.start(); | ||
return subscriptionID; | ||
} | ||
@@ -66,5 +75,10 @@ }, { | ||
value: function unsubscribe(id) { | ||
if (id !== null) { | ||
if (id !== null && this.subscribers[id - 1]) { | ||
delete this.subscribers[id - 1]; | ||
this.activeSubscriptions--; | ||
} | ||
if (this.activeSubscriptions === 0) { | ||
this.stop(); | ||
} | ||
} | ||
@@ -71,0 +85,0 @@ }]); |
@@ -0,1 +1,2 @@ | ||
import _keys from "lodash/keys"; | ||
import _identity from "lodash/identity"; | ||
@@ -20,3 +21,4 @@ import _defaults from "lodash/defaults"; | ||
var hasDifference = false; | ||
var difference = Object.keys(a).reduce(function (_difference, key) { | ||
var difference = _keys(a).reduce(function (_difference, key) { | ||
if (!(key in b)) { | ||
@@ -29,2 +31,3 @@ hasDifference = true; | ||
}, {}); | ||
return hasDifference && difference; | ||
@@ -31,0 +34,0 @@ } |
@@ -88,9 +88,9 @@ import * as React from "react"; | ||
export interface CallbackArgs { | ||
active: boolean; | ||
data: any; | ||
datum: any; | ||
horizontal: boolean; | ||
active?: boolean; | ||
data?: any; | ||
datum?: any; | ||
horizontal?: boolean; | ||
index: number | string; | ||
x: number; | ||
y: number; | ||
x?: number; | ||
y?: number; | ||
scale?: { | ||
@@ -100,4 +100,9 @@ x?: D3Scale; | ||
}; | ||
tick?: any; | ||
ticks?: any; | ||
text?: any; | ||
} | ||
export type OrientationTypes = "top" | "bottom" | "left" | "right"; | ||
export type VictoryStringOrNumberCallback = (args: CallbackArgs) => string | number; | ||
@@ -107,2 +112,3 @@ export type VictoryNumberCallback = (args: CallbackArgs) => number; | ||
export type VictoryPaddingCallback = (args: CallbackArgs) => number | BlockProps; | ||
export type VictoryOrientationCallback = (args: CallbackArgs) => OrientationTypes; | ||
export type StringOrNumberOrCallback = string | number | VictoryStringOrNumberCallback; | ||
@@ -112,7 +118,6 @@ export type NumberOrCallback = number | VictoryNumberCallback; | ||
export type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback; | ||
export type OrientationOrCallback = OrientationTypes | VictoryOrientationCallback; | ||
export type SliceNumberOrCallback<T, P = null> = number | ((props: Omit<T, P>) => number); | ||
export type VictoryStyleObject = { [K in keyof React.CSSProperties]: StringOrNumberOrCallback }; | ||
export type StringOrNumberOrList = string | number | (string | number)[]; | ||
@@ -125,4 +130,11 @@ | ||
export type OrientationTypes = "top" | "bottom" | "left" | "right"; | ||
export type VictoryStyleObject = { [K in keyof React.CSSProperties]: StringOrNumberOrCallback }; | ||
export type LabelProps = React.CSSProperties & { | ||
angle?: number; | ||
verticalAnchor?: VerticalAnchorType; | ||
}; | ||
export type VictoryLabelStyleObject = { [K in keyof LabelProps]: StringOrNumberOrCallback }; | ||
/** | ||
@@ -134,3 +146,3 @@ * Style interface used in components/themeing | ||
data?: VictoryStyleObject; | ||
labels?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
border?: VictoryStyleObject; | ||
@@ -158,7 +170,6 @@ } | ||
export type TickLabelProps = React.CSSProperties & { | ||
angle?: number; | ||
verticalAnchor?: VerticalAnchorType; | ||
}; | ||
export type TickProps = React.CSSProperties & { size?: number }; | ||
export type VictoryTickStyleObject = { [K in keyof TickProps]: StringOrNumberOrCallback }; | ||
export interface VictoryAxisCommonProps { | ||
@@ -172,20 +183,8 @@ axisComponent?: React.ReactElement; | ||
style?: { | ||
parent?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
axis?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
axisLabel?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
grid?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
ticks?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
tickLabels?: { | ||
[K in keyof TickLabelProps]: string | number | ((tick?: any) => string | number); | ||
}; | ||
parent?: VictoryStyleObject; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
@@ -212,3 +211,3 @@ tickComponent?: React.ReactElement; | ||
backgroundComponent?: React.ReactElement; | ||
backgroundStyle?: React.CSSProperties | React.CSSProperties[]; | ||
backgroundStyle?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
backgroundPadding?: PaddingProps | PaddingProps[]; | ||
@@ -230,3 +229,3 @@ capHeight?: StringOrNumberOrCallback; | ||
renderInPortal?: boolean; | ||
style?: React.CSSProperties | React.CSSProperties[]; | ||
style?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
tabIndex?: NumberOrCallback; | ||
@@ -323,14 +322,2 @@ text?: string[] | StringOrNumberOrCallback; | ||
// #region Victory Theme | ||
export type ThemeBaseProps = { | ||
width?: number; | ||
height?: number; | ||
colorScale?: string[]; | ||
padding?: number; | ||
offsetX?: number; | ||
offsetY?: number; | ||
}; | ||
export type TickProps = React.CSSProperties & { size?: number }; | ||
// Note: Many SVG attributes are missed in CSSProperties interface | ||
@@ -340,40 +327,44 @@ export interface VictoryThemeDefinition { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
axis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
offsetX?: number; | ||
offsetY?: number; | ||
} & VictoryCommonThemeProps; | ||
bar?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
boxplot?: { | ||
style?: { | ||
max?: React.CSSProperties; | ||
maxLabels?: React.CSSProperties; | ||
median?: React.CSSProperties; | ||
medianLabels?: React.CSSProperties; | ||
min?: React.CSSProperties; | ||
minLabels?: React.CSSProperties; | ||
q1?: React.CSSProperties; | ||
q1Labels?: React.CSSProperties; | ||
q3?: React.CSSProperties; | ||
q3Labels?: React.CSSProperties; | ||
max?: VictoryStyleObject; | ||
maxLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
median?: VictoryStyleObject; | ||
medianLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
min?: VictoryStyleObject; | ||
minLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
q1?: VictoryStyleObject; | ||
q1Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
q3?: VictoryStyleObject; | ||
q3Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
boxWidth?: number; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
candlestick?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
@@ -384,104 +375,123 @@ candleColors?: { | ||
}; | ||
} & ThemeBaseProps; | ||
chart?: ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
chart?: VictoryCommonThemeProps; | ||
dependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
offsetX?: number; | ||
offsetY?: number; | ||
orientation?: OrientationTypes; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
errorbar?: { | ||
borderWidth?: number; | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
group?: ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
group?: VictoryCommonThemeProps; | ||
independentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
offsetX?: number; | ||
offsetY?: number; | ||
orientation?: OrientationTypes; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
legend?: { | ||
gutter?: number; | ||
orientation?: "vertical" | "horizontal"; | ||
titleOrientation?: OrientationTypes; | ||
gutter?: number | BlockProps; | ||
rowGutter?: number | BlockProps; | ||
orientation?: string; | ||
titleOrientation?: string; | ||
style?: { | ||
data?: React.CSSProperties & { | ||
type?: ScatterSymbolType; | ||
data?: VictoryStyleObject & { | ||
type?: string; | ||
}; | ||
labels?: React.CSSProperties; | ||
title?: React.CSSProperties; | ||
border?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
title?: VictoryLabelStyleObject; | ||
}; | ||
} & ThemeBaseProps; | ||
itemsPerRow?: number; | ||
x?: number; | ||
y?: number; | ||
centerTitle?: boolean; | ||
borderPadding?: number | BlockProps; | ||
} & VictoryCommonThemeProps; | ||
line?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
pie?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
polarAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
polarDependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
polarIndependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
scatter?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
stack?: ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
stack?: VictoryCommonThemeProps; | ||
tooltip?: { | ||
style?: React.CSSProperties; | ||
flyoutStyle?: React.CSSProperties; | ||
cornerRadius?: number; | ||
pointerLength?: number; | ||
flyoutPadding?: number; | ||
style?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
flyoutStyle?: VictoryStyleObject; | ||
cornerRadius?: NumberOrCallback; | ||
pointerLength?: NumberOrCallback; | ||
flyoutPadding?: PaddingOrCallback; | ||
flyoutWidth?: NumberOrCallback; | ||
flyoutHeight?: NumberOrCallback; | ||
orientation?: OrientationOrCallback; | ||
pointerOrientation?: OrientationOrCallback; | ||
}; | ||
voronoi?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
flyout?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
flyout?: VictoryStyleObject; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
} | ||
@@ -624,4 +634,5 @@ | ||
export interface VictoryCommonProps { | ||
export interface VictoryCommonThemeProps { | ||
animate?: boolean | AnimatePropTypeInterface; | ||
colorScale?: ColorScalePropType; | ||
containerComponent?: React.ReactElement; | ||
@@ -651,2 +662,5 @@ domainPadding?: DomainPaddingPropType; | ||
width?: number; | ||
} | ||
export interface VictoryCommonProps extends VictoryCommonThemeProps { | ||
theme?: VictoryThemeDefinition; | ||
@@ -653,0 +667,0 @@ } |
@@ -8,2 +8,4 @@ "use strict"; | ||
var _keys2 = _interopRequireDefault(require("lodash/keys")); | ||
var _react = _interopRequireDefault(require("react")); | ||
@@ -70,3 +72,3 @@ | ||
return Object.keys(this.map).map(function (key) { | ||
return (0, _keys2.default)(this.map).map(function (key) { | ||
var el = _this2.map[key]; | ||
@@ -73,0 +75,0 @@ return el ? _react.default.cloneElement(el, { |
@@ -8,2 +8,4 @@ "use strict"; | ||
var _keys2 = _interopRequireDefault(require("lodash/keys")); | ||
var _includes2 = _interopRequireDefault(require("lodash/includes")); | ||
@@ -144,5 +146,5 @@ | ||
if (eventReturn.eventKey === "all") { | ||
return baseProps[childName] ? (0, _without2.default)(Object.keys(baseProps[childName]), "parent") : (0, _without2.default)(Object.keys(baseProps), "parent"); | ||
return baseProps[childName] ? (0, _without2.default)((0, _keys2.default)(baseProps[childName]), "parent") : (0, _without2.default)((0, _keys2.default)(baseProps), "parent"); | ||
} else if (eventReturn.eventKey === undefined && eventKey === "parent") { | ||
return baseProps[childName] ? Object.keys(baseProps[childName]) : Object.keys(baseProps); | ||
return baseProps[childName] ? (0, _keys2.default)(baseProps[childName]) : (0, _keys2.default)(baseProps); | ||
} | ||
@@ -179,3 +181,3 @@ | ||
if (state[key] && !Object.keys(state[key]).length) { | ||
if (state[key] && !(0, _keys2.default)(state[key]).length) { | ||
delete state[key]; | ||
@@ -207,3 +209,3 @@ } | ||
var allChildNames = childNames === "all" ? (0, _without2.default)(Object.keys(baseProps), "parent") : childNames; | ||
var allChildNames = childNames === "all" ? (0, _without2.default)((0, _keys2.default)(baseProps), "parent") : childNames; | ||
return Array.isArray(allChildNames) ? allChildNames.reduce(function (memo, childName) { | ||
@@ -254,3 +256,3 @@ return (0, _assign6.default)(memo, getReturnByChild(childName)); | ||
return Object.keys(events).reduce(function (memo, event) { | ||
return (0, _keys2.default)(events).reduce(function (memo, event) { | ||
memo[event] = onEvent; | ||
@@ -265,3 +267,3 @@ return memo; | ||
getPartialEvents: function (events, eventKey, childProps) { | ||
return events ? Object.keys(events).reduce(function (memo, eventName) { | ||
return events ? (0, _keys2.default)(events).reduce(function (memo, eventName) { | ||
var appliedEvent = function (evt) { | ||
@@ -333,3 +335,3 @@ return events[eventName](evt, childProps, eventKey, eventName); | ||
baseState = baseState || {}; | ||
var eventKeys = Object.keys(baseProps); | ||
var eventKeys = (0, _keys2.default)(baseProps); | ||
return eventKeys.reduce(function (memo, eventKey) { | ||
@@ -351,3 +353,3 @@ var keyState = baseState[eventKey] || {}; | ||
// will be used. (i.e. labels) | ||
var targets = (0, _uniq2.default)(Object.keys(keyProps).concat(Object.keys(keyState))); | ||
var targets = (0, _uniq2.default)((0, _keys2.default)(keyProps).concat((0, _keys2.default)(keyState))); | ||
memo[eventKey] = targets.reduce(function (m, target) { | ||
@@ -354,0 +356,0 @@ var identifier = { |
@@ -8,2 +8,4 @@ "use strict"; | ||
var _keys2 = _interopRequireDefault(require("lodash/keys")); | ||
var _assign2 = _interopRequireDefault(require("lodash/assign")); | ||
@@ -53,3 +55,3 @@ | ||
* @param {Object} originalObject: created object will be based on this object | ||
* @param {Array<String>} keys: an array of keys to omit from the new object | ||
* @param {Array<String>} ks: an array of keys to omit from the new object | ||
* @returns {Object} new object with same properties as originalObject | ||
@@ -60,3 +62,3 @@ */ | ||
function omit(originalObject) { | ||
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var ks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
// code based on babel's _objectWithoutProperties | ||
@@ -66,3 +68,3 @@ var newObject = {}; | ||
for (var key in originalObject) { | ||
if (keys.indexOf(key) >= 0) { | ||
if (ks.indexOf(key) >= 0) { | ||
continue; | ||
@@ -195,3 +197,3 @@ } | ||
function evaluateStyle(style, props) { | ||
if (!style || !Object.keys(style).some(function (value) { | ||
if (!style || !(0, _keys2.default)(style).some(function (value) { | ||
return (0, _isFunction2.default)(style[value]); | ||
@@ -202,3 +204,3 @@ })) { | ||
return Object.keys(style).reduce(function (prev, curr) { | ||
return (0, _keys2.default)(style).reduce(function (prev, curr) { | ||
prev[curr] = evaluateProp(style[curr], props); | ||
@@ -205,0 +207,0 @@ return prev; |
@@ -25,3 +25,4 @@ "use strict"; | ||
this.loop = this.loop.bind(this); | ||
this.timer = (0, _d3Timer.timer)(this.loop); | ||
this.timer = null; | ||
this.activeSubscriptions = 0; | ||
} | ||
@@ -49,3 +50,5 @@ | ||
value: function start() { | ||
this.timer.start(); | ||
if (!this.timer) { | ||
this.timer = (0, _d3Timer.timer)(this.loop); | ||
} | ||
} | ||
@@ -55,3 +58,6 @@ }, { | ||
value: function stop() { | ||
this.timer.stop(); | ||
if (this.timer) { | ||
this.timer.stop(); | ||
this.timer = null; | ||
} | ||
} | ||
@@ -62,3 +68,3 @@ }, { | ||
duration = this.shouldAnimate ? duration : 0; | ||
return this.subscribers.push({ | ||
var subscriptionID = this.subscribers.push({ | ||
startTime: (0, _d3Timer.now)(), | ||
@@ -68,2 +74,5 @@ callback: callback, | ||
}); | ||
this.activeSubscriptions++; | ||
this.start(); | ||
return subscriptionID; | ||
} | ||
@@ -73,5 +82,10 @@ }, { | ||
value: function unsubscribe(id) { | ||
if (id !== null) { | ||
if (id !== null && this.subscribers[id - 1]) { | ||
delete this.subscribers[id - 1]; | ||
this.activeSubscriptions--; | ||
} | ||
if (this.activeSubscriptions === 0) { | ||
this.stop(); | ||
} | ||
} | ||
@@ -78,0 +92,0 @@ }]); |
@@ -8,2 +8,4 @@ "use strict"; | ||
var _keys2 = _interopRequireDefault(require("lodash/keys")); | ||
var _identity2 = _interopRequireDefault(require("lodash/identity")); | ||
@@ -33,3 +35,3 @@ | ||
var hasDifference = false; | ||
var difference = Object.keys(a).reduce(function (_difference, key) { | ||
var difference = (0, _keys2.default)(a).reduce(function (_difference, key) { | ||
if (!(key in b)) { | ||
@@ -36,0 +38,0 @@ hasDifference = true; |
{ | ||
"name": "victory-core", | ||
"version": "35.3.3", | ||
"version": "35.3.4", | ||
"description": "Victory Core", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -88,9 +88,9 @@ import * as React from "react"; | ||
export interface CallbackArgs { | ||
active: boolean; | ||
data: any; | ||
datum: any; | ||
horizontal: boolean; | ||
active?: boolean; | ||
data?: any; | ||
datum?: any; | ||
horizontal?: boolean; | ||
index: number | string; | ||
x: number; | ||
y: number; | ||
x?: number; | ||
y?: number; | ||
scale?: { | ||
@@ -100,4 +100,9 @@ x?: D3Scale; | ||
}; | ||
tick?: any; | ||
ticks?: any; | ||
text?: any; | ||
} | ||
export type OrientationTypes = "top" | "bottom" | "left" | "right"; | ||
export type VictoryStringOrNumberCallback = (args: CallbackArgs) => string | number; | ||
@@ -107,2 +112,3 @@ export type VictoryNumberCallback = (args: CallbackArgs) => number; | ||
export type VictoryPaddingCallback = (args: CallbackArgs) => number | BlockProps; | ||
export type VictoryOrientationCallback = (args: CallbackArgs) => OrientationTypes; | ||
export type StringOrNumberOrCallback = string | number | VictoryStringOrNumberCallback; | ||
@@ -112,7 +118,6 @@ export type NumberOrCallback = number | VictoryNumberCallback; | ||
export type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback; | ||
export type OrientationOrCallback = OrientationTypes | VictoryOrientationCallback; | ||
export type SliceNumberOrCallback<T, P = null> = number | ((props: Omit<T, P>) => number); | ||
export type VictoryStyleObject = { [K in keyof React.CSSProperties]: StringOrNumberOrCallback }; | ||
export type StringOrNumberOrList = string | number | (string | number)[]; | ||
@@ -125,4 +130,11 @@ | ||
export type OrientationTypes = "top" | "bottom" | "left" | "right"; | ||
export type VictoryStyleObject = { [K in keyof React.CSSProperties]: StringOrNumberOrCallback }; | ||
export type LabelProps = React.CSSProperties & { | ||
angle?: number; | ||
verticalAnchor?: VerticalAnchorType; | ||
}; | ||
export type VictoryLabelStyleObject = { [K in keyof LabelProps]: StringOrNumberOrCallback }; | ||
/** | ||
@@ -134,3 +146,3 @@ * Style interface used in components/themeing | ||
data?: VictoryStyleObject; | ||
labels?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
border?: VictoryStyleObject; | ||
@@ -158,7 +170,6 @@ } | ||
export type TickLabelProps = React.CSSProperties & { | ||
angle?: number; | ||
verticalAnchor?: VerticalAnchorType; | ||
}; | ||
export type TickProps = React.CSSProperties & { size?: number }; | ||
export type VictoryTickStyleObject = { [K in keyof TickProps]: StringOrNumberOrCallback }; | ||
export interface VictoryAxisCommonProps { | ||
@@ -172,20 +183,8 @@ axisComponent?: React.ReactElement; | ||
style?: { | ||
parent?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
axis?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
axisLabel?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
grid?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
ticks?: { | ||
[K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); | ||
}; | ||
tickLabels?: { | ||
[K in keyof TickLabelProps]: string | number | ((tick?: any) => string | number); | ||
}; | ||
parent?: VictoryStyleObject; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
@@ -212,3 +211,3 @@ tickComponent?: React.ReactElement; | ||
backgroundComponent?: React.ReactElement; | ||
backgroundStyle?: React.CSSProperties | React.CSSProperties[]; | ||
backgroundStyle?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
backgroundPadding?: PaddingProps | PaddingProps[]; | ||
@@ -230,3 +229,3 @@ capHeight?: StringOrNumberOrCallback; | ||
renderInPortal?: boolean; | ||
style?: React.CSSProperties | React.CSSProperties[]; | ||
style?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
tabIndex?: NumberOrCallback; | ||
@@ -323,14 +322,2 @@ text?: string[] | StringOrNumberOrCallback; | ||
// #region Victory Theme | ||
export type ThemeBaseProps = { | ||
width?: number; | ||
height?: number; | ||
colorScale?: string[]; | ||
padding?: number; | ||
offsetX?: number; | ||
offsetY?: number; | ||
}; | ||
export type TickProps = React.CSSProperties & { size?: number }; | ||
// Note: Many SVG attributes are missed in CSSProperties interface | ||
@@ -340,40 +327,44 @@ export interface VictoryThemeDefinition { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
axis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
offsetX?: number; | ||
offsetY?: number; | ||
} & VictoryCommonThemeProps; | ||
bar?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
boxplot?: { | ||
style?: { | ||
max?: React.CSSProperties; | ||
maxLabels?: React.CSSProperties; | ||
median?: React.CSSProperties; | ||
medianLabels?: React.CSSProperties; | ||
min?: React.CSSProperties; | ||
minLabels?: React.CSSProperties; | ||
q1?: React.CSSProperties; | ||
q1Labels?: React.CSSProperties; | ||
q3?: React.CSSProperties; | ||
q3Labels?: React.CSSProperties; | ||
max?: VictoryStyleObject; | ||
maxLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
median?: VictoryStyleObject; | ||
medianLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
min?: VictoryStyleObject; | ||
minLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
q1?: VictoryStyleObject; | ||
q1Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
q3?: VictoryStyleObject; | ||
q3Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
boxWidth?: number; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
candlestick?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
@@ -384,104 +375,123 @@ candleColors?: { | ||
}; | ||
} & ThemeBaseProps; | ||
chart?: ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
chart?: VictoryCommonThemeProps; | ||
dependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
offsetX?: number; | ||
offsetY?: number; | ||
orientation?: OrientationTypes; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
errorbar?: { | ||
borderWidth?: number; | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
group?: ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
group?: VictoryCommonThemeProps; | ||
independentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
offsetX?: number; | ||
offsetY?: number; | ||
orientation?: OrientationTypes; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
legend?: { | ||
gutter?: number; | ||
orientation?: "vertical" | "horizontal"; | ||
titleOrientation?: OrientationTypes; | ||
gutter?: number | BlockProps; | ||
rowGutter?: number | BlockProps; | ||
orientation?: string; | ||
titleOrientation?: string; | ||
style?: { | ||
data?: React.CSSProperties & { | ||
type?: ScatterSymbolType; | ||
data?: VictoryStyleObject & { | ||
type?: string; | ||
}; | ||
labels?: React.CSSProperties; | ||
title?: React.CSSProperties; | ||
border?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
title?: VictoryLabelStyleObject; | ||
}; | ||
} & ThemeBaseProps; | ||
itemsPerRow?: number; | ||
x?: number; | ||
y?: number; | ||
centerTitle?: boolean; | ||
borderPadding?: number | BlockProps; | ||
} & VictoryCommonThemeProps; | ||
line?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
pie?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
polarAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
polarDependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
polarIndependentAxis?: { | ||
style?: { | ||
axis?: React.CSSProperties; | ||
axisLabel?: React.CSSProperties; | ||
grid?: React.CSSProperties; | ||
ticks?: TickProps; | ||
tickLabels?: React.CSSProperties; | ||
axis?: VictoryStyleObject; | ||
axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
grid?: VictoryStyleObject; | ||
ticks?: VictoryTickStyleObject; | ||
tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps; | ||
scatter?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
}; | ||
} & ThemeBaseProps; | ||
stack?: ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
stack?: VictoryCommonThemeProps; | ||
tooltip?: { | ||
style?: React.CSSProperties; | ||
flyoutStyle?: React.CSSProperties; | ||
cornerRadius?: number; | ||
pointerLength?: number; | ||
flyoutPadding?: number; | ||
style?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
flyoutStyle?: VictoryStyleObject; | ||
cornerRadius?: NumberOrCallback; | ||
pointerLength?: NumberOrCallback; | ||
flyoutPadding?: PaddingOrCallback; | ||
flyoutWidth?: NumberOrCallback; | ||
flyoutHeight?: NumberOrCallback; | ||
orientation?: OrientationOrCallback; | ||
pointerOrientation?: OrientationOrCallback; | ||
}; | ||
voronoi?: { | ||
style?: { | ||
data?: React.CSSProperties; | ||
labels?: React.CSSProperties; | ||
flyout?: React.CSSProperties; | ||
data?: VictoryStyleObject; | ||
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[]; | ||
flyout?: VictoryStyleObject; | ||
}; | ||
} & ThemeBaseProps; | ||
} & VictoryCommonThemeProps & | ||
VictoryDatableProps; | ||
} | ||
@@ -624,4 +634,5 @@ | ||
export interface VictoryCommonProps { | ||
export interface VictoryCommonThemeProps { | ||
animate?: boolean | AnimatePropTypeInterface; | ||
colorScale?: ColorScalePropType; | ||
containerComponent?: React.ReactElement; | ||
@@ -651,2 +662,5 @@ domainPadding?: DomainPaddingPropType; | ||
width?: number; | ||
} | ||
export interface VictoryCommonProps extends VictoryCommonThemeProps { | ||
theme?: VictoryThemeDefinition; | ||
@@ -653,0 +667,0 @@ } |
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import CustomPropTypes from "../victory-util/prop-types"; | ||
import { keys } from "lodash"; | ||
@@ -40,3 +41,3 @@ export default class Portal extends React.Component { | ||
getChildren() { | ||
return Object.keys(this.map).map((key) => { | ||
return keys(this.map).map((key) => { | ||
const el = this.map[key]; | ||
@@ -43,0 +44,0 @@ return el ? React.cloneElement(el, { key }) : el; |
@@ -1,2 +0,2 @@ | ||
import { assign, isEmpty, isFunction, without, pickBy, uniq, includes } from "lodash"; | ||
import { assign, isEmpty, isFunction, without, pickBy, uniq, includes, keys } from "lodash"; | ||
@@ -111,6 +111,6 @@ export default { | ||
return baseProps[childName] | ||
? without(Object.keys(baseProps[childName]), "parent") | ||
: without(Object.keys(baseProps), "parent"); | ||
? without(keys(baseProps[childName]), "parent") | ||
: without(keys(baseProps), "parent"); | ||
} else if (eventReturn.eventKey === undefined && eventKey === "parent") { | ||
return baseProps[childName] ? Object.keys(baseProps[childName]) : Object.keys(baseProps); | ||
return baseProps[childName] ? keys(baseProps[childName]) : keys(baseProps); | ||
} | ||
@@ -138,3 +138,3 @@ return eventReturn.eventKey !== undefined ? eventReturn.eventKey : eventKey; | ||
} | ||
if (state[key] && !Object.keys(state[key]).length) { | ||
if (state[key] && !keys(state[key]).length) { | ||
delete state[key]; | ||
@@ -171,4 +171,3 @@ } | ||
// returns an entire mutated state for all children | ||
const allChildNames = | ||
childNames === "all" ? without(Object.keys(baseProps), "parent") : childNames; | ||
const allChildNames = childNames === "all" ? without(keys(baseProps), "parent") : childNames; | ||
return Array.isArray(allChildNames) | ||
@@ -214,3 +213,3 @@ ? allChildNames.reduce((memo, childName) => { | ||
// returns a new events object with enhanced event handlers | ||
return Object.keys(events).reduce((memo, event) => { | ||
return keys(events).reduce((memo, event) => { | ||
memo[event] = onEvent; | ||
@@ -226,3 +225,3 @@ return memo; | ||
return events | ||
? Object.keys(events).reduce((memo, eventName) => { | ||
? keys(events).reduce((memo, eventName) => { | ||
const appliedEvent = (evt) => events[eventName](evt, childProps, eventKey, eventName); | ||
@@ -291,3 +290,3 @@ memo[eventName] = appliedEvent; | ||
const eventKeys = Object.keys(baseProps); | ||
const eventKeys = keys(baseProps); | ||
return eventKeys.reduce((memo, eventKey) => { | ||
@@ -303,3 +302,3 @@ const keyState = baseState[eventKey] || {}; | ||
// will be used. (i.e. labels) | ||
const targets = uniq(Object.keys(keyProps).concat(Object.keys(keyState))); | ||
const targets = uniq(keys(keyProps).concat(keys(keyState))); | ||
memo[eventKey] = targets.reduce((m, target) => { | ||
@@ -306,0 +305,0 @@ const identifier = { eventKey, target, childName }; |
/* eslint-disable func-style */ | ||
/* eslint-disable no-use-before-define */ | ||
import React from "react"; | ||
import { defaults, isFunction, property, pick, assign } from "lodash"; | ||
import { defaults, isFunction, property, pick, assign, keys } from "lodash"; | ||
@@ -33,10 +33,10 @@ // Private Functions | ||
* @param {Object} originalObject: created object will be based on this object | ||
* @param {Array<String>} keys: an array of keys to omit from the new object | ||
* @param {Array<String>} ks: an array of keys to omit from the new object | ||
* @returns {Object} new object with same properties as originalObject | ||
*/ | ||
function omit(originalObject, keys = []) { | ||
function omit(originalObject, ks = []) { | ||
// code based on babel's _objectWithoutProperties | ||
const newObject = {}; | ||
for (const key in originalObject) { | ||
if (keys.indexOf(key) >= 0) { | ||
if (ks.indexOf(key) >= 0) { | ||
continue; | ||
@@ -132,6 +132,6 @@ } | ||
function evaluateStyle(style, props) { | ||
if (!style || !Object.keys(style).some((value) => isFunction(style[value]))) { | ||
if (!style || !keys(style).some((value) => isFunction(style[value]))) { | ||
return style; | ||
} | ||
return Object.keys(style).reduce((prev, curr) => { | ||
return keys(style).reduce((prev, curr) => { | ||
prev[curr] = evaluateProp(style[curr], props); | ||
@@ -138,0 +138,0 @@ return prev; |
@@ -8,3 +8,4 @@ import { timer, now } from "d3-timer"; | ||
this.loop = this.loop.bind(this); | ||
this.timer = timer(this.loop); | ||
this.timer = null; | ||
this.activeSubscriptions = 0; | ||
} | ||
@@ -27,7 +28,12 @@ | ||
start() { | ||
this.timer.start(); | ||
if (!this.timer) { | ||
this.timer = timer(this.loop); | ||
} | ||
} | ||
stop() { | ||
this.timer.stop(); | ||
if (this.timer) { | ||
this.timer.stop(); | ||
this.timer = null; | ||
} | ||
} | ||
@@ -37,3 +43,3 @@ | ||
duration = this.shouldAnimate ? duration : 0; | ||
return this.subscribers.push({ | ||
const subscriptionID = this.subscribers.push({ | ||
startTime: now(), | ||
@@ -43,9 +49,16 @@ callback, | ||
}); | ||
this.activeSubscriptions++; | ||
this.start(); | ||
return subscriptionID; | ||
} | ||
unsubscribe(id) { | ||
if (id !== null) { | ||
if (id !== null && this.subscribers[id - 1]) { | ||
delete this.subscribers[id - 1]; | ||
this.activeSubscriptions--; | ||
} | ||
if (this.activeSubscriptions === 0) { | ||
this.stop(); | ||
} | ||
} | ||
} |
/* eslint-disable func-style */ | ||
import { assign, defaults, identity } from "lodash"; | ||
import { assign, defaults, identity, keys } from "lodash"; | ||
import React from "react"; | ||
@@ -19,3 +19,3 @@ | ||
let hasDifference = false; | ||
const difference = Object.keys(a).reduce((_difference, key) => { | ||
const difference = keys(a).reduce((_difference, key) => { | ||
if (!(key in b)) { | ||
@@ -22,0 +22,0 @@ hasDifference = true; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2272987
30926