@lobehub/charts
Version:
React modern charts components built on recharts
32 lines • 922 B
JavaScript
import { DeltaTypes } from "../types/charts";
export var defaultValueFormatter = String;
export var sumNumericArray = function sumNumericArray(arr) {
return arr.reduce(function (prefixSum, num) {
return prefixSum + num;
}, 0);
};
export var isOnSeverSide = typeof document === 'undefined' || typeof window === 'undefined';
export var mapInputsToDeltaType = function mapInputsToDeltaType(deltaType, isIncreasePositive) {
if (isIncreasePositive || deltaType === DeltaTypes.Unchanged) {
return deltaType;
}
switch (deltaType) {
case DeltaTypes.Increase:
{
return DeltaTypes.Decrease;
}
case DeltaTypes.ModerateIncrease:
{
return DeltaTypes.ModerateDecrease;
}
case DeltaTypes.Decrease:
{
return DeltaTypes.Increase;
}
case DeltaTypes.ModerateDecrease:
{
return DeltaTypes.ModerateIncrease;
}
}
return '';
};