( kind: Kind, points: DataPoint[], [xMin, xMax, yMin, yMax]: Bounds, [width, height]: Size, xValues?: XValue[], xScale: XScale = CATEGORY, timestampUnit: TimestampUnit = MILLISECOND, xTitle?: string, yTitle?: string, )
| 79 | }; |
| 80 | |
| 81 | export const getScaledPoints = ( |
| 82 | kind: Kind, |
| 83 | points: DataPoint[], |
| 84 | [xMin, xMax, yMin, yMax]: Bounds, |
| 85 | [width, height]: Size, |
| 86 | xValues?: XValue[], |
| 87 | xScale: XScale = CATEGORY, |
| 88 | timestampUnit: TimestampUnit = MILLISECOND, |
| 89 | xTitle?: string, |
| 90 | yTitle?: string, |
| 91 | ): ScaledPoint[] => { |
| 92 | const continuousX = xScale != CATEGORY; |
| 93 | const xDomain: Domain = continuousX |
| 94 | ? [xMin as number, xMax as number] |
| 95 | : [0, 0]; |
| 96 | const yDomain: Domain = [yMin ?? 0, yMax ?? 0]; |
| 97 | const xCategories = mapNew<XValue, number>(); |
| 98 | |
| 99 | arrayForEach( |
| 100 | isNullish(xValues) || arrayIsEmpty(xValues) |
| 101 | ? arrayMap(points, ([, xValue]) => xValue) |
| 102 | : xValues, |
| 103 | (xValue) => |
| 104 | collHas(xCategories, xValue) |
| 105 | ? 0 |
| 106 | : mapSet(xCategories, xValue, collSize(xCategories)), |
| 107 | ); |
| 108 | |
| 109 | return arrayFilter( |
| 110 | arrayMap(points, ([rowId, xValue, yValue]): ScaledPoint | undefined => { |
| 111 | const x = getX( |
| 112 | xValue, |
| 113 | xScale, |
| 114 | timestampUnit, |
| 115 | xDomain, |
| 116 | xCategories, |
| 117 | width, |
| 118 | kind, |
| 119 | ); |
| 120 | return isUndefined(x) |
| 121 | ? undefined |
| 122 | : [ |
| 123 | rowId, |
| 124 | xValue, |
| 125 | yValue, |
| 126 | x, |
| 127 | height - getScale(yValue, yDomain[0], yDomain[1], height), |
| 128 | xTitle, |
| 129 | yTitle, |
| 130 | ]; |
| 131 | }), |
| 132 | (point): point is ScaledPoint => !isUndefined(point), |
| 133 | ); |
| 134 | }; |
| 135 | |
| 136 | const getX = ( |
| 137 | xValue: XValue, |
no test coverage detected
searching dependent graphs…