react-gauge-component
Advanced tools
Comparing version 1.0.16 to 1.1.0
@@ -104,3 +104,7 @@ "use strict"; | ||
var limit = subArc.limit; | ||
if (subArc.limit == undefined) { | ||
if (subArc.length != undefined) { | ||
subArcLength = subArc.length; | ||
limit = utils.getCurrentGaugeValueByPercentage(subArcLength + lastSubArcLimitPercentageAcc_1, gauge); | ||
} | ||
else if (subArc.limit == undefined) { | ||
subArcRange = lastSubArcLimit_1; | ||
@@ -424,10 +428,12 @@ var remainingPercentageEquallyDivided = undefined; | ||
var verifySubArcsLimits = function (gauge) { | ||
var _a, _b; | ||
reOrderSubArcs(gauge); | ||
var _a; | ||
// disabled when length implemented. | ||
// reOrderSubArcs(gauge); | ||
var minValue = gauge.props.minValue; | ||
var maxValue = gauge.props.maxValue; | ||
var arc = gauge.props.arc; | ||
var subArcs = arc.subArcs; | ||
var prevLimit = undefined; | ||
for (var _i = 0, _c = ((_a = gauge.props.arc) === null || _a === void 0 ? void 0 : _a.subArcs) || []; _i < _c.length; _i++) { | ||
var subArc = _c[_i]; | ||
for (var _i = 0, _b = ((_a = gauge.props.arc) === null || _a === void 0 ? void 0 : _a.subArcs) || []; _i < _b.length; _i++) { | ||
var subArc = _b[_i]; | ||
var limit = subArc.limit; | ||
@@ -438,2 +444,7 @@ if (typeof limit !== 'undefined') { | ||
throw new Error("The limit of a subArc must be between the minValue and maxValue. The limit of the subArc is ".concat(limit)); | ||
// Check if the limit is greater than the previous limit | ||
if (typeof prevLimit !== 'undefined') { | ||
if (limit <= prevLimit) | ||
throw new Error("The limit of a subArc must be greater than the limit of the previous subArc. The limit of the subArc is ".concat(limit, ". If you're trying to specify length in percent of the arc, use property \"length\". refer to: https://github.com/antoniolago/react-gauge-component")); | ||
} | ||
prevLimit = limit; | ||
@@ -443,3 +454,2 @@ } | ||
// If the user has defined subArcs, make sure the last subArc has a limit equal to the maxValue | ||
var subArcs = (_b = gauge.props.arc) === null || _b === void 0 ? void 0 : _b.subArcs; | ||
if (subArcs.length > 0) { | ||
@@ -446,0 +456,0 @@ var lastSubArc = subArcs[subArcs.length - 1]; |
@@ -14,2 +14,3 @@ import { Tooltip } from './Tooltip'; | ||
color?: string | number; | ||
length?: number; | ||
showMark?: boolean; | ||
@@ -16,0 +17,0 @@ tooltip?: Tooltip; |
{ | ||
"name": "react-gauge-component", | ||
"version": "1.0.16", | ||
"version": "1.1.0", | ||
"main": "dist/lib/index.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/lib/index.js", |
@@ -358,14 +358,16 @@ # react-gauge-component | ||
<ul> | ||
<li><code>limit: number</code>: The subArc limit value. When no limits are defined will auto-calculate remaining arcs limits. Attention: limits are reordered in ascending order.</li> | ||
<li><code>color: string</code>: The subArc color. When not provided, it will use default subArc's colors and interpolate first and last colors when subArcs number is greater than <code>colorArray</code>.</li> | ||
<li><code>showMark: boolean</code>: Whether or not to show the mark. Default: <code>false</code>.</li> | ||
<li><code>tooltip: object</code>: Tooltip object. | ||
<ul> | ||
<li><code>text: string</code>text that will be displayed in the tooltip when hovering the subArc.</li> | ||
<li><code>style: React.CSSProperties</code>: Overrides tooltip styles.</li> | ||
</ul> | ||
</li> | ||
<li><code>onClick: (event: any) => void</code>: onClick callback. Default: <code>undefined</code>.</li> | ||
<li><code>onMouseMove: (event: any) => void</code>: onMouseMove callback. Default: <code>undefined</code>.</li> | ||
<li><code>onMouseLeave: (event: any) => void</code>: onMouseLeave callback. Default: <code>undefined</code>.</li> | ||
<li><code>limit: number</code>: The subArc length using value as reference. When no limits or lengths are defined will auto-calculate remaining arcs limits. Example of valid input: <code>subArcs: [{limit: 50}, {limit: 100}]</code> this will render 2 arcs 50/50</li> | ||
<li><code>length: number</code>: The subArc length in percent of the arc (as the behavior of the original project). Example of | ||
a valid input: <code>subArcs: [{length: 0.50}, {length: 0.50}]</code>, this will render 2 arcs 50/50</li> | ||
<li><code>color: string</code>: The subArc color. When not provided, it will use default subArc's colors and interpolate first and last colors when subArcs number is greater than <code>colorArray</code>.</li> | ||
<li><code>showMark: boolean</code>: Whether or not to show the mark. Default: <code>false</code>.</li> | ||
<li><code>tooltip: object</code>: Tooltip object. | ||
<ul> | ||
<li><code>text: string</code>text that will be displayed in the tooltip when hovering the subArc.</li> | ||
<li><code>style: React.CSSProperties</code>: Overrides tooltip styles.</li> | ||
</ul> | ||
</li> | ||
<li><code>onClick: (event: any) => void</code>: onClick callback. Default: <code>undefined</code>.</li> | ||
<li><code>onMouseMove: (event: any) => void</code>: onMouseMove callback. Default: <code>undefined</code>.</li> | ||
<li><code>onMouseLeave: (event: any) => void</code>: onMouseLeave callback. Default: <code>undefined</code>.</li> | ||
</ul> | ||
@@ -372,0 +374,0 @@ subArcs default value: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103656
1849
442