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

victory-pie

Package Overview
Dependencies
Maintainers
6
Versions
213
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

victory-pie - npm Package Compare versions

Comparing version 11.1.2 to 11.2.0

4

CHANGELOG.md
# VictoryPie Changelog
## 11.2.0 (2017-07-12)
- [148](https://github.com/FormidableLabs/victory-pie/pull/148) Translates individual slices rather than an entire group translation for pie and labels
## 11.1.2 (2017-06-06)

@@ -4,0 +8,0 @@

20

lib/components/helper-methods.js

@@ -30,3 +30,3 @@ Object.defineProperty(exports,"__esModule",{value:true});var _omit2=require("lodash/omit");var _omit3=_interopRequireDefault(_omit2);var _isFunction2=require("lodash/isFunction");var _isFunction3=_interopRequireDefault(_isFunction2);var _defaults2=require("lodash/defaults");var _defaults3=_interopRequireDefault(_defaults2);var _assign2=require("lodash/assign");var _assign3=_interopRequireDefault(_assign2);

var calculatedValues=this.getCalculatedValues(props);var
slices=calculatedValues.slices,style=calculatedValues.style,pathFunction=calculatedValues.pathFunction,data=calculatedValues.data;
slices=calculatedValues.slices,style=calculatedValues.style,pathFunction=calculatedValues.pathFunction,data=calculatedValues.data,origin=calculatedValues.origin;
var childProps={

@@ -44,3 +44,3 @@ parent:{

var dataProps={
index:index,slice:slice,pathFunction:pathFunction,datum:datum,data:data,
index:index,slice:slice,pathFunction:pathFunction,datum:datum,data:data,origin:origin,
style:this.getSliceStyle(datum,index,calculatedValues)};

@@ -59,3 +59,3 @@

index=dataProps.index,datum=dataProps.datum,data=dataProps.data,slice=dataProps.slice;var
style=calculatedValues.style,radius=calculatedValues.radius;
style=calculatedValues.style,radius=calculatedValues.radius,origin=calculatedValues.origin;
var labelStyle=(0,_assign3.default)({padding:0},style.labels);

@@ -69,4 +69,4 @@ var labelRadius=_victoryCore.Helpers.evaluateProp(props.labelRadius,datum);

style:labelStyle,
x:Math.round(position[0]),
y:Math.round(position[1]),
x:Math.round(position[0])+origin.x,
y:Math.round(position[1])+origin.y,
text:this.getLabelText(props,datum,index),

@@ -80,3 +80,3 @@ textAnchor:labelStyle.textAnchor||this.getTextAnchor(orientation),

getCalculatedValues:function getCalculatedValues(props){var
theme=props.theme,colorScale=props.colorScale;
theme=props.theme,colorScale=props.colorScale,width=props.width,height=props.height;
var styleObject=theme&&theme.pie&&theme.pie.style?theme.pie.style:{};

@@ -87,2 +87,8 @@ var style=_victoryCore.Helpers.getStyles(props.style,styleObject,"auto","100%");

var radius=this.getRadius(props,padding);
var offsetWidth=width/2+padding.left-padding.right;
var offsetHeight=height/2+padding.top-padding.bottom;
var origin={
x:offsetWidth+radius>width?radius+padding.left-padding.right:offsetWidth,
y:offsetHeight+radius>height?radius+padding.top-padding.bottom:offsetHeight};
var data=_victoryCore.Data.getData(props);

@@ -94,3 +100,3 @@ var slices=this.getSlices(props,data);

innerRadius(props.innerRadius);
return{style:style,colors:colors,padding:padding,radius:radius,data:data,slices:slices,pathFunction:pathFunction};
return{style:style,colors:colors,padding:padding,radius:radius,data:data,slices:slices,pathFunction:pathFunction,origin:origin};
},

@@ -97,0 +103,0 @@

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

Object.defineProperty(exports,"__esModule",{value:true});var _assign2=require("lodash/assign");var _assign3=_interopRequireDefault(_assign2);var _partialRight2=require("lodash/partialRight");var _partialRight3=_interopRequireDefault(_partialRight2);var _jsxFileName="src/components/victory-pie.js";var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();
Object.defineProperty(exports,"__esModule",{value:true});var _partialRight2=require("lodash/partialRight");var _partialRight3=_interopRequireDefault(_partialRight2);var _jsxFileName="src/components/victory-pie.js";var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();
var _react=require("react");var _react2=_interopRequireDefault(_react);

@@ -38,3 +38,3 @@ var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);

VictoryPie=function(_React$Component){_inherits(VictoryPie,_React$Component);function VictoryPie(){_classCallCheck(this,VictoryPie);return _possibleConstructorReturn(this,(VictoryPie.__proto__||Object.getPrototypeOf(VictoryPie)).apply(this,arguments));}_createClass(VictoryPie,[{key:"renderPieData",value:function renderPieData(
VictoryPie=function(_React$Component){_inherits(VictoryPie,_React$Component);function VictoryPie(){_classCallCheck(this,VictoryPie);return _possibleConstructorReturn(this,(VictoryPie.__proto__||Object.getPrototypeOf(VictoryPie)).apply(this,arguments));}_createClass(VictoryPie,[{key:"shouldAnimate",value:function shouldAnimate()

@@ -149,42 +149,3 @@

props){var
dataComponent=props.dataComponent,labelComponent=props.labelComponent;
var dataComponents=[];
var labelComponents=[];
for(var index=0,len=this.dataKeys.length;index<len;index++){
var dataProps=this.getComponentProps(dataComponent,"data",index);
dataComponents[index]=_react2.default.cloneElement(dataComponent,dataProps);
var labelProps=this.getComponentProps(labelComponent,"labels",index);
if(labelProps&&labelProps.text!==undefined&&labelProps.text!==null){
labelComponents[index]=_react2.default.cloneElement(
labelComponent,(0,_assign3.default)({},labelProps,{renderInPortal:false}));
}
}
var children=[].concat(dataComponents,labelComponents);
return this.renderGroup(props,children);
}},{key:"renderGroup",value:function renderGroup(
props,children){
var offset=this.getOffset(props);
var transform="translate("+offset.x+", "+offset.y+")";
var groupComponent=_react2.default.cloneElement(props.groupComponent,{transform:transform});
return this.renderContainer(groupComponent,children);
}},{key:"getOffset",value:function getOffset(
props){var
width=props.width,height=props.height;
var calculatedProps=_helperMethods2.default.getCalculatedValues(props);var
padding=calculatedProps.padding,radius=calculatedProps.radius;
var offsetWidth=width/2+padding.left-padding.right;
var offsetHeight=height/2+padding.top-padding.bottom;
return{
x:offsetWidth+radius>width?radius+padding.left-padding.right:offsetWidth,
y:offsetHeight+radius>height?radius+padding.top-padding.bottom:offsetHeight};
}},{key:"shouldAnimate",value:function shouldAnimate()
{

@@ -201,3 +162,3 @@ return Boolean(this.props.animate);

var children=this.renderPieData(props);
var children=this.renderData(props);
return props.standalone?this.renderContainer(props.containerComponent,children):children;

@@ -204,0 +165,0 @@ }}]);return VictoryPie;}(_react2.default.Component);VictoryPie.displayName="VictoryPie";VictoryPie.defaultTransitions={onExit:{duration:500,before:function before(){return{_y:0,label:" "};}},onEnter:{duration:500,before:function before(){return{_y:0,label:" "};},after:function after(datum){return{y_:datum._y,label:datum.label};}}};VictoryPie.propTypes={animate:_propTypes2.default.object,colorScale:_propTypes2.default.oneOfType([_propTypes2.default.arrayOf(_propTypes2.default.string),_propTypes2.default.oneOf(["grayscale","qualitative","heatmap","warm","cool","red","green","blue"])]),containerComponent:_propTypes2.default.element,cornerRadius:_victoryCore.PropTypes.nonNegative,data:_propTypes2.default.array,dataComponent:_propTypes2.default.element,endAngle:_propTypes2.default.number,eventKey:_propTypes2.default.oneOfType([_propTypes2.default.func,_victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer,_victoryCore.PropTypes.nonNegative]),_propTypes2.default.string]),events:_propTypes2.default.arrayOf(_propTypes2.default.shape({target:_propTypes2.default.oneOf(["data","labels","parent"]),eventKey:_propTypes2.default.oneOfType([_propTypes2.default.func,_victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer,_victoryCore.PropTypes.nonNegative]),_propTypes2.default.string]),eventHandlers:_propTypes2.default.object})),groupComponent:_propTypes2.default.element,height:_victoryCore.PropTypes.nonNegative,innerRadius:_victoryCore.PropTypes.nonNegative,labelComponent:_propTypes2.default.element,labelRadius:_propTypes2.default.oneOfType([_victoryCore.PropTypes.nonNegative,_propTypes2.default.func]),labels:_propTypes2.default.oneOfType([_propTypes2.default.func,_propTypes2.default.array]),name:_propTypes2.default.string,padAngle:_victoryCore.PropTypes.nonNegative,padding:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.shape({top:_propTypes2.default.number,bottom:_propTypes2.default.number,left:_propTypes2.default.number,right:_propTypes2.default.number})]),sharedEvents:_propTypes2.default.shape({events:_propTypes2.default.array,getEventState:_propTypes2.default.func}),sortKey:_propTypes2.default.oneOfType([_propTypes2.default.func,_victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer,_victoryCore.PropTypes.nonNegative]),_propTypes2.default.string,_propTypes2.default.arrayOf(_propTypes2.default.string)]),standalone:_propTypes2.default.bool,startAngle:_propTypes2.default.number,style:_propTypes2.default.shape({parent:_propTypes2.default.object,data:_propTypes2.default.object,labels:_propTypes2.default.object}),theme:_propTypes2.default.object,width:_victoryCore.PropTypes.nonNegative,x:_propTypes2.default.oneOfType([_propTypes2.default.func,_victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer,_victoryCore.PropTypes.nonNegative]),_propTypes2.default.string,_propTypes2.default.arrayOf(_propTypes2.default.string)]),y:_propTypes2.default.oneOfType([_propTypes2.default.func,_victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer,_victoryCore.PropTypes.nonNegative]),_propTypes2.default.string,_propTypes2.default.arrayOf(_propTypes2.default.string)])};VictoryPie.defaultProps={data:[{x:"A",y:1},{x:"B",y:2},{x:"C",y:3},{x:"D",y:1},{x:"E",y:2}],standalone:true,dataComponent:_react2.default.createElement(_victoryCore.Slice,{__source:{fileName:_jsxFileName,lineNumber:135}}),labelComponent:_react2.default.createElement(_victoryCore.VictoryLabel,{__source:{fileName:_jsxFileName,lineNumber:136}}),containerComponent:_react2.default.createElement(_victoryCore.VictoryContainer,{__source:{fileName:_jsxFileName,lineNumber:137}}),groupComponent:_react2.default.createElement("g",{__source:{fileName:_jsxFileName,lineNumber:138}}),theme:_victoryCore.VictoryTheme.grayscale};VictoryPie.getBaseProps=(0,_partialRight3.default)(_helperMethods2.default.getBaseProps.bind(_helperMethods2.default),fallbackProps);VictoryPie.getData=_victoryCore.Data.getData.bind(_victoryCore.Data);VictoryPie.expectedComponents=["dataComponent","labelComponent","groupComponent","containerComponent"];exports.default=

