You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/01/09 14:10:08 UTC

[GitHub] 100pah closed pull request #8997: Pie chart adds filterValue parameter

100pah closed pull request #8997: Pie chart adds filterValue parameter
URL: https://github.com/apache/incubator-echarts/pull/8997
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/chart/pie/PieView.js b/src/chart/pie/PieView.js
index 84697f598..3ed3b0cb5 100644
--- a/src/chart/pie/PieView.js
+++ b/src/chart/pie/PieView.js
@@ -94,6 +94,9 @@ function PiePiece(data, idx) {
     this.add(sector);
     this.add(polyline);
     this.add(text);
+    
+    var valueDim = data.mapDimension('value');
+    this._sum = data.getSum(valueDim) || 0;
 
     this.updateData(data, idx, true);
 
@@ -211,6 +214,13 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
     graphic.setHoverStyle(this);
 };
 
+piePieceProto._getLabelDisplayThresholdState = function (data, idx) {
+    var seriesModel = data.hostModel;
+    var valueDim = data.mapDimension('value');
+    var labelDisplayThreshold = seriesModel.get('labelDisplayThreshold');
+    return this._sum * labelDisplayThreshold > data.get(valueDim, idx);
+}
+
 piePieceProto._updateLabel = function (data, idx) {
 
     var labelLine = this.childAt(1);
@@ -221,6 +231,7 @@ piePieceProto._updateLabel = function (data, idx) {
     var layout = data.getItemLayout(idx);
     var labelLayout = layout.label;
     var visualColor = data.getItemVisual(idx, 'color');
+    var filterLabelIgnore = this._getLabelDisplayThresholdState(data, idx);
 
     graphic.updateProps(labelLine, {
         shape: {
@@ -264,11 +275,11 @@ piePieceProto._updateLabel = function (data, idx) {
         }
     );
 
-    labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
-    labelText.hoverIgnore = !labelHoverModel.get('show');
+    labelText.ignore = labelText.normalIgnore = !labelModel.get('show') || filterLabelIgnore;
+    labelText.hoverIgnore = !labelHoverModel.get('show') || filterLabelIgnore;
 
-    labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
-    labelLine.hoverIgnore = !labelLineHoverModel.get('show');
+    labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show') || filterLabelIgnore;
+    labelLine.hoverIgnore = !labelLineHoverModel.get('show') || filterLabelIgnore;
 
     // Default use item visual color
     labelLine.setStyle({
@@ -319,7 +330,6 @@ var PieView = ChartView.extend({
         );
 
         var selectedMode = seriesModel.get('selectedMode');
-
         data.diff(oldData)
             .add(function (idx) {
                 var piePiece = new PiePiece(data, idx);
@@ -411,4 +421,4 @@ var PieView = ChartView.extend({
 
 });
 
-export default PieView;
\ No newline at end of file
+export default PieView;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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