Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

victory-candlestick

Package Overview
Dependencies
Maintainers
16
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

victory-candlestick - npm Package Compare versions

Comparing version 36.8.1 to 36.8.2

es/candle.d.ts

6

CHANGELOG.md
# victory-candlestick
## 36.8.2
### Patch Changes
- Migrate victory-candlestick to TypeScript ([#2716](https://github.com/FormidableLabs/victory/pull/2716))
## 36.8.1

@@ -4,0 +10,0 @@

63

es/candle.js

@@ -11,6 +11,4 @@ import _isFunction from "lodash/isFunction";

/* eslint no-magic-numbers: ["error", { "ignore": [0, 0.5, 1, 2] }]*/
import React from "react";
import PropTypes from "prop-types";
import { Helpers, CommonProps, Line, Rect } from "victory-core";
import { Helpers, Line, Rect } from "victory-core";

@@ -120,21 +118,19 @@ var getCandleWidth = function (candleWidth, props) {

};
export var Candle = function (props) {
var modifiedProps = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props));
var ariaLabel = modifiedProps.ariaLabel,
events = modifiedProps.events,
groupComponent = modifiedProps.groupComponent,
clipPath = modifiedProps.clipPath,
rectComponent = modifiedProps.rectComponent,
lineComponent = modifiedProps.lineComponent,
role = modifiedProps.role,
shapeRendering = modifiedProps.shapeRendering,
className = modifiedProps.className,
wickStrokeWidth = modifiedProps.wickStrokeWidth,
transform = modifiedProps.transform,
style = modifiedProps.style,
desc = modifiedProps.desc,
tabIndex = modifiedProps.tabIndex;
var Candle = function (props) {
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props));
var _props = props,
ariaLabel = _props.ariaLabel,
events = _props.events,
groupComponent = _props.groupComponent,
clipPath = _props.clipPath,
rectComponent = _props.rectComponent,
lineComponent = _props.lineComponent,
role = _props.role,
shapeRendering = _props.shapeRendering,
className = _props.className,
wickStrokeWidth = _props.wickStrokeWidth,
transform = _props.transform,
style = _props.style,
desc = _props.desc,
tabIndex = _props.tabIndex;
var wickStyle = _defaults({

@@ -155,26 +151,9 @@ strokeWidth: wickStrokeWidth

var candleProps = _assign(getCandleProps(props, style), sharedProps);
var candleProps = _assign(getCandleProps(modifiedProps, style), sharedProps);
var highWickProps = _assign(getHighWickProps(props, wickStyle), sharedProps);
var highWickProps = _assign(getHighWickProps(modifiedProps, wickStyle), sharedProps);
var lowWickProps = _assign(getLowWickProps(props, wickStyle), sharedProps);
var lowWickProps = _assign(getLowWickProps(modifiedProps, wickStyle), sharedProps);
return /*#__PURE__*/React.cloneElement(groupComponent, {}, [/*#__PURE__*/React.cloneElement(rectComponent, candleProps), /*#__PURE__*/React.cloneElement(lineComponent, highWickProps), /*#__PURE__*/React.cloneElement(lineComponent, lowWickProps)]);
};
Candle.propTypes = _objectSpread(_objectSpread({}, CommonProps.primitiveProps), {}, {
candleRatio: PropTypes.number,
candleWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
close: PropTypes.number,
datum: PropTypes.object,
groupComponent: PropTypes.element,
high: PropTypes.number,
lineComponent: PropTypes.element,
low: PropTypes.number,
open: PropTypes.number,
rectComponent: PropTypes.element,
wickStrokeWidth: PropTypes.number,
width: PropTypes.number,
x: PropTypes.number
});
export default Candle;
};

@@ -8,2 +8,3 @@ import _isPlainObject from "lodash/isPlainObject";

