MCPcopy
hub / github.com/apache/echarts / interpolateRawValues

Function interpolateRawValues

src/util/model.ts:1095–1154  ·  view source on GitHub ↗
(
    data: SeriesData,
    precision: number | 'auto',
    sourceValue: InterpolatableValue,
    targetValue: InterpolatableValue,
    percent: number
)

Source from the content-addressed store, hash-verified

1093 * Other cases do not supported.
1094 */
1095export function interpolateRawValues(
1096 data: SeriesData,
1097 precision: number | 'auto',
1098 sourceValue: InterpolatableValue,
1099 targetValue: InterpolatableValue,
1100 percent: number
1101): InterpolatableValue {
1102 const isAutoPrecision = precision == null || precision === 'auto';
1103
1104 if (targetValue == null) {
1105 return targetValue;
1106 }
1107
1108 if (isNumber(targetValue)) {
1109 const value = interpolateNumber(
1110 sourceValue as number || 0,
1111 targetValue as number,
1112 percent
1113 );
1114 return round(
1115 value,
1116 isAutoPrecision ? Math.max(
1117 getPrecision(sourceValue as number || 0),
1118 getPrecision(targetValue as number)
1119 )
1120 : precision as number
1121 );
1122 }
1123 else if (isString(targetValue)) {
1124 return percent < 1 ? sourceValue : targetValue;
1125 }
1126 else {
1127 const interpolated = [];
1128 const leftArr = sourceValue as (string | number)[];
1129 const rightArr = targetValue as (string | number[]);
1130 const length = Math.max(leftArr ? leftArr.length : 0, rightArr.length);
1131 for (let i = 0; i < length; ++i) {
1132 const info = data.getDimensionInfo(i);
1133 // Don't interpolate ordinal dims
1134 if (info && info.type === 'ordinal') {
1135 // In init, there is no `sourceValue`, but should better not to get undefined result.
1136 interpolated[i] = (percent < 1 && leftArr ? leftArr : rightArr)[i] as number;
1137 }
1138 else {
1139 const leftVal = leftArr && leftArr[i] ? leftArr[i] as number : 0;
1140 const rightVal = rightArr[i] as number;
1141 const value = interpolateNumber(leftVal, rightVal, percent);
1142 interpolated[i] = round(
1143 value,
1144 isAutoPrecision ? Math.max(
1145 getPrecision(leftVal),
1146 getPrecision(rightVal)
1147 )
1148 : precision as number
1149 );
1150 }
1151 }
1152 return interpolated;

Callers 1

duringFunction · 0.90

Calls 5

roundFunction · 0.90
getPrecisionFunction · 0.90
isNumberFunction · 0.85
interpolateNumberFunction · 0.85
getDimensionInfoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…