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 16.0.1 to 16.1.0

4

CHANGELOG.md
# VictoryPie Changelog
## 16.1.0 (2018-06-23)
-[182](https://github.com/FormidableLabs/victory-pie/pull/182) Adds optional `radius` and `origin` props to `VictoryPie`. The `radius` prop should be given as a single number. The `origin` prop should be given as an object with number values specified for "x" and "y". When these props are not given, radius and origin are determined by `width`, `height`, and `padding` as previously.
## 16.0.1 (2018-06-21)

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

23

es/components/helper-methods.js

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

import _isPlainObject from "lodash/isPlainObject";
import _isFunction from "lodash/isFunction";

@@ -28,5 +29,19 @@ import _assign from "lodash/assign"; /*eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2, 45, 135, 180, 225, 315] }]*/

var getRadius = function (props, padding) {
if (props.radius) {
return props.radius;
}
return Math.min(props.width - padding.left - padding.right, props.height - padding.top - padding.bottom) / 2;
};
var getOrigin = function (props, padding) {
var width = props.width,
height = props.height;
var origin = _isPlainObject(props.origin) ? props.origin : {};
return {
x: origin.x !== undefined ? origin.x : (padding.left - padding.right + width) / 2,
y: origin.y !== undefined ? origin.y : (padding.top - padding.bottom + height) / 2
};
};
var getSlices = function (props, data) {

@@ -41,5 +56,3 @@ var layoutFunction = d3Shape.pie().sort(null).startAngle(degreesToRadians(props.startAngle)).endAngle(degreesToRadians(props.endAngle)).padAngle(degreesToRadians(props.padAngle)).value(function (datum) {

var theme = props.theme,
colorScale = props.colorScale,
width = props.width,
height = props.height;
colorScale = props.colorScale;

@@ -51,5 +64,3 @@ var styleObject = theme && theme.pie && theme.pie.style ? theme.pie.style : {};

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

@@ -56,0 +67,0 @@ var slices = getSlices(props, data);

@@ -111,2 +111,6 @@ 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; }; }();

name: PropTypes.string,
origin: PropTypes.shape({
x: CustomPropTypes.nonNegative,
y: CustomPropTypes.nonNegative
}),
padAngle: CustomPropTypes.nonNegative,

@@ -117,2 +121,3 @@ padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({

})]),
radius: CustomPropTypes.nonNegative,
sharedEvents: PropTypes.shape({

@@ -119,0 +124,0 @@ events: PropTypes.array,

@@ -6,2 +6,6 @@ Object.defineProperty(exports, "__esModule", {

var _isPlainObject2 = require("lodash/isPlainObject");
var _isPlainObject3 = _interopRequireDefault(_isPlainObject2);
var _isFunction2 = require("lodash/isFunction");

@@ -46,5 +50,19 @@

var getRadius = function (props, padding) {
if (props.radius) {
return props.radius;
}
return Math.min(props.width - padding.left - padding.right, props.height - padding.top - padding.bottom) / 2;
};
var getOrigin = function (props, padding) {
var width = props.width,
height = props.height;
var origin = (0, _isPlainObject3.default)(props.origin) ? props.origin : {};
return {
x: origin.x !== undefined ? origin.x : (padding.left - padding.right + width) / 2,
y: origin.y !== undefined ? origin.y : (padding.top - padding.bottom + height) / 2
};
};
var getSlices = function (props, data) {

@@ -59,5 +77,3 @@ var layoutFunction = d3Shape.pie().sort(null).startAngle(degreesToRadians(props.startAngle)).endAngle(degreesToRadians(props.endAngle)).padAngle(degreesToRadians(props.padAngle)).value(function (datum) {

var theme = props.theme,
colorScale = props.colorScale,
width = props.width,
height = props.height;
colorScale = props.colorScale;

@@ -69,5 +85,3 @@ var styleObject = theme && theme.pie && theme.pie.style ? theme.pie.style : {};

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

@@ -74,0 +88,0 @@ var slices = getSlices(props, data);

@@ -124,2 +124,6 @@ Object.defineProperty(exports, "__esModule", {

name: _propTypes2.default.string,
origin: _propTypes2.default.shape({
x: _victoryCore.PropTypes.nonNegative,
y: _victoryCore.PropTypes.nonNegative
}),
padAngle: _victoryCore.PropTypes.nonNegative,

@@ -130,2 +134,3 @@ padding: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.shape({

})]),
radius: _victoryCore.PropTypes.nonNegative,
sharedEvents: _propTypes2.default.shape({

@@ -132,0 +137,0 @@ events: _propTypes2.default.array,

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

@@ -5,0 +5,0 @@ "main": "lib/index.js",

/*eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2, 45, 135, 180, 225, 315] }]*/
import { assign, isFunction } from "lodash";
import { assign, isFunction, isPlainObject } from "lodash";
import * as d3Shape from "d3-shape";

@@ -27,2 +27,5 @@

const getRadius = (props, padding) => {
if (props.radius) {
return props.radius;
}
return Math.min(

@@ -34,2 +37,11 @@ props.width - padding.left - padding.right,

const getOrigin = (props, padding) => {
const { width, height } = props;
const origin = isPlainObject(props.origin) ? props.origin : {};
return {
x: origin.x !== undefined ? origin.x : (padding.left - padding.right + width) / 2,
y: origin.y !== undefined ? origin.y : (padding.top - padding.bottom + height) / 2
};
};
const getSlices = (props, data) => {

@@ -46,3 +58,3 @@ const layoutFunction = d3Shape.pie()

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

@@ -53,5 +65,3 @@ const style = Helpers.getStyles(props.style, styleObject, "auto", "100%");

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

@@ -58,0 +68,0 @@ const slices = getSlices(props, data);

@@ -105,2 +105,6 @@ /*eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2] }]*/

name: PropTypes.string,
origin: PropTypes.shape({
x: CustomPropTypes.nonNegative,
y: CustomPropTypes.nonNegative
}),
padAngle: CustomPropTypes.nonNegative,

@@ -114,2 +118,3 @@ padding: PropTypes.oneOfType([

]),
radius: CustomPropTypes.nonNegative,
sharedEvents: PropTypes.shape({

@@ -116,0 +121,0 @@ events: PropTypes.array,

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