var TYPES = ["close", "open", "high", "low"];
var DEFAULT_CANDLE_WIDTH = 8;
export var getData = function (props) {

@@ -192,4 +193,3 @@ var accessorTypes = ["x", "high", "low", "close", "open"];

candleWidth = props.candleWidth,
scale = props.scale,
defaultCandleWidth = props.defaultCandleWidth;
scale = props.scale;

@@ -206,3 +206,3 @@ if (candleWidth) {

var candleRatio = props.candleRatio || 0.5;
var defaultWidth = candleRatio * (data.length < 2 ? defaultCandleWidth : extent / candles);
var defaultWidth = candleRatio * (data.length < 2 ? DEFAULT_CANDLE_WIDTH : extent / candles);
return Math.max(1, defaultWidth);

@@ -209,0 +209,0 @@ };

@@ -1,110 +0,3 @@

import * as React from "react";
import {
EventPropTypeInterface,
OrientationTypes,
StringOrNumberOrCallback,
VictoryCommonProps,
VictoryCommonPrimitiveProps,
VictoryDatableProps,
VictoryStyleObject,
VictoryLabelStyleObject,
VictoryLabelableProps,
VictoryMultiLabelableProps,
} from "victory-core";
export interface VictoryCandlestickStyleInterface {
close?: VictoryStyleObject;
closeLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
data?: VictoryStyleObject;
high?: VictoryStyleObject;
highLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
low?: VictoryStyleObject;
lowLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
open?: VictoryStyleObject;
openLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
parent?: VictoryStyleObject;
}
export type VictoryCandlestickLabelsType =
| (string | number)[]
| boolean
| ((datum: any) => number);
export interface VictoryCandlestickProps
extends Omit<VictoryCommonProps, "polar">,
VictoryDatableProps,
VictoryLabelableProps,
VictoryMultiLabelableProps {
candleColors?: {
positive?: string;
negative?: string;
};
candleRatio?: number;
candleWidth?: number | Function;
close?: StringOrNumberOrCallback | string[];
closeLabelComponent?: React.ReactElement;
closeLabels?: VictoryCandlestickLabelsType;
eventKey?: StringOrNumberOrCallback | string[];
events?: EventPropTypeInterface<
| "data"
| "labels"
| "open"
| "openLabels"
| "close"
| "closeLabels"
| "low"
| "lowLabels"
| "high"
| "highLabels",
StringOrNumberOrCallback | string[]
>[];
high?: StringOrNumberOrCallback | string[];
highLabelComponenet?: React.ReactElement;
highLabels?: VictoryCandlestickLabelsType;
labelOrientation?:
| OrientationTypes
| {
open?: OrientationTypes;
close?: OrientationTypes;
low?: OrientationTypes;
high?: OrientationTypes;
};
low?: StringOrNumberOrCallback | string[];
lowLabelComponent?: React.ReactElement;
lowLabels?: VictoryCandlestickLabelsType;
open?: StringOrNumberOrCallback | string[];
openLabelComponent?: React.ReactElement;
openLabels?: VictoryCandlestickLabelsType;
size?: number;
style?: VictoryCandlestickStyleInterface;
wickStrokeWidth?: number;
}
/**
* VictoryCandlestick renders a dataset as a series of candlesticks.
* VictoryCandlestick can be composed with VictoryChart to create candlestick charts.
*/
export class VictoryCandlestick extends React.Component<
VictoryCandlestickProps,
any
> {}
export interface CandleProps extends VictoryCommonPrimitiveProps {
candleRatio?: number;
candleWidth?: number | Function;
close?: number;
datum?: any;
groupComponent?: React.ReactElement;
high?: number;
lineComponent?: React.ReactElement;
low?: number;
open?: number;
rectComponent?: React.ReactElement;
wickStrokeWidth?: number;
width?: number;
x?: number;
}
export class Candle extends React.Component<CandleProps, any> {}
export * from "./victory-candlestick";
export * from "./candle";
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

export { default as VictoryCandlestick } from "./victory-candlestick";
export { default as Candle } from "./candle";
export * from "./victory-candlestick";
export * from "./candle";

@@ -1,10 +0,3 @@

import _flatten from "lodash/flatten";
import _isNil from "lodash/isNil";
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; }
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; }
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; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

@@ -42,9 +35,8 @@

import PropTypes from "prop-types";
import React from "react";
import { PropTypes as CustomPropTypes, Helpers, VictoryLabel, addEvents, VictoryContainer, VictoryTheme, DefaultTransitions, CommonProps, UserProps } from "victory-core";
import Candle from "./candle";
import { Helpers, VictoryLabel, addEvents, VictoryContainer, VictoryTheme, DefaultTransitions, UserProps } from "victory-core";
import { Candle } from "./candle";
import { getDomain, getData, getBaseProps } from "./helper-methods";
/* eslint-disable no-magic-numbers */
var fallbackProps = {

@@ -130,16 +122,33 @@ width: 450,

return !_isNil(datum._x) && !_isNil(datum._y);
};
}; // eslint-disable-next-line @typescript-eslint/no-empty-interface
var VictoryCandlestick = /*#__PURE__*/function (_React$Component) {
_inherits(VictoryCandlestick, _React$Component);
var _super = _createSuper(VictoryCandlestick);
/**
* VictoryCandlestick renders a dataset as a series of candlesticks.
* VictoryCandlestick can be composed with VictoryChart to create candlestick charts.
*/
var VictoryCandlestickBase = /*#__PURE__*/function (_React$Component) {
_inherits(VictoryCandlestickBase, _React$Component);
function VictoryCandlestick() {
_classCallCheck(this, VictoryCandlestick);
var _super = _createSuper(VictoryCandlestickBase);
return _super.apply(this, arguments);
function VictoryCandlestickBase() {
var _this;
_classCallCheck(this, VictoryCandlestickBase);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_this.shouldRenderDatum = function (datum) {
return !_isNil(datum._x) && !_isNil(datum._high) && !_isNil(datum._low) && !_isNil(datum._close) && !_isNil(datum._open);
};
return _this;
}
_createClass(VictoryCandlestick, [{
_createClass(VictoryCandlestickBase, [{
key: "shouldAnimate",

@@ -151,10 +160,5 @@ value: // Overridden in native versions

}, {
key: "shouldRenderDatum",
value: function shouldRenderDatum(datum) {
return !_isNil(datum._x) && !_isNil(datum._high) && !_isNil(datum._low) && !_isNil(datum._close) && !_isNil(datum._open);
}
}, {
key: "renderCandleData",
value: function renderCandleData(props) {
var _this = this;
var _this2 = this;

@@ -166,18 +170,28 @@ var shouldRenderDatum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : datumHasXandY;

var types = ["close", "open", "low", "high"];
var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
var dataProps = _this.getComponentProps(dataComponent, "data", index);
if (shouldRenderDatum(dataProps.datum)) {
validDataComponents.push( /*#__PURE__*/React.cloneElement(dataComponent, dataProps));
}
if (!groupComponent) {
throw new Error("VictoryCandlestick expects a groupComponent prop");
}
return validDataComponents;
}, []);
var children = [];
var labelComponents = _flatten(types.map(function (type) {
var components = _this.dataKeys.map(function (key, index) {
if (dataComponent) {
var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
var dataProps = _this2.getComponentProps(dataComponent, "data", index);
if (shouldRenderDatum(dataProps.datum)) {
validDataComponents.push( /*#__PURE__*/React.cloneElement(dataComponent, dataProps));
}
return validDataComponents;
}, []);
children.push.apply(children, _toConsumableArray(dataComponents));
}
var labelComponents = types.flatMap(function (type) {
return _this2.dataKeys.map(function (key, index) {
var name = "".concat(type, "Labels");
var baseComponent = props["".concat(type, "LabelComponent")];
var labelProps = _this.getComponentProps(baseComponent, name, index);
var labelProps = _this2.getComponentProps(baseComponent, name, index);

@@ -189,17 +203,23 @@ if (labelProps.text !== undefined && labelProps.text !== null) {

return undefined;
}).filter(function (comp) {
return comp !== undefined;
});
});
children.push.apply(children, _toConsumableArray(labelComponents));
return components.filter(Boolean);
}));
if (labelComponent) {
var labelsComponents = this.dataKeys.map(function (_dataKey, index) {
var labelProps = _this2.getComponentProps(labelComponent, "labels", index);
var labelsComponents = this.dataKeys.map(function (_dataKey, index) {
var labelProps = _this.getComponentProps(labelComponent, "labels", index);
if (labelProps.text !== undefined && labelProps.text !== null) {
return /*#__PURE__*/React.cloneElement(labelComponent, labelProps);
}
if (labelProps.text !== undefined && labelProps.text !== null) {
return /*#__PURE__*/React.cloneElement(labelComponent, labelProps);
}
return undefined;
}).filter(function (comp) {
return comp !== undefined;
});
children.push.apply(children, _toConsumableArray(labelsComponents));
}
return undefined;
}).filter(Boolean);
var children = [].concat(_toConsumableArray(dataComponents), _toConsumableArray(labelComponents), _toConsumableArray(labelsComponents));
return this.renderContainer(groupComponent, children);

@@ -224,55 +244,10 @@ }

return VictoryCandlestick;
return VictoryCandlestickBase;
}(React.Component);
VictoryCandlestick.animationWhitelist = ["data", "domain", "height", "padding", "samples", "size", "style", "width"];
VictoryCandlestick.displayName = "VictoryCandlestick";
VictoryCandlestick.role = "candlestick";
VictoryCandlestick.defaultTransitions = DefaultTransitions.discreteTransitions();
VictoryCandlestick.propTypes = _objectSpread(_objectSpread(_objectSpread({}, CommonProps.baseProps), CommonProps.dataProps), {}, {
candleColors: PropTypes.shape({
positive: PropTypes.string,
negative: PropTypes.string
}),
candleRatio: PropTypes.number,
candleWidth: PropTypes.oneOfType([PropTypes.func, PropTypes.number]),
close: PropTypes.oneOfType([PropTypes.func, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
closeLabelComponent: PropTypes.element,
closeLabels: PropTypes.oneOfType([PropTypes.func, PropTypes.array, PropTypes.bool]),
events: PropTypes.arrayOf(PropTypes.shape({
target: PropTypes.oneOf(["data", "labels", "open", "openLabels", "close", "closeLabels", "low", "lowLabels", "high", "highLabels"]),
eventKey: PropTypes.oneOfType([PropTypes.array, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), PropTypes.string]),
eventHandlers: PropTypes.object
})),
high: PropTypes.oneOfType([PropTypes.func, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
highLabelComponent: PropTypes.element,
highLabels: PropTypes.oneOfType([PropTypes.func, PropTypes.array, PropTypes.bool]),
labelOrientation: PropTypes.oneOfType([PropTypes.oneOf(["top", "bottom", "left", "right"]), PropTypes.shape({
open: PropTypes.oneOf(["top", "bottom", "left", "right"]),
close: PropTypes.oneOf(["top", "bottom", "left", "right"]),
low: PropTypes.oneOf(["top", "bottom", "left", "right"]),
high: PropTypes.oneOf(["top", "bottom", "left", "right"])
})]),
low: PropTypes.oneOfType([PropTypes.func, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
lowLabelComponent: PropTypes.element,
lowLabels: PropTypes.oneOfType([PropTypes.func, PropTypes.array, PropTypes.bool]),
open: PropTypes.oneOfType([PropTypes.func, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
openLabelComponent: PropTypes.element,
openLabels: PropTypes.oneOfType([PropTypes.func, PropTypes.array, PropTypes.bool]),
style: PropTypes.shape({
data: PropTypes.object,
labels: PropTypes.object,
close: PropTypes.object,
closeLabels: PropTypes.object,
open: PropTypes.object,
openLabels: PropTypes.object,
high: PropTypes.object,
highLabels: PropTypes.object,
low: PropTypes.object,
lowLabels: PropTypes.object
}),
wickStrokeWidth: PropTypes.number
});
VictoryCandlestick.defaultProps = {
defaultCandleWidth: 8,
VictoryCandlestickBase.animationWhitelist = ["data", "domain", "height", "padding", "samples", "size", "style", "width"];
VictoryCandlestickBase.displayName = "VictoryCandlestick";
VictoryCandlestickBase.role = "candlestick";
VictoryCandlestickBase.defaultTransitions = DefaultTransitions.discreteTransitions();
VictoryCandlestickBase.defaultProps = {
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),

@@ -294,10 +269,10 @@ data: defaultData,

};
VictoryCandlestick.getDomain = getDomain;
VictoryCandlestick.getData = getData;
VictoryCandlestickBase.getDomain = getDomain;
VictoryCandlestickBase.getData = getData;
VictoryCandlestick.getBaseProps = function (props) {
VictoryCandlestickBase.getBaseProps = function (props) {
return getBaseProps(props, fallbackProps);
};
VictoryCandlestick.expectedComponents = ["openLabelComponent", "closeLabelComponent", "highLabelComponent", "lowLabelComponent", "dataComponent", "labelComponent", "groupComponent", "containerComponent"];
export default addEvents(VictoryCandlestick, options);
VictoryCandlestickBase.expectedComponents = ["openLabelComponent", "closeLabelComponent", "highLabelComponent", "lowLabelComponent", "dataComponent", "labelComponent", "groupComponent", "containerComponent"];
export var VictoryCandlestick = addEvents(VictoryCandlestickBase, options);

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = void 0;
exports.Candle = void 0;

@@ -17,4 +17,2 @@ var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));

var _propTypes = _interopRequireDefault(require("prop-types"));
var _victoryCore = require("victory-core");

@@ -141,18 +139,17 @@

var Candle = function (props) {
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props));
var _props = props,
ariaLabel = _props.ariaLabel,
events = _props.events,
groupComponent = _props.groupComponent,
clipPath = _props.clipPath,
rectComponent = _props.rectComponent,
lineComponent = _props.lineComponent,
role = _props.role,
shapeRendering = _props.shapeRendering,
className = _props.className,
wickStrokeWidth = _props.wickStrokeWidth,
transform = _props.transform,
style = _props.style,
desc = _props.desc,
tabIndex = _props.tabIndex;
var modifiedProps = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props));
var ariaLabel = modifiedProps.ariaLabel,
events = modifiedProps.events,
groupComponent = modifiedProps.groupComponent,
clipPath = modifiedProps.clipPath,
rectComponent = modifiedProps.rectComponent,
lineComponent = modifiedProps.lineComponent,
role = modifiedProps.role,
shapeRendering = modifiedProps.shapeRendering,
className = modifiedProps.className,
wickStrokeWidth = modifiedProps.wickStrokeWidth,
transform = modifiedProps.transform,
style = modifiedProps.style,
desc = modifiedProps.desc,
tabIndex = modifiedProps.tabIndex;
var wickStyle = (0, _defaults2.default)({

@@ -173,24 +170,8 @@ strokeWidth: wickStrokeWidth

var candleProps = (0, _assign2.default)(getCandleProps(props, style), sharedProps);
var highWickProps = (0, _assign2.default)(getHighWickProps(props, wickStyle), sharedProps);
var lowWickProps = (0, _assign2.default)(getLowWickProps(props, wickStyle), sharedProps);
var candleProps = (0, _assign2.default)(getCandleProps(modifiedProps, style), sharedProps);
var highWickProps = (0, _assign2.default)(getHighWickProps(modifiedProps, wickStyle), sharedProps);
var lowWickProps = (0, _assign2.default)(getLowWickProps(modifiedProps, wickStyle), sharedProps);
return /*#__PURE__*/_react.default.cloneElement(groupComponent, {}, [/*#__PURE__*/_react.default.cloneElement(rectComponent, candleProps), /*#__PURE__*/_react.default.cloneElement(lineComponent, highWickProps), /*#__PURE__*/_react.default.cloneElement(lineComponent, lowWickProps)]);
};
Candle.propTypes = _objectSpread(_objectSpread({}, _victoryCore.CommonProps.primitiveProps), {}, {
candleRatio: _propTypes.default.number,
candleWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.func]),
close: _propTypes.default.number,
datum: _propTypes.default.object,
groupComponent: _propTypes.default.element,
high: _propTypes.default.number,
lineComponent: _propTypes.default.element,
low: _propTypes.default.number,
open: _propTypes.default.number,
rectComponent: _propTypes.default.element,
wickStrokeWidth: _propTypes.default.number,
width: _propTypes.default.number,
x: _propTypes.default.number
});
var _default = Candle;
exports.default = _default;
exports.Candle = Candle;

@@ -23,2 +23,3 @@ "use strict";

var TYPES = ["close", "open", "high", "low"];
var DEFAULT_CANDLE_WIDTH = 8;

@@ -218,4 +219,3 @@ var getData = function (props) {

candleWidth = props.candleWidth,
scale = props.scale,
defaultCandleWidth = props.defaultCandleWidth;
scale = props.scale;

@@ -232,3 +232,3 @@ if (candleWidth) {

var candleRatio = props.candleRatio || 0.5;
var defaultWidth = candleRatio * (data.length < 2 ? defaultCandleWidth : extent / candles);
var defaultWidth = candleRatio * (data.length < 2 ? DEFAULT_CANDLE_WIDTH : extent / candles);
return Math.max(1, defaultWidth);

@@ -235,0 +235,0 @@ };

@@ -1,110 +0,3 @@

import * as React from "react";
import {
EventPropTypeInterface,
OrientationTypes,
StringOrNumberOrCallback,
VictoryCommonProps,
VictoryCommonPrimitiveProps,
VictoryDatableProps,
VictoryStyleObject,
VictoryLabelStyleObject,
VictoryLabelableProps,
VictoryMultiLabelableProps,
} from "victory-core";
export interface VictoryCandlestickStyleInterface {
close?: VictoryStyleObject;
closeLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
data?: VictoryStyleObject;
high?: VictoryStyleObject;
highLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
low?: VictoryStyleObject;
lowLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
open?: VictoryStyleObject;
openLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
parent?: VictoryStyleObject;
}
export type VictoryCandlestickLabelsType =
| (string | number)[]
| boolean
| ((datum: any) => number);
export interface VictoryCandlestickProps
extends Omit<VictoryCommonProps, "polar">,
VictoryDatableProps,
VictoryLabelableProps,
VictoryMultiLabelableProps {
candleColors?: {
positive?: string;
negative?: string;
};
candleRatio?: number;
candleWidth?: number | Function;
close?: StringOrNumberOrCallback | string[];
closeLabelComponent?: React.ReactElement;
closeLabels?: VictoryCandlestickLabelsType;
eventKey?: StringOrNumberOrCallback | string[];
events?: EventPropTypeInterface<
| "data"
| "labels"
| "open"
| "openLabels"
| "close"
| "closeLabels"
| "low"
| "lowLabels"
| "high"
| "highLabels",
StringOrNumberOrCallback | string[]
>[];
high?: StringOrNumberOrCallback | string[];
highLabelComponenet?: React.ReactElement;
highLabels?: VictoryCandlestickLabelsType;
labelOrientation?:
| OrientationTypes
| {
open?: OrientationTypes;
close?: OrientationTypes;
low?: OrientationTypes;
high?: OrientationTypes;
};
low?: StringOrNumberOrCallback | string[];
lowLabelComponent?: React.ReactElement;
lowLabels?: VictoryCandlestickLabelsType;
open?: StringOrNumberOrCallback | string[];
openLabelComponent?: React.ReactElement;
openLabels?: VictoryCandlestickLabelsType;
size?: number;
style?: VictoryCandlestickStyleInterface;
wickStrokeWidth?: number;
}
/**
* VictoryCandlestick renders a dataset as a series of candlesticks.
* VictoryCandlestick can be composed with VictoryChart to create candlestick charts.
*/
export class VictoryCandlestick extends React.Component<
VictoryCandlestickProps,
any
> {}
export interface CandleProps extends VictoryCommonPrimitiveProps {
candleRatio?: number;
candleWidth?: number | Function;
close?: number;
datum?: any;
groupComponent?: React.ReactElement;
high?: number;
lineComponent?: React.ReactElement;
low?: number;
open?: number;
rectComponent?: React.ReactElement;
wickStrokeWidth?: number;
width?: number;
x?: number;
}
export class Candle extends React.Component<CandleProps, any> {}
export * from "./victory-candlestick";
export * from "./candle";
//# sourceMappingURL=index.d.ts.map

@@ -6,19 +6,27 @@ "use strict";

});
Object.defineProperty(exports, "Candle", {
enumerable: true,
get: function () {
return _candle.default;
}
var _victoryCandlestick = require("./victory-candlestick");
Object.keys(_victoryCandlestick).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _victoryCandlestick[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _victoryCandlestick[key];
}
});
});
Object.defineProperty(exports, "VictoryCandlestick", {
enumerable: true,
get: function () {
return _victoryCandlestick.default;
}
});
var _victoryCandlestick = _interopRequireDefault(require("./victory-candlestick"));
var _candle = require("./candle");
var _candle = _interopRequireDefault(require("./candle"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.keys(_candle).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _candle[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _candle[key];
}
});
});

@@ -6,10 +6,6 @@ "use strict";

});
exports.default = void 0;
exports.VictoryCandlestick = void 0;
var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
var _isNil2 = _interopRequireDefault(require("lodash/isNil"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));

@@ -19,3 +15,3 @@

var _candle = _interopRequireDefault(require("./candle"));
var _candle = require("./candle");

@@ -26,8 +22,2 @@ var _helperMethods = require("./helper-methods");

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; }
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; }
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; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

@@ -146,16 +136,33 @@

return !(0, _isNil2.default)(datum._x) && !(0, _isNil2.default)(datum._y);
};
}; // eslint-disable-next-line @typescript-eslint/no-empty-interface
var VictoryCandlestick = /*#__PURE__*/function (_React$Component) {
_inherits(VictoryCandlestick, _React$Component);
var _super = _createSuper(VictoryCandlestick);
/**
* VictoryCandlestick renders a dataset as a series of candlesticks.
* VictoryCandlestick can be composed with VictoryChart to create candlestick charts.
*/
var VictoryCandlestickBase = /*#__PURE__*/function (_React$Component) {
_inherits(VictoryCandlestickBase, _React$Component);
function VictoryCandlestick() {
_classCallCheck(this, VictoryCandlestick);
var _super = _createSuper(VictoryCandlestickBase);
return _super.apply(this, arguments);
function VictoryCandlestickBase() {
var _this;
_classCallCheck(this, VictoryCandlestickBase);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_this.shouldRenderDatum = function (datum) {
return !(0, _isNil2.default)(datum._x) && !(0, _isNil2.default)(datum._high) && !(0, _isNil2.default)(datum._low) && !(0, _isNil2.default)(datum._close) && !(0, _isNil2.default)(datum._open);
};
return _this;
}
_createClass(VictoryCandlestick, [{
_createClass(VictoryCandlestickBase, [{
key: "shouldAnimate",

@@ -167,10 +174,5 @@ value: // Overridden in native versions

}, {
key: "shouldRenderDatum",
value: function shouldRenderDatum(datum) {
return !(0, _isNil2.default)(datum._x) && !(0, _isNil2.default)(datum._high) && !(0, _isNil2.default)(datum._low) && !(0, _isNil2.default)(datum._close) && !(0, _isNil2.default)(datum._open);
}
}, {
key: "renderCandleData",
value: function renderCandleData(props) {
var _this = this;
var _this2 = this;

@@ -182,17 +184,28 @@ var shouldRenderDatum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : datumHasXandY;

var types = ["close", "open", "low", "high"];
var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
var dataProps = _this.getComponentProps(dataComponent, "data", index);
if (shouldRenderDatum(dataProps.datum)) {
validDataComponents.push( /*#__PURE__*/_react.default.cloneElement(dataComponent, dataProps));
}
if (!groupComponent) {
throw new Error("VictoryCandlestick expects a groupComponent prop");
}
return validDataComponents;
}, []);
var labelComponents = (0, _flatten2.default)(types.map(function (type) {
var components = _this.dataKeys.map(function (key, index) {
var children = [];
if (dataComponent) {
var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
var dataProps = _this2.getComponentProps(dataComponent, "data", index);
if (shouldRenderDatum(dataProps.datum)) {
validDataComponents.push( /*#__PURE__*/_react.default.cloneElement(dataComponent, dataProps));
}
return validDataComponents;
}, []);
children.push.apply(children, _toConsumableArray(dataComponents));
}
var labelComponents = types.flatMap(function (type) {
return _this2.dataKeys.map(function (key, index) {
var name = "".concat(type, "Labels");
var baseComponent = props["".concat(type, "LabelComponent")];
var labelProps = _this.getComponentProps(baseComponent, name, index);
var labelProps = _this2.getComponentProps(baseComponent, name, index);

@@ -204,16 +217,23 @@ if (labelProps.text !== undefined && labelProps.text !== null) {

return undefined;
}).filter(function (comp) {
return comp !== undefined;
});
});
children.push.apply(children, _toConsumableArray(labelComponents));
return components.filter(Boolean);
}));
var labelsComponents = this.dataKeys.map(function (_dataKey, index) {
var labelProps = _this.getComponentProps(labelComponent, "labels", index);
if (labelComponent) {
var labelsComponents = this.dataKeys.map(function (_dataKey, index) {
var labelProps = _this2.getComponentProps(labelComponent, "labels", index);
if (labelProps.text !== undefined && labelProps.text !== null) {
return /*#__PURE__*/_react.default.cloneElement(labelComponent, labelProps);
}
if (labelProps.text !== undefined && labelProps.text !== null) {
return /*#__PURE__*/_react.default.cloneElement(labelComponent, labelProps);
}
return undefined;
}).filter(Boolean);
var children = [].concat(_toConsumableArray(dataComponents), _toConsumableArray(labelComponents), _toConsumableArray(labelsComponents));
return undefined;
}).filter(function (comp) {
return comp !== undefined;
});
children.push.apply(children, _toConsumableArray(labelsComponents));
}
return this.renderContainer(groupComponent, children);

@@ -239,58 +259,13 @@ }

return VictoryCandlestick;
return VictoryCandlestickBase;
}(_react.default.Component);
VictoryCandlestick.animationWhitelist = ["data", "domain", "height", "padding", "samples", "size", "style", "width"];
VictoryCandlestick.displayName = "VictoryCandlestick";
VictoryCandlestick.role = "candlestick";
VictoryCandlestick.defaultTransitions = _victoryCore.DefaultTransitions.discreteTransitions();
VictoryCandlestick.propTypes = _objectSpread(_objectSpread(_objectSpread({}, _victoryCore.CommonProps.baseProps), _victoryCore.CommonProps.dataProps), {}, {
candleColors: _propTypes.default.shape({
positive: _propTypes.default.string,
negative: _propTypes.default.string
}),
candleRatio: _propTypes.default.number,
candleWidth: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.number]),
close: _propTypes.default.oneOfType([_propTypes.default.func, _victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer, _victoryCore.PropTypes.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
closeLabelComponent: _propTypes.default.element,
closeLabels: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.array, _propTypes.default.bool]),
events: _propTypes.default.arrayOf(_propTypes.default.shape({
target: _propTypes.default.oneOf(["data", "labels", "open", "openLabels", "close", "closeLabels", "low", "lowLabels", "high", "highLabels"]),
eventKey: _propTypes.default.oneOfType([_propTypes.default.array, _victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer, _victoryCore.PropTypes.nonNegative]), _propTypes.default.string]),
eventHandlers: _propTypes.default.object
})),
high: _propTypes.default.oneOfType([_propTypes.default.func, _victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer, _victoryCore.PropTypes.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
highLabelComponent: _propTypes.default.element,
highLabels: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.array, _propTypes.default.bool]),
labelOrientation: _propTypes.default.oneOfType([_propTypes.default.oneOf(["top", "bottom", "left", "right"]), _propTypes.default.shape({
open: _propTypes.default.oneOf(["top", "bottom", "left", "right"]),
close: _propTypes.default.oneOf(["top", "bottom", "left", "right"]),
low: _propTypes.default.oneOf(["top", "bottom", "left", "right"]),
high: _propTypes.default.oneOf(["top", "bottom", "left", "right"])
})]),
low: _propTypes.default.oneOfType([_propTypes.default.func, _victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer, _victoryCore.PropTypes.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
lowLabelComponent: _propTypes.default.element,
lowLabels: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.array, _propTypes.default.bool]),
open: _propTypes.default.oneOfType([_propTypes.default.func, _victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer, _victoryCore.PropTypes.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
openLabelComponent: _propTypes.default.element,
openLabels: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.array, _propTypes.default.bool]),
style: _propTypes.default.shape({
data: _propTypes.default.object,
labels: _propTypes.default.object,
close: _propTypes.default.object,
closeLabels: _propTypes.default.object,
open: _propTypes.default.object,
openLabels: _propTypes.default.object,
high: _propTypes.default.object,
highLabels: _propTypes.default.object,
low: _propTypes.default.object,
lowLabels: _propTypes.default.object
}),
wickStrokeWidth: _propTypes.default.number
});
VictoryCandlestick.defaultProps = {
defaultCandleWidth: 8,
VictoryCandlestickBase.animationWhitelist = ["data", "domain", "height", "padding", "samples", "size", "style", "width"];
VictoryCandlestickBase.displayName = "VictoryCandlestick";
VictoryCandlestickBase.role = "candlestick";
VictoryCandlestickBase.defaultTransitions = _victoryCore.DefaultTransitions.discreteTransitions();
VictoryCandlestickBase.defaultProps = {
containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null),
data: defaultData,
dataComponent: /*#__PURE__*/_react.default.createElement(_candle.default, null),
dataComponent: /*#__PURE__*/_react.default.createElement(_candle.Candle, null),
groupComponent: /*#__PURE__*/_react.default.createElement("g", {

@@ -309,13 +284,11 @@ role: "presentation"

};
VictoryCandlestick.getDomain = _helperMethods.getDomain;
VictoryCandlestick.getData = _helperMethods.getData;
VictoryCandlestickBase.getDomain = _helperMethods.getDomain;
VictoryCandlestickBase.getData = _helperMethods.getData;
VictoryCandlestick.getBaseProps = function (props) {
VictoryCandlestickBase.getBaseProps = function (props) {
return (0, _helperMethods.getBaseProps)(props, fallbackProps);
};
VictoryCandlestick.expectedComponents = ["openLabelComponent", "closeLabelComponent", "highLabelComponent", "lowLabelComponent", "dataComponent", "labelComponent", "groupComponent", "containerComponent"];
var _default = (0, _victoryCore.addEvents)(VictoryCandlestick, options);
exports.default = _default;
VictoryCandlestickBase.expectedComponents = ["openLabelComponent", "closeLabelComponent", "highLabelComponent", "lowLabelComponent", "dataComponent", "labelComponent", "groupComponent", "containerComponent"];
var VictoryCandlestick = (0, _victoryCore.addEvents)(VictoryCandlestickBase, options);
exports.VictoryCandlestick = VictoryCandlestick;
{
"name": "victory-candlestick",
"version": "36.8.1",
"version": "36.8.2",
"description": "Candlestick Component for Victory",

@@ -25,3 +25,3 @@ "keywords": [

"prop-types": "^15.8.1",
"victory-core": "^36.8.1"
"victory-core": "^36.8.2"
},

@@ -32,3 +32,5 @@ "peerDependencies": {

"devDependencies": {
"victory-chart": "^36.8.1"
"victory-vendor": "^36.8.2",
"victory-chart": "^36.8.2",
"victory-candlestick": "*"
},

@@ -160,4 +162,4 @@ "publishConfig": {

"../victory-core:types:create",
"../victory-vendor:types:create",
"../victory-chart:types:create",
"../victory-vendor:types:create",
"../victory-voronoi:types:create"

@@ -227,4 +229,4 @@ ],

"../victory-core:types:create",
"../victory-vendor:types:create",
"../victory-chart:types:create",
"../victory-vendor:types:create",
"../victory-voronoi:types:create"

@@ -246,4 +248,4 @@ ],

"../victory-core:types:create",
"../victory-vendor:types:create",
"../victory-chart:types:create",
"../victory-vendor:types:create",
"../victory-voronoi:types:create"

@@ -266,4 +268,4 @@ ],

"build:lib:cjs",
"../victory-vendor:build:lib:cjs",
"../victory-chart:build:lib:cjs",
"../victory-vendor:build:lib:cjs",
"../victory-voronoi:build:lib:cjs"

@@ -270,0 +272,0 @@ ],

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc