-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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
fix bug #7340 #11295
fix bug #7340 #11295
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,21 +179,28 @@ export default echarts.extendComponentView({ | |
if (seriesModel) { | ||
var data = seriesModel.getData(); | ||
var color = data.getVisual('color'); | ||
var borderColor = data.getVisual('borderColor'); | ||
|
||
// If color is a callback function | ||
if (typeof color === 'function') { | ||
// Use the first data | ||
color = color(seriesModel.getDataParams(0)); | ||
} | ||
|
||
// If borderColor is a callback function | ||
if (typeof borderColor === 'function') { | ||
// Use the first data | ||
borderColor = borderColor(seriesModel.getDataParams(0)); | ||
} | ||
|
||
// Using rect symbol defaultly | ||
var legendSymbolType = data.getVisual('legendSymbol') || 'roundRect'; | ||
var symbolType = data.getVisual('symbol'); | ||
|
||
var itemGroup = this._createItem( | ||
name, dataIndex, itemModel, legendModel, | ||
legendSymbolType, symbolType, | ||
itemAlign, color, | ||
itemAlign, color, borderColor, | ||
selectMode | ||
); | ||
|
||
|
@@ -219,13 +226,14 @@ export default echarts.extendComponentView({ | |
} | ||
|
||
var color = data.getItemVisual(idx, 'color'); | ||
var borderColor = data.getItemVisual(idx, 'borderColor'); | ||
|
||
var legendSymbolType = 'roundRect'; | ||
|
||
var itemGroup = this._createItem( | ||
name, dataIndex, itemModel, legendModel, | ||
legendSymbolType, null, | ||
itemAlign, color, | ||
itemAlign, color, borderColor, | ||
selectMode | ||
); | ||
|
||
|
@@ -299,12 +307,14 @@ export default echarts.extendComponentView({ | |
_createItem: function ( | ||
name, dataIndex, itemModel, legendModel, | ||
legendSymbolType, symbolType, | ||
itemAlign, color, selectMode | ||
itemAlign, color, borderColor, selectMode | ||
) { | ||
var itemWidth = legendModel.get('itemWidth'); | ||
var itemHeight = legendModel.get('itemHeight'); | ||
var inactiveColor = legendModel.get('inactiveColor'); | ||
var inactiveBorderColor = legendModel.get('inactiveBorderColor'); | ||
var symbolKeepAspect = legendModel.get('symbolKeepAspect'); | ||
var itemStyle = legendModel.getModel('itemStyle').getItemStyle(); | ||
|
||
var isSelected = legendModel.isSelected(name); | ||
var itemGroup = new Group(); | ||
|
@@ -318,7 +328,7 @@ export default echarts.extendComponentView({ | |
|
||
// Use user given icon first | ||
legendSymbolType = itemIcon || legendSymbolType; | ||
itemGroup.add(createSymbol( | ||
var legendSymbol = createSymbol( | ||
legendSymbolType, | ||
0, | ||
0, | ||
|
@@ -327,7 +337,13 @@ export default echarts.extendComponentView({ | |
isSelected ? color : inactiveColor, | ||
// symbolKeepAspect default true for legend | ||
symbolKeepAspect == null ? true : symbolKeepAspect | ||
)); | ||
); | ||
itemGroup.add( | ||
setSympleStyle( | ||
legendSymbol, legendSymbolType, itemStyle, | ||
borderColor, inactiveBorderColor, isSelected | ||
) | ||
); | ||
|
||
// Compose symbols | ||
// PENDING | ||
|
@@ -339,8 +355,7 @@ export default echarts.extendComponentView({ | |
if (symbolType === 'none') { | ||
symbolType = 'circle'; | ||
} | ||
// Put symbol in the center | ||
itemGroup.add(createSymbol( | ||
var legendSymbolCenter = createSymbol( | ||
symbolType, | ||
(itemWidth - size) / 2, | ||
(itemHeight - size) / 2, | ||
|
@@ -349,7 +364,14 @@ export default echarts.extendComponentView({ | |
isSelected ? color : inactiveColor, | ||
// symbolKeepAspect default true for legend | ||
symbolKeepAspect == null ? true : symbolKeepAspect | ||
)); | ||
); | ||
// Put symbol in the center | ||
itemGroup.add( | ||
setSympleStyle( | ||
legendSymbolCenter, symbolType, itemStyle, | ||
borderColor, inactiveBorderColor, isSelected | ||
) | ||
); | ||
} | ||
|
||
var textX = itemAlign === 'left' ? itemWidth + 5 : -5; | ||
|
@@ -481,6 +503,17 @@ export default echarts.extendComponentView({ | |
|
||
}); | ||
|
||
function setSympleStyle(symbol, symbolType, itemStyle, borderColor, inactiveBorderColor, isSelected) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: Symple |
||
if (symbolType !== 'line' && symbolType.indexOf('empty') < 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it is a good practice to set stroke here. So if intending to modify There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank @100pah for the very detailed review. I have a different opinion about this part. The |
||
symbol.style.stroke = borderColor; | ||
if (!isSelected) { | ||
itemStyle.stroke = inactiveBorderColor; | ||
} | ||
symbol.setStyle(itemStyle); | ||
} | ||
return symbol; | ||
} | ||
|
||
function dispatchSelectAction(name, api) { | ||
api.dispatchAction({ | ||
type: 'legendToggleSelect', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,10 +53,13 @@ export default function (seriesType) { | |
var singleDataColor = filteredIdx != null | ||
&& data.getItemVisual(filteredIdx, 'color', true); | ||
|
||
if (!singleDataColor) { | ||
// FIXME Performance | ||
var itemModel = dataAll.getItemModel(rawIdx); | ||
var singleDataBorderColor = filteredIdx != null | ||
&& data.getItemVisual(filteredIdx, 'borderColor', true); | ||
|
||
// FIXME Performance | ||
var itemModel = dataAll.getItemModel(rawIdx); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this sentence has performance issue in large data render cases, |
||
|
||
if (!singleDataColor) { | ||
var color = itemModel.get('itemStyle.color') | ||
|| seriesModel.getColorFromPalette( | ||
dataAll.getName(rawIdx) || (rawIdx + ''), seriesModel.__paletteScope, | ||
|
@@ -74,6 +77,25 @@ export default function (seriesType) { | |
// Set data all color for legend | ||
dataAll.setItemVisual(rawIdx, 'color', singleDataColor); | ||
} | ||
|
||
if (!singleDataBorderColor) { | ||
var borderColor = itemModel.get('itemStyle.borderColor') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some historical reason, we have both |
||
|| seriesModel.getColorFromPalette( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should indent, according to the code style standard. |
||
dataAll.getName(rawIdx) || (rawIdx + ''), seriesModel.__paletteScope, | ||
dataAll.count() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
); | ||
// Legend may use the visual info in data before processed | ||
dataAll.setItemVisual(rawIdx, 'borderColor', borderColor); | ||
|
||
// Data is not filtered | ||
if (filteredIdx != null) { | ||
data.setItemVisual(filteredIdx, 'borderColor', borderColor); | ||
} | ||
} | ||
else { | ||
// Set data all borderColor for legend | ||
dataAll.setItemVisual(rawIdx, 'borderColor', singleDataBorderColor); | ||
} | ||
}); | ||
} | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,15 @@ export default { | |
|
||
// FIXME Set color function or use the platte color | ||
data.setVisual('color', color); | ||
|
||
var borderColorAccessPath = (seriesModel.visualBorderColorAccessPath || 'itemStyle.borderColor').split('.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For historical reason, we have both 'borderColor' and 'barBorderColor'. |
||
var borderColor = seriesModel.get(borderColorAccessPath) // Set in itemStyle | ||
|| seriesModel.getColorFromPalette( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should not repeat it, now that it both used in two places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should not repeat it, now that it both used in two places. |
||
// TODO series count changed. | ||
seriesModel.name, null, ecModel.getSeriesCount() | ||
); // Default borderColor | ||
// FIXME Set borderColor function or use the platte borderColor | ||
data.setVisual('borderColor', borderColor); | ||
|
||
// Only visible series has each data be visual encoded | ||
if (!ecModel.isSeriesFiltered(seriesModel)) { | ||
|
@@ -41,16 +50,23 @@ export default { | |
data.setItemVisual( | ||
idx, 'color', color(seriesModel.getDataParams(idx)) | ||
); | ||
data.setItemVisual( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer do not support set callback function for |
||
idx, 'borderColor', borderColor(seriesModel.getDataParams(idx)) | ||
); | ||
}); | ||
} | ||
|
||
// itemStyle in each data item | ||
var dataEach = function (data, idx) { | ||
var itemModel = data.getItemModel(idx); | ||
var color = itemModel.get(colorAccessPath, true); | ||
var borderColor = itemModel.get(borderColorAccessPath, true); | ||
if (color != null) { | ||
data.setItemVisual(idx, 'color', color); | ||
} | ||
if (borderColor != null) { | ||
data.setItemVisual(idx, 'borderColor', borderColor); | ||
} | ||
}; | ||
|
||
return { dataEach: data.hasItemOption ? dataEach : null }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use English please.
Although the previous comment is Chinese, we should change it to English gradually,
usually when modifying the file.