You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/10/22 05:37:15 UTC

[incubator-echarts] branch next updated: feat(bar): add sampling support in bar. some code cleanup

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/next by this push:
     new 2fcb411  feat(bar): add sampling support in bar. some code cleanup
2fcb411 is described below

commit 2fcb41198e0a51496e41a0d44d8ec75bb6ba1ea8
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Oct 22 13:33:24 2020 +0800

    feat(bar): add sampling support in bar. some code cleanup
    
    Even in large mode drawing bar can be slow when has ten thousands of data. Because canvas may do merge on those paths before fill. This merge is very slow.
---
 src/chart/bar.ts                        | 7 +++++++
 src/chart/bar/BarSeries.ts              | 5 +++--
 src/chart/bar/BarView.ts                | 8 ++------
 src/util/types.ts                       | 1 -
 test/circle-packing-with-d3.compat.html | 1 +
 test/circle-packing-with-d3.html        | 1 +
 test/clip-large1.html                   | 1 +
 7 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/chart/bar.ts b/src/chart/bar.ts
index 1370124..27ecad4 100644
--- a/src/chart/bar.ts
+++ b/src/chart/bar.ts
@@ -27,6 +27,7 @@ import './bar/BarView';
 import '../action/changeAxisOrder';
 // In case developer forget to include grid component
 import '../component/gridSimple';
+import dataSample from '../processor/dataSample';
 
 
 echarts.registerLayout(echarts.PRIORITY.VISUAL.LAYOUT, zrUtil.curry(layout, 'bar'));
@@ -41,3 +42,9 @@ echarts.registerVisual({
         seriesModel.getData().setVisual('legendSymbol', 'roundRect');
     }
 });
+
+// Down sample after filter
+echarts.registerProcessor(
+    echarts.PRIORITY.PROCESSOR.STATISTIC,
+    dataSample('bar')
+);
diff --git a/src/chart/bar/BarSeries.ts b/src/chart/bar/BarSeries.ts
index 730f8b0..2c29401 100644
--- a/src/chart/bar/BarSeries.ts
+++ b/src/chart/bar/BarSeries.ts
@@ -25,7 +25,8 @@ import {
     LabelOption,
     SeriesStackOptionMixin,
     StatesOptionMixin,
-    OptionDataItemObject
+    OptionDataItemObject,
+    SeriesSamplingOptionMixin
 } from '../../util/types';
 import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
 import type Polar from '../../coord/polar/Polar';
@@ -49,7 +50,7 @@ export interface BarDataItemOption extends BarStateOption, StatesOptionMixin<Bar
 }
 
 export interface BarSeriesOption extends BaseBarSeriesOption<BarStateOption>, BarStateOption,
-    SeriesStackOptionMixin {
+    SeriesStackOptionMixin, SeriesSamplingOptionMixin {
 
     type?: 'bar'
 
diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts
index 8e4469e..012f813 100644
--- a/src/chart/bar/BarView.ts
+++ b/src/chart/bar/BarView.ts
@@ -29,7 +29,7 @@ import {
 } from '../../util/graphic';
 import { getECData } from '../../util/innerStore';
 import { enableHoverEmphasis, setStatesStylesFromModel } from '../../util/states';
-import { setLabelStyle, getLabelStatesModels, labelInner, setLabelValueAnimation } from '../../label/labelStyle';
+import { setLabelStyle, getLabelStatesModels, setLabelValueAnimation } from '../../label/labelStyle';
 import {throttle} from '../../util/throttle';
 import {createClipPath} from '../helper/createClipPathFromCoordSys';
 import Sausage from '../../util/shape/sausage';
@@ -44,8 +44,7 @@ import {
     OrdinalSortInfo,
     Payload,
     OrdinalNumber,
-    ParsedValue,
-    ECElement
+    ParsedValue
 } from '../../util/types';
 import BarSeriesModel, {BarSeriesOption, BarDataItemOption} from './BarSeries';
 import type Axis2D from '../../coord/cartesian/Axis2D';
@@ -238,9 +237,6 @@ class BarView extends ChartView {
         const isInitSort = payload && payload.isInitSort;
         const isChangeOrder = payload && payload.type === 'changeAxisOrder';
 
-        const defaultTextGetter = (values: ParsedValue | ParsedValue[]) => {
-            return getDefaultInterpolatedLabel(seriesModel.getData(), values);
-        };
         function createBackground(dataIndex: number) {
             const bgLayout = getLayout[coord.type](data, dataIndex);
             const bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
diff --git a/src/util/types.ts b/src/util/types.ts
index fd2c990..af92a0c 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -46,7 +46,6 @@ import { PathStyleProps } from 'zrender/src/graphic/Path';
 import { ImageStyleProps } from 'zrender/src/graphic/Image';
 import ZRText, { TextStyleProps } from 'zrender/src/graphic/Text';
 import { Source } from '../data/Source';
-import { ModelFinderObject } from './model';
 
 
 
diff --git a/test/circle-packing-with-d3.compat.html b/test/circle-packing-with-d3.compat.html
index 486b6e3..3c4418b 100644
--- a/test/circle-packing-with-d3.compat.html
+++ b/test/circle-packing-with-d3.compat.html
@@ -45,6 +45,7 @@ text {
 <svg width="960" height="960"><g transform="translate(1,1)"></g></svg>
 <script src="https://d3js.org/d3.v4.min.js"></script>
 <script src="../dist/echarts.js"></script>
+<script src="./lib/config.js"></script>
 <script>
 
 var stratify = d3.stratify()
diff --git a/test/circle-packing-with-d3.html b/test/circle-packing-with-d3.html
index ca65ae3..55082da 100644
--- a/test/circle-packing-with-d3.html
+++ b/test/circle-packing-with-d3.html
@@ -46,6 +46,7 @@ text {
 <script src="https://d3js.org/d3.v4.min.js"></script>
 <script src="../dist/echarts.js"></script>
 <script src="./lib/testHelper.js"></script>
+<script src="./lib/config.js"></script>
 <script>
 
 var stratify = d3.stratify()
diff --git a/test/clip-large1.html b/test/clip-large1.html
index cdb065f..76514eb 100644
--- a/test/clip-large1.html
+++ b/test/clip-large1.html
@@ -101,6 +101,7 @@ under the License.
                     series: {
                         type: 'bar',
                         large: true,
+                        sampling: 'lttb',
                         data: data
                     }
                 };


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org