{
"name": "victory-pie",
"version": "11.1.2",
"version": "11.2.0",
"description": "D3 pie & donut chart component for React",

@@ -31,3 +31,3 @@ "main": "lib/index.js",

"lodash": "^4.17.4",
"victory-core": "^16.0.0"
"victory-core": "^16.2.0"
},

@@ -34,0 +34,0 @@ "devDependencies": {

@@ -30,3 +30,3 @@ /*eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2, 45, 135, 180, 225, 315] }]*/

const calculatedValues = this.getCalculatedValues(props);
const { slices, style, pathFunction, data } = calculatedValues;
const { slices, style, pathFunction, data, origin } = calculatedValues;
const childProps = {

@@ -44,3 +44,3 @@ parent: {

const dataProps = {
index, slice, pathFunction, datum, data,
index, slice, pathFunction, datum, data, origin,
style: this.getSliceStyle(datum, index, calculatedValues)

@@ -59,3 +59,3 @@ };

const { index, datum, data, slice } = dataProps;
const { style, radius } = calculatedValues;
const { style, radius, origin } = calculatedValues;
const labelStyle = assign({ padding: 0 }, style.labels);

@@ -69,4 +69,4 @@ const labelRadius = Helpers.evaluateProp(props.labelRadius, datum);

style: labelStyle,
x: Math.round(position[0]),
y: Math.round(position[1]),
x: Math.round(position[0]) + origin.x,
y: Math.round(position[1]) + origin.y,
text: this.getLabelText(props, datum, index),

@@ -80,3 +80,3 @@ textAnchor: labelStyle.textAnchor || this.getTextAnchor(orientation),

getCalculatedValues(props) {
const { theme, colorScale } = props;
const { theme, colorScale, width, height } = props;
const styleObject = theme && theme.pie && theme.pie.style ? theme.pie.style : {};

@@ -87,2 +87,8 @@ const style = Helpers.getStyles(props.style, styleObject, "auto", "100%");

const radius = this.getRadius(props, padding);
const offsetWidth = width / 2 + padding.left - padding.right;
const offsetHeight = height / 2 + padding.top - padding.bottom;
const origin = {
x: offsetWidth + radius > width ? radius + padding.left - padding.right : offsetWidth,
y: offsetHeight + radius > height ? radius + padding.top - padding.bottom : offsetHeight
};
const data = Data.getData(props);

@@ -94,3 +100,3 @@ const slices = this.getSlices(props, data);

.innerRadius(props.innerRadius);
return { style, colors, padding, radius, data, slices, pathFunction };
return { style, colors, padding, radius, data, slices, pathFunction, origin };
},

@@ -97,0 +103,0 @@

/*eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2] }]*/
import React from "react";
import PropTypes from "prop-types";
import { partialRight, assign } from "lodash";
import { partialRight } from "lodash";
import {

@@ -148,42 +148,3 @@ addEvents, Helpers, Data, PropTypes as CustomPropTypes, Slice,

renderPieData(props) {
const { dataComponent, labelComponent } = props;
const dataComponents = [];
const labelComponents = [];
for (let index = 0, len = this.dataKeys.length; index < len; index++) {
const dataProps = this.getComponentProps(dataComponent, "data", index);
dataComponents[index] = React.cloneElement(dataComponent, dataProps);
const labelProps = this.getComponentProps(labelComponent, "labels", index);
if (labelProps && labelProps.text !== undefined && labelProps.text !== null) {
labelComponents[index] = React.cloneElement(
labelComponent, assign({}, labelProps, { renderInPortal: false })
);
}
}
const children = [...dataComponents, ...labelComponents];
return this.renderGroup(props, children);
}
// Overridden in victory-native
renderGroup(props, children) {
const offset = this.getOffset(props);
const transform = `translate(${offset.x}, ${offset.y})`;
const groupComponent = React.cloneElement(props.groupComponent, { transform });
return this.renderContainer(groupComponent, children);
}
getOffset(props) {
const { width, height } = props;
const calculatedProps = PieHelpers.getCalculatedValues(props);
const { padding, radius } = calculatedProps;
const offsetWidth = width / 2 + padding.left - padding.right;
const offsetHeight = height / 2 + padding.top - padding.bottom;
return {
x: offsetWidth + radius > width ? radius + padding.left - padding.right : offsetWidth,
y: offsetHeight + radius > height ? radius + padding.top - padding.bottom : offsetHeight
};
}
// Overridden in victory-native
shouldAnimate() {

@@ -200,3 +161,3 @@ return Boolean(this.props.animate);

const children = this.renderPieData(props);
const children = this.renderData(props);
return props.standalone ? this.renderContainer(props.containerComponent, children) : children;

@@ -203,0 +164,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