Copilot commented on code in PR #21601:
URL: https://github.com/apache/echarts/pull/21601#discussion_r3177835789
##########
src/processor/dataSample.ts:
##########
@@ -86,14 +115,28 @@ 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 rawCount = seriesModel.getRawData().count();
+ if (count >= rawCount || !dataExtentInAxisExtent(data,
baseAxis, baseDim)) {
+ dataCount = countDataInAxisExtent(data, baseAxis,
baseDim);
+ }
+ }
Review Comment:
The `count >= rawCount` clause makes this branch run for the common case
where `seriesModel.getData().count() === seriesModel.getRawData().count()`
(i.e., no filtering / fully zoomed out). That forces `countDataInAxisExtent` to
do an extra O(n) scan even when the current axis extent already contains the
full data extent, which is a performance regression on large line series.
Consider relying on the extent check alone (e.g. only count when
`!dataExtentInAxisExtent(...)`), and/or short-circuit after computing
`dataCount` when `dataCount <= size` so you don’t pay the scan cost when
sampling won’t happen anyway.
--
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]