Copilot commented on code in PR #21601:
URL: https://github.com/apache/echarts/pull/21601#discussion_r3178214939
##########
src/processor/dataSample.ts:
##########
@@ -86,14 +115,31 @@ export default function dataSample(seriesType: string):
StageHandler {
const coordSys = seriesModel.coordinateSystem;
const count = data.count();
// Only cartesian2d support down sampling. Disable it when there
is few data.
- if (count > 10 && coordSys.type === 'cartesian2d' && sampling) {
+ if (count > 10 && coordSys.type === 'cartesian2d' && sampling &&
sampling !== 'none') {
const baseAxis = coordSys.getBaseAxis();
const valueAxis = coordSys.getOtherAxis(baseAxis);
const extent = baseAxis.getExtent();
const dpr = api.getDevicePixelRatio();
// Coordinste system has been resized
const size = Math.abs(extent[1] - extent[0]) * (dpr || 1);
- const rate = Math.round(count / size);
+ if (!isFinite(size) || size <= 0) {
+ return;
+ }
+ if (count <= size) {
+ return;
+ }
+ const baseDim = data.mapDimension(baseAxis.dim);
+ let dataCount = count;
+ if (baseDim != null) {
+ const rawData = seriesModel.getRawData();
+ const rawCount = rawData.count();
+ const extentData = count < rawCount ? data : rawData;
+ const extentBaseDim = count < rawCount ? baseDim :
rawData.mapDimension(baseAxis.dim);
+ if (extentBaseDim == null ||
!dataExtentInAxisExtent(extentData, baseAxis, extentBaseDim)) {
+ dataCount = countDataInAxisExtent(data, baseAxis,
baseDim);
+ }
Review Comment:
`countDataInAxisExtent` does a full pass over `data` to compute `dataCount`,
and when `rate > 1` the downsampling step will iterate the full dataset again.
For `filterMode: 'none'|'empty'` with large series where the visible window
still contains more points than pixels, this introduces an extra O(n) scan per
reset compared to the previous single-pass downsample. Consider avoiding the
pre-scan (e.g., estimate `dataCount` from extents, early-exit the count once it
exceeds a threshold sufficient to determine `rate`, or integrate visible-count
estimation into the downsample step so the data is only traversed once).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]