Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pie chart adds filterValue parameter #8997

Merged
merged 11 commits into from
Jan 9, 2019
21 changes: 15 additions & 6 deletions src/chart/pie/PieView.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,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 data._sum * labelDisplayThreshold > data.get(valueDim, idx);
}

piePieceProto._updateLabel = function (data, idx) {

var labelLine = this.childAt(1);
Expand All @@ -221,6 +228,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: {
Expand Down Expand Up @@ -264,11 +272,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({
Expand Down Expand Up @@ -319,7 +327,8 @@ var PieView = ChartView.extend({
);

var selectedMode = seriesModel.get('selectedMode');

var valueDim = data.mapDimension('value');
data._sum = data.getSum(valueDim) || 0;
Copy link
Member

@100pah 100pah Oct 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By convention, a property name prefixed by a single '_' represents a "private member" of a class. We should not add other that kind of properties (_xxx) outside the class definition dynamically. Otherwise, it probably confuses the code reader and might overwrite the inner private members with the same name.

If we need to save the sum here, it's OK to save it to this, because in this module we have the legal control of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,I can save sum to this.I change it

data.diff(oldData)
.add(function (idx) {
var piePiece = new PiePiece(data, idx);
Expand Down Expand Up @@ -411,4 +420,4 @@ var PieView = ChartView.extend({

});

export default PieView;
export default PieView;