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

victory-axis

Package Overview
Dependencies
Maintainers
35
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

victory-axis - npm Package Compare versions

Comparing version 31.0.2 to 31.1.0

31

es/victory-axis.js

@@ -36,21 +36,2 @@ import _assign from "lodash/assign";

};
var animationWhitelist = ["style", "domain", "range", "tickCount", "tickValues", "offsetX", "offsetY", "padding", "width", "height"];
var options = {
components: [{
name: "axis",
index: 0
}, {
name: "axisLabel",
index: 0
}, {
name: "grid"
}, {
name: "parent",
index: "parent"
}, {
name: "ticks"
}, {
name: "tickLabels"
}]
};

@@ -183,3 +164,5 @@ var VictoryAxis =

value: function render() {
var props = Helpers.modifyProps(this.props, fallbackProps, "axis");
var animationWhitelist = VictoryAxis.animationWhitelist,
role = VictoryAxis.role;
var props = Helpers.modifyProps(this.props, fallbackProps, role);

@@ -200,2 +183,8 @@ if (this.shouldAnimate()) {

Object.defineProperty(VictoryAxis, "animationWhitelist", {
configurable: true,
enumerable: true,
writable: true,
value: ["style", "domain", "range", "tickCount", "tickValues", "offsetX", "offsetY", "padding", "width", "height"]
});
Object.defineProperty(VictoryAxis, "displayName", {

@@ -338,2 +327,2 @@ configurable: true,

});
export default addEvents(VictoryAxis, options);
export default addEvents(VictoryAxis);

@@ -49,21 +49,2 @@ "use strict";

};
var animationWhitelist = ["style", "domain", "range", "tickCount", "tickValues", "offsetX", "offsetY", "padding", "width", "height"];
var options = {
components: [{
name: "axis",
index: 0
}, {
name: "axisLabel",
index: 0
}, {
name: "grid"
}, {
name: "parent",
index: "parent"
}, {
name: "ticks"
}, {
name: "tickLabels"
}]
};

@@ -200,4 +181,7 @@ var VictoryAxis =

value: function render() {
var props = _victoryCore.Helpers.modifyProps(this.props, fallbackProps, "axis");
var animationWhitelist = VictoryAxis.animationWhitelist,
role = VictoryAxis.role;
var props = _victoryCore.Helpers.modifyProps(this.props, fallbackProps, role);
if (this.shouldAnimate()) {

@@ -217,2 +201,8 @@ return this.animateComponent(props, animationWhitelist);

Object.defineProperty(VictoryAxis, "animationWhitelist", {
configurable: true,
enumerable: true,
writable: true,
value: ["style", "domain", "range", "tickCount", "tickValues", "offsetX", "offsetY", "padding", "width", "height"]
});
Object.defineProperty(VictoryAxis, "displayName", {

@@ -356,4 +346,4 @@ configurable: true,

var _default = (0, _victoryCore.addEvents)(VictoryAxis, options);
var _default = (0, _victoryCore.addEvents)(VictoryAxis);
exports.default = _default;
{
"name": "victory-axis",
"version": "31.0.2",
"version": "31.1.0",
"description": "Axis Component for Victory",

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

"prop-types": "^15.5.8",
"victory-core": "^31.0.2"
"victory-core": "^31.1.0"
},

@@ -27,0 +27,0 @@ "scripts": {

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

# VictoryAxis

@@ -54,3 +53,3 @@

*default:* `axisComponent={<Line type={"axis"}/>}`
_default:_ `axisComponent={<Line type={"axis"}/>}`

@@ -67,3 +66,3 @@ ```jsx

*default:* `axisLabelComponent={<VictoryLabel/>}`
_default:_ `axisLabelComponent={<VictoryLabel/>}`

@@ -90,3 +89,3 @@ ```jsx

*default:* `crossAxis={false}`
_default:_ `crossAxis={false}`

@@ -99,3 +98,3 @@ ### dependentAxis

*default:* `dependentAxis={false}`
_default:_ `dependentAxis={false}`

@@ -151,3 +150,3 @@ ```playground

*default:* `fixLabelOverlap={false}`
_default:_ `fixLabelOverlap={false}`

@@ -160,3 +159,3 @@ ### gridComponent

*default:* `gridComponent={<Line type={"grid"}/>}`
_default:_ `gridComponent={<Line type={"grid"}/>}`

@@ -173,3 +172,3 @@ ```jsx

*default:* `<g/>`
_default:_ `<g/>`

@@ -186,3 +185,3 @@ ```jsx

*default (provided by default theme):* `height={300}`
_default (provided by default theme):_ `height={300}`

@@ -199,3 +198,3 @@ ```jsx

*default:* `invertAxis={false}`
_default:_ `invertAxis={false}`

@@ -220,3 +219,2 @@ ### label

```playground

@@ -235,3 +233,2 @@ <VictoryAxis

```playground

@@ -251,3 +248,3 @@ <VictoryAxis

```jsx
name="series-1"
name = "series-1";
```

@@ -301,3 +298,3 @@

*default (provided by default theme):* `padding={50}`
_default (provided by default theme):_ `padding={50}`

@@ -325,3 +322,3 @@ ```jsx

*default:* `scale="linear"`
_default:_ `scale="linear"`

@@ -350,3 +347,3 @@ ```jsx

*default:* `standalone={true}`
_default:_ `standalone={true}`

@@ -384,3 +381,3 @@ ```playground

*default (provided by default theme):* See [grayscale theme][] for more detail
_default (provided by default theme):_ See [grayscale theme][] for more detail

@@ -408,5 +405,5 @@ ```playground

*default:* `theme={VictoryTheme.grayscale}`
_default:_ `theme={VictoryTheme.grayscale}`
*Note:* Use the `dependentAxis` and `independentAxis` namespaces to theme axes by type. These namespaces will be merged with any props and styles supplied in the `axis` namespace.
_Note:_ Use the `dependentAxis` and `independentAxis` namespaces to theme axes by type. These namespaces will be merged with any props and styles supplied in the `axis` namespace.

@@ -423,3 +420,3 @@ ```jsx

*default:* `tickComponent={<Line type={"tick"}/>}`
_default:_ `tickComponent={<Line type={"tick"}/>}`

@@ -455,3 +452,3 @@ ```jsx

*default:* `tickLabelComponent={<VictoryLabel/>}`
_default:_ `tickLabelComponent={<VictoryLabel/>}`

@@ -466,3 +463,3 @@ ```jsx

The `tickValues` prop explicitly specifies a set of tick values to draw on the axis. This prop should be given as an array of unique values of the same type (_i.e.,_ all numbers). The `tickValues` prop is used to specify the _values_ of each tick, so numeric values are typically appropriate. An array of strings or dates may be supplied for categorical and time series data respectively. Use the [tickFormat][] prop to specify how ticks should be labeled. *Note:* `tickValues` should be given as a unique array.
The `tickValues` prop explicitly specifies a set of tick values to draw on the axis. This prop should be given as an array of unique values of the same type (_i.e.,_ all numbers). The `tickValues` prop is used to specify the _values_ of each tick, so numeric values are typically appropriate. An array of strings or dates may be supplied for categorical and time series data respectively. Use the [tickFormat][] prop to specify how ticks should be labeled. _Note:_ `tickValues` should be given as a unique array.

@@ -479,3 +476,3 @@ ```playground

*default (provided by default theme):* `width={450}`
_default (provided by default theme):_ `width={450}`

@@ -486,10 +483,10 @@ ```jsx

[Animations Guide]: https://formidable.com/open-source/victory/guides/animations
[Events Guide]: https://formidable.com/open-source/victory/guides/events
[Themes Guide]: https://formidable.com/open-source/victory/guides/themes
[`VictoryChart`]: https://formidable.com/open-source/victory/docs/victory-chart
[tickFormat]: https://formidable.com/open-source/victory/docs/victory-axis#tickformat
[d3Scale]: https://github.com/d3/d3-scale
[animations guide]: https://formidable.com/open-source/victory/guides/animations
[events guide]: https://formidable.com/open-source/victory/guides/events
[themes guide]: https://formidable.com/open-source/victory/guides/themes
[`victorychart`]: https://formidable.com/open-source/victory/docs/victory-chart
[tickformat]: https://formidable.com/open-source/victory/docs/victory-axis#tickformat
[d3scale]: https://github.com/d3/d3-scale
[grayscale theme]: https://github.com/FormidableLabs/victory-core/blob/master/src/victory-theme/grayscale.js
[Line component]: https://formidable.com/open-source/victory/docs/victory-primitives#line
[`VictoryLabel`]: https://formidable.com/open-source/victory/docs/victory-label
[line component]: https://formidable.com/open-source/victory/docs/victory-primitives#line
[`victorylabel`]: https://formidable.com/open-source/victory/docs/victory-label

@@ -49,4 +49,5 @@ import { assign, defaults, isFunction } from "lodash";

return generalAxisStyle && specificAxisStyle ?
mergeStyles() : specificAxisStyle || generalAxisStyle;
return generalAxisStyle && specificAxisStyle
? mergeStyles()
: specificAxisStyle || generalAxisStyle;
};

@@ -131,10 +132,6 @@

if (props.dependentAxis) {
return props.theme && props.theme.dependentAxis
? "dependentAxis"
: "axis";
return props.theme && props.theme.dependentAxis ? "dependentAxis" : "axis";
}
return props.theme && props.theme.independentAxis
? "independentAxis"
: "axis";
return props.theme && props.theme.independentAxis ? "independentAxis" : "axis";
};

@@ -162,7 +159,8 @@

const angle = isVertical ? -90 : 0; // eslint-disable-line no-magic-numbers
const x = isVertical ? globalTransform.x + (sign * labelPadding) :
((props.width - hPadding) / 2) + padding.left + globalTransform.x;
const y = isVertical ?
((props.height - vPadding) / 2) + padding.top + globalTransform.y :
(sign * labelPadding) + globalTransform.y;
const x = isVertical
? globalTransform.x + sign * labelPadding
: (props.width - hPadding) / 2 + padding.left + globalTransform.x;
const y = isVertical
? (props.height - vPadding) / 2 + padding.top + globalTransform.y
: sign * labelPadding + globalTransform.y;

@@ -198,3 +196,3 @@ return {

const fontSize = labelStyle.fontSize || 14;
return props.label ? (fontSize * (isVertical ? 2.3 : 1.6)) : 0;
return props.label ? fontSize * (isVertical ? 2.3 : 1.6) : 0;
/*eslint-enable no-magic-numbers*/

@@ -205,3 +203,9 @@ };

const {
style, padding, isVertical, orientation, labelPadding, stringTicks, ticks
style,
padding,
isVertical,
orientation,
labelPadding,
stringTicks,
ticks
} = calculatedValues;

@@ -211,6 +215,4 @@ const xPadding = orientation === "right" ? padding.right : padding.left;

const fontSize = style.axisLabel.fontSize || 14; // eslint-disable-line no-magic-numbers
const offsetX = (props.offsetX !== null) && (props.offsetX !== undefined)
? props.offsetX : xPadding;
const offsetY = (props.offsetY !== null) && (props.offsetY !== undefined)
? props.offsetY : yPadding;
const offsetX = props.offsetX !== null && props.offsetX !== undefined ? props.offsetX : xPadding;
const offsetY = props.offsetY !== null && props.offsetY !== undefined ? props.offsetY : yPadding;
const tickSizes = ticks.map((data) => {

@@ -221,3 +223,3 @@ const tick = stringTicks ? props.tickValues[data - 1] : data;

});
const totalPadding = fontSize + (2 * Math.max(...tickSizes)) + labelPadding;
const totalPadding = fontSize + 2 * Math.max(...tickSizes) + labelPadding;
const minimumPadding = 1.2 * fontSize; // eslint-disable-line no-magic-numbers

@@ -227,4 +229,4 @@ const x = isVertical ? totalPadding : minimumPadding;

return {
x: (offsetX !== null) && (offsetX !== undefined) ? offsetX : x,
y: (offsetY !== null) && (offsetY !== undefined) ? offsetY : y
x: offsetX !== null && offsetX !== undefined ? offsetX : x,
y: offsetY !== null && offsetY !== undefined ? offsetY : y
};

@@ -268,6 +270,4 @@ };

const sign = -orientationSign[orientation];
const x = isVertical ?
sign * (props.width - (padding.left + padding.right)) : 0;
const y = isVertical ?
0 : sign * (props.height - (padding.top + padding.bottom));
const x = isVertical ? sign * (props.width - (padding.left + padding.right)) : 0;
const y = isVertical ? 0 : sign * (props.height - (padding.top + padding.bottom));
return { x, y };

@@ -311,4 +311,14 @@ };

return {
axis, style, padding, orientation, isVertical, labelPadding, stringTicks,
anchors, scale, ticks, tickFormat, domain
axis,
style,
padding,
orientation,
isVertical,
labelPadding,
stringTicks,
anchors,
scale,
ticks,
tickFormat,
domain
};

@@ -322,4 +332,13 @@ };

const {
axis, style, orientation, isVertical, scale, ticks,
tickFormat, anchors, domain, stringTicks, name
axis,
style,
orientation,
isVertical,
scale,
ticks,
tickFormat,
anchors,
domain,
stringTicks,
name
} = calculatedValues;

@@ -341,4 +360,4 @@ const otherAxis = axis === "x" ? "y" : "x";

range: { [otherAxis]: Helpers.getRange(props, otherAxis) },
scale: props.scale && props.scale[otherAxis] ?
{ [otherAxis]: props.scale[otherAxis] } : undefined
scale:
props.scale && props.scale[otherAxis] ? { [otherAxis]: props.scale[otherAxis] } : undefined
};

@@ -356,6 +375,4 @@ return ticks.reduce((childProps, tick, index) => {

transform: {
x: isVertical ?
-gridOffset.x + globalTransform.x : scale(tick) + globalTransform.x,
y: isVertical ?
scale(tick) + globalTransform.y : gridOffset.y + globalTransform.y
x: isVertical ? -gridOffset.x + globalTransform.x : scale(tick) + globalTransform.x,
y: isVertical ? scale(tick) + globalTransform.y : gridOffset.y + globalTransform.y
}

@@ -367,8 +384,14 @@ };

ticks: assign({}, sharedProps, getTickProps(tickLayout, styles.tickStyle, tick)),
tickLabels: assign({}, sharedProps, getTickLabelProps(
tickLayout, styles.labelStyle, anchors, tick, tickFormat(tick, index, ticks)
)),
grid: assign(
{}, sharedProps, gridProps, getGridProps(gridLayout, styles.gridStyle, tick)
)
tickLabels: assign(
{},
sharedProps,
getTickLabelProps(
tickLayout,
styles.labelStyle,
anchors,
tick,
tickFormat(tick, index, ticks)
)
),
grid: assign({}, sharedProps, gridProps, getGridProps(gridLayout, styles.gridStyle, tick))
};

@@ -375,0 +398,0 @@ return childProps;

@@ -5,8 +5,15 @@ import PropTypes from "prop-types";

import {
PropTypes as CustomPropTypes, Helpers, VictoryLabel, CommonProps,
VictoryContainer, VictoryTheme, LineSegment, TextSize, addEvents, Axis
PropTypes as CustomPropTypes,
Helpers,
VictoryLabel,
CommonProps,
VictoryContainer,
VictoryTheme,
LineSegment,
TextSize,
addEvents,
Axis
} from "victory-core";
import { getBaseProps, getScale, getStyles } from "./helper-methods";
const fallbackProps = {

@@ -18,19 +25,16 @@ width: 450,

const animationWhitelist = [
"style", "domain", "range", "tickCount", "tickValues",
"offsetX", "offsetY", "padding", "width", "height"
];
class VictoryAxis extends React.Component {
static animationWhitelist = [
"style",
"domain",
"range",
"tickCount",
"tickValues",
"offsetX",
"offsetY",
"padding",
"width",
"height"
];
const options = {
components: [
{ name: "axis", index: 0 },
{ name: "axisLabel", index: 0 },
{ name: "grid" },
{ name: "parent", index: "parent" },
{ name: "ticks" },
{ name: "tickLabels" }
]
};
class VictoryAxis extends React.Component {
static displayName = "VictoryAxis";

@@ -56,3 +60,4 @@

PropTypes.shape({
x: PropTypes.arrayOf(PropTypes.string), y: PropTypes.arrayOf(PropTypes.string)
x: PropTypes.arrayOf(PropTypes.string),
y: PropTypes.arrayOf(PropTypes.string)
})

@@ -62,11 +67,13 @@ ]),

dependentAxis: PropTypes.bool,
events: PropTypes.arrayOf(PropTypes.shape({
target: PropTypes.oneOf(["axis", "axisLabel", "grid", "ticks", "tickLabels"]),
eventKey: PropTypes.oneOfType([
PropTypes.array,
CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]),
PropTypes.string
]),
eventHandlers: PropTypes.object
})),
events: PropTypes.arrayOf(
PropTypes.shape({
target: PropTypes.oneOf(["axis", "axisLabel", "grid", "ticks", "tickLabels"]),
eventKey: PropTypes.oneOfType([
PropTypes.array,
CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]),
PropTypes.string
]),
eventHandlers: PropTypes.object
})
),
fixLabelOverlap: PropTypes.bool,

@@ -83,10 +90,15 @@ gridComponent: PropTypes.element,

style: PropTypes.shape({
parent: PropTypes.object, axis: PropTypes.object, axisLabel: PropTypes.object,
grid: PropTypes.object, ticks: PropTypes.object, tickLabels: PropTypes.object
parent: PropTypes.object,
axis: PropTypes.object,
axisLabel: PropTypes.object,
grid: PropTypes.object,
ticks: PropTypes.object,
tickLabels: PropTypes.object
}),
tickComponent: PropTypes.element,
tickCount: CustomPropTypes.allOfType([
CustomPropTypes.integer, CustomPropTypes.greaterThanZero
CustomPropTypes.integer,
CustomPropTypes.greaterThanZero
]),
tickFormat: PropTypes.oneOfType([ PropTypes.func, CustomPropTypes.homogeneousArray ]),
tickFormat: PropTypes.oneOfType([PropTypes.func, CustomPropTypes.homogeneousArray]),
tickLabelComponent: PropTypes.element,

@@ -97,7 +109,7 @@ tickValues: CustomPropTypes.homogeneousArray

static defaultProps = {
axisComponent: <LineSegment type={"axis"}/>,
axisLabelComponent: <VictoryLabel/>,
tickLabelComponent: <VictoryLabel/>,
tickComponent: <LineSegment type={"tick"}/>,
gridComponent: <LineSegment type={"grid"}/>,
axisComponent: <LineSegment type={"axis"} />,
axisLabelComponent: <VictoryLabel />,
tickLabelComponent: <VictoryLabel />,
tickComponent: <LineSegment type={"tick"} />,
gridComponent: <LineSegment type={"grid"} />,
scale: "linear",

@@ -107,3 +119,3 @@ standalone: true,

containerComponent: <VictoryContainer />,
groupComponent: <g role="presentation"/>,
groupComponent: <g role="presentation" />,
fixLabelOverlap: false

@@ -118,4 +130,9 @@ };

static expectedComponents = [
"axisComponent", "axisLabelComponent", "groupComponent", "containerComponent",
"tickComponent", "tickLabelComponent", "gridComponent"
"axisComponent",
"axisLabelComponent",
"groupComponent",
"containerComponent",
"tickComponent",
"tickLabelComponent",
"gridComponent"
];

@@ -150,3 +167,5 @@

{ key: `${name}-tick-group-${key}` },
GridComponent, TickComponent, TickLabel
GridComponent,
TickComponent,
TickLabel
);

@@ -160,8 +179,9 @@ });

const isVictoryLabel = (child) => child.type && child.type.role === "label";
const labels = gridAndTicks.map((gridAndTick) => gridAndTick.props.children)
.reduce((accumulator, childArr) => accumulator.concat(childArr), [])
.filter(isVictoryLabel)
.map((child) => child.props);
const labels = gridAndTicks
.map((gridAndTick) => gridAndTick.props.children)
.reduce((accumulator, childArr) => accumulator.concat(childArr), [])
.filter(isVictoryLabel)
.map((child) => child.props);
const paddingToObject = (padding) =>
typeof (padding) === "object"
typeof padding === "object"
? assign({}, { top: 0, right: 0, bottom: 0, left: 0 }, padding)

@@ -177,14 +197,20 @@ : { top: padding, right: padding, bottom: padding, left: padding };

});
return sum + (isVertical
? labelSize.height + padding.top + padding.bottom
: labelSize.width + padding.right + padding.left);
return (
sum +
(isVertical
? labelSize.height + padding.top + padding.bottom
: labelSize.width + padding.right + padding.left)
);
}, 0);
const availiableLabelCount = Math.floor(size * gridAndTicks.length / labelsSumSize);
const availiableLabelCount = Math.floor((size * gridAndTicks.length) / labelsSumSize);
const divider = Math.ceil(gridAndTicks.length / availiableLabelCount) || 1;
const getLabelCoord = (gridAndTick) => gridAndTick.props.children
.filter(isVictoryLabel)
.reduce((prev, child) => (isVertical ? child.props.y : child.props.x) || 0, 0);
const sorted = gridAndTicks.sort((a, b) => isVertical
? getLabelCoord(b) - getLabelCoord(a) //ordinat axis has top-bottom orientation
: getLabelCoord(a) - getLabelCoord(b) //ordinat axis has left-right orientation
const getLabelCoord = (gridAndTick) =>
gridAndTick.props.children
.filter(isVictoryLabel)
.reduce((prev, child) => (isVertical ? child.props.y : child.props.x) || 0, 0);
const sorted = gridAndTicks.sort(
(a, b) =>
isVertical
? getLabelCoord(b) - getLabelCoord(a) //ordinat axis has top-bottom orientation
: getLabelCoord(a) - getLabelCoord(b) //ordinat axis has left-right orientation
);

@@ -200,3 +226,5 @@ return sorted.filter((gridAndTick, index) => index % divider === 0);

render() {
const props = Helpers.modifyProps(this.props, fallbackProps, "axis");
const { animationWhitelist, role } = VictoryAxis;
const props = Helpers.modifyProps(this.props, fallbackProps, role);
if (this.shouldAnimate()) {

@@ -210,13 +238,9 @@ return this.animateComponent(props, animationWhitelist);

: gridAndTicks;
const children = [
this.renderLine(props),
this.renderLabel(props),
...modifiedGridAndTicks
];
return props.standalone ?
this.renderContainer(props.containerComponent, children) :
React.cloneElement(props.groupComponent, {}, children);
const children = [this.renderLine(props), this.renderLabel(props), ...modifiedGridAndTicks];
return props.standalone
? this.renderContainer(props.containerComponent, children)
: React.cloneElement(props.groupComponent, {}, children);
}
}
export default addEvents(VictoryAxis, options);
export default addEvents(VictoryAxis);

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