提交 387f8fd4 编写于 作者: L lang

Move areaStyle, lineStyle, label out of itemStyle

上级 ac7ef3e2
......@@ -38,6 +38,26 @@ define(function(require) {
barGap: '30%',
// 类目间柱形距离,默认为类目间距的20%,可设固定值
barCategoryGap: '20%',
label: {
normal: {
show: false
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// 默认自适应,水平布局为'top',垂直布局为'right',可选为
// 'inside' | 'insideleft' | 'insideTop' | 'insideRight' | 'insideBottom' |
// 'outside' |'left' | 'right'|'top'|'bottom'
// position:
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
},
emphasis: {
show: false
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
// 'inside'|'left'|'right'|'top'|'bottom'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
}
},
itemStyle: {
normal: {
// color: '各异',
......@@ -49,28 +69,16 @@ define(function(require) {
barBorderWidth: 0,
label: {
show: false
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// 默认自适应,水平布局为'top',垂直布局为'right',可选为
// 'inside' | 'insideleft' | 'insideTop' | 'insideRight' | 'insideBottom' |
// 'outside' |'left' | 'right'|'top'|'bottom'
// position:
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
}
},
emphasis: {
// color: '各异',
barBorderColor: '#fff', // 柱条边线
barBorderRadius: 0, // 柱条边线圆角,单位px,默认为0
barBorderWidth: 0, // 柱条边线线宽,单位px,默认为1
label: {
show: false
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
// 'inside'|'left'|'right'|'top'|'bottom'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
}
// 柱条边线
barBorderColor: '#fff',
// 柱条边线圆角,单位px,默认为0
barBorderRadius: 0,
// 柱条边线线宽,单位px,默认为1
barBorderWidth: 0,
}
}
}
......
......@@ -99,7 +99,7 @@ define(function (require) {
_updateStyle: function (seriesModel, data, isHorizontal) {
data.eachItemGraphicEl(function (rect, idx) {
var itemModel = data.getItemModel(idx);
var labelModel = itemModel.getModel('itemStyle.normal.label');
var labelModel = itemModel.getModel('label.normal');
var color = data.getItemVisual(idx, 'color');
var layout = data.getItemLayout(idx);
......
......@@ -196,7 +196,7 @@ define(function (require) {
data.eachItemGraphicEl(function (el, idx) {
var itemModel = data.getItemModel(idx);
var normalItemStyleModel = itemModel.getModel(itemStyleAccessPath);
var labelModel = normalItemStyleModel.getModel('label');
var labelModel = itemModel.getModel('label.normal');
var color = data.getItemVisual(idx, 'color');
zrUtil.extend(
......
......@@ -27,36 +27,44 @@ define(function(require) {
gridIndex: 0,
// 'nearest', 'min', 'max', 'average'
dataFilter: 'nearest',
label: {
normal: {
show: false
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
// 'inside'|'left'|'right'|'top'|'bottom'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
},
emphasis: {
show: false
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
// 'inside'|'left'|'right'|'top'|'bottom'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
}
},
itemStyle: {
normal: {
// color: 各异,
label: {
show: false
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
// 'inside'|'left'|'right'|'top'|'bottom'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
},
lineStyle: {
width: 2,
type: 'solid',
shadowColor: 'rgba(0,0,0,0)', //默认透明
shadowBlur: 0,
shadowOffsetX: 0,
shadowOffsetY: 0
}
// color: 各异
},
emphasis: {
// color: 各异,
label: {
show: false
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
// 'inside'|'left'|'right'|'top'|'bottom'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
}
}
},
lineStyle: {
normal: {
width: 2,
type: 'solid',
shadowColor: 'rgba(0,0,0,0)', //默认透明
shadowBlur: 0,
shadowOffsetX: 0,
shadowOffsetY: 0
}
},
// areaStyle: {
// },
// smooth: false,
// 拐点图形类型
symbol: 'emptyCircle',
......
......@@ -92,8 +92,8 @@ define(function(require) {
var coordSys = seriesModel.coordinateSystem;
var group = this.group;
var data = seriesModel.getData();
var lineStyleModel = seriesModel.getModel('itemStyle.normal.lineStyle');
var areaStyleModel = seriesModel.getModel('itemStyle.normal.areaStyle');
var lineStyleModel = seriesModel.getModel('lineStyle.normal');
var areaStyleModel = seriesModel.getModel('areaStyle.normal');
var points = data.mapArray(data.getItemLayout, true);
......
......@@ -86,35 +86,54 @@ define(function (require) {
clickable: true,
// 是否开启缩放及漫游模式
// roam: false,
// 在 roam 开启的时候使用
roamDetail: {
x: 0,
y: 0,
zoom: 1
},
label: {
normal: {
show: false,
textStyle: {
color: '#000'
}
},
emphasis: {
show: false,
textStyle: {
color: '#000'
}
}
},
// scaleLimit: null,
itemStyle: {
normal: {
// color: 各异,
borderWidth: 0.5,
borderColor: '#444',
areaStyle: {
color: '#eee'
},
label: {
show: false,
textStyle: {
color: '#000'
}
}
areaColor: '#eee'
},
// 也是选中样式
emphasis: {
areaStyle: {
color: 'rgba(255,215,0,0.8)'
},
label: {
show: false,
textStyle: {
color: '#000'
}
}
areaColor: 'rgba(255,215,0,0.8)'
}
}
}
},
setRoamZoom: function (zoom) {
var roamDetail = this.option.roamDetail;
roamDetail && (roamDetail.zoom = zoom);
},
setRoamPan: function (x, y) {
var roamDetail = this.option.roamDetail;
if (roamDetail) {
roamDetail.x = x;
roamDetail.y = y;
}
}
})
});
\ No newline at end of file
......@@ -4,7 +4,7 @@ define(function (require) {
var colorList = ecModel.get('color');
var itemStyleModel = seriesModel.getModel('itemStyle.normal');
var areaColor = itemStyleModel.get('areaStyle.color');
var areaColor = itemStyleModel.get('areaColor');
var color = itemStyleModel.get('color')
|| colorList[seriesModel.seriesIndex % colorList.length];
......
......@@ -104,52 +104,41 @@ define(function(require) {
// selectedMode: false,
// 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
// roseType: null,
label: {
normal: {
show: true,
// 'outer', 'inside', 'center'
position: 'outer'
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
// distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
},
emphasis: {}
},
// Enabled when label.normal.position is 'outer'
labelLine: {
show: true,
// 引导线两段中的第一段长度
length: 20,
// 引导线两段中的第二段长度
length2: 5,
lineStyle: {
// color: 各异,
width: 1,
type: 'solid'
}
},
itemStyle: {
normal: {
// color: 各异,
borderColor: 'rgba(0,0,0,0)',
borderWidth: 1,
label: {
show: true,
// 'outer', 'inside', 'center'
position: 'outer'
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
// distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
},
labelLine: {
show: true,
// 引导线两段中的第一段长度
length: 20,
// 引导线两段中的第二段长度
length2: 5,
lineStyle: {
// color: 各异,
width: 1,
type: 'solid'
}
}
borderWidth: 1
},
emphasis: {
// color: 各异,
borderColor: 'rgba(0,0,0,0)',
borderWidth: 1,
label: {
show: false
// position: 'outer'
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
// distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
},
labelLine: {
show: false,
length: 20,
lineStyle: {
// color: 各异,
width: 1,
type: 'solid'
}
}
borderWidth: 1
}
}
}
......
// FIXME emphasis label position is not same with normal label position
define(function (require) {
'use strict';
......@@ -6,9 +7,7 @@ define(function (require) {
return function (seriesModel) {
var data = seriesModel.getData();
var itemStyleModel = seriesModel.getModel('itemStyle.normal');
var labelLineModel = itemStyleModel.getModel('labelLine');
var labelModel = itemStyleModel.getModel('label')
var labelLineModel = seriesModel.getModel('labelLine');
var labelLineLen = labelLineModel.get('length');
var labelLineLen2 = labelLineModel.get('length2');
......@@ -18,7 +17,7 @@ define(function (require) {
data.each(function (idx) {
var layout = data.getItemLayout(idx);
var itemModel = data.getItemModel(idx);
var labelModel = itemModel.getModel('itemStyle.normal.label');
var labelModel = itemModel.getModel('label.normal');
var font = labelModel.getModel('textStyle').getFont();
var labelPosition = labelModel.get('position');
......
......@@ -37,27 +37,23 @@ define(function (require) {
// symbol: null, // 图形类型
symbolSize: 4, // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
// symbolRotate: null, // 图形旋转控制
itemStyle: {
label: {
normal: {
opacity: 0.8,
// color: 各异,
label: {
show: false
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
// 'inside'|'left'|'right'|'top'|'bottom'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
}
show: false
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
// 'inside'|'left'|'right'|'top'|'bottom'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
},
emphasis: {
// color: '各异'
label: {
show: false
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
// position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
// 'inside'|'left'|'right'|'top'|'bottom'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
}
show: false
}
},
itemStyle: {
normal: {
opacity: 0.8,
// color: 各异
}
}
}
......
......@@ -13,11 +13,11 @@ define(function(require) {
update: 'updateView'
};
echarts.registerAction(actionInfo, function (event, ecModel) {
echarts.registerAction(actionInfo, function (payload, ecModel) {
var fromDataRangeModel = ecModel.getComponentById(event.dataRangeModelId);
var fromDataRangeModel = ecModel.getComponentById(payload.dataRangeModelId);
fromDataRangeModel && fromDataRangeModel.setSelected(event.selected);
fromDataRangeModel && fromDataRangeModel.setSelected(payload.selected);
// Find all dataRangeModel that has the same visualType and controls the same series.
// var linkedNodesFinder = modelUtil.createLinkedNodesFinder(
......@@ -40,7 +40,7 @@ define(function(require) {
// var effectedModels = linkedNodesFinder(fromDataRangeModel).nodes;
// zrUtil.each(effectedModels, function (dataRangeModel) {
// fromDataRangeModel.setSelected(event.selected);
// fromDataRangeModel.setSelected(payload.selected);
// });
});
......
......@@ -20,6 +20,8 @@ define(function (require) {
var zrender = require('zrender');
var zrUtil = require('zrender/core/util');
var each = zrUtil.each;
var VISUAL_CODING_STAGES = ['echarts', 'chart', 'component'];
// TODO Transform first or filter first
......@@ -110,6 +112,10 @@ define(function (require) {
// PENDING
option = zrUtil.clone(option, true);
each(optionPreprocessorFuncs, function (preProcess) {
preProcess(option);
})
var ecModel = this._model;
if (!ecModel || notMerge) {
ecModel = new GlobalModel(option, null, this._theme);
......@@ -162,11 +168,7 @@ define(function (require) {
this._coordinateSystem.update(ecModel, this._extensionAPI);
this._doLayout(ecModel, payload);
this._doVisualCoding(ecModel);
this._doRender(ecModel, payload);
this.updateView(payload);
// Set background
this._dom.style.backgroundColor = ecModel.get('backgroundColor');
......@@ -208,7 +210,7 @@ define(function (require) {
var actionWrap = actions[payload.type];
if (actionWrap) {
actionWrap.action(payload, this._model);
this[actionWrap.update || 'update'](payload);
this[actionWrap.actionInfo.update || 'update'](payload);
}
},
......@@ -318,8 +320,8 @@ define(function (require) {
* @private
*/
_processData: function (ecModel) {
zrUtil.each(PROCESSOR_STAGES, function (stage) {
zrUtil.each(dataProcessorFuncs[stage] || [], function (process) {
each(PROCESSOR_STAGES, function (stage) {
each(dataProcessorFuncs[stage] || [], function (process) {
process(ecModel);
});
});
......@@ -351,10 +353,10 @@ define(function (require) {
*/
_doLayout: function (ecModel, event) {
var api = this._extensionAPI;
zrUtil.each(this._layouts, function (layout) {
each(this._layouts, function (layout) {
layout.update(ecModel, api, event);
});
zrUtil.each(layoutFuncs, function (layout) {
each(layoutFuncs, function (layout) {
layout(ecModel, api, event);
});
},
......@@ -366,8 +368,8 @@ define(function (require) {
* @private
*/
_doVisualCoding: function (ecModel) {
zrUtil.each(VISUAL_CODING_STAGES, function (stage) {
zrUtil.each(visualCodingFuncs[stage] || [], function (visualCoding) {
each(VISUAL_CODING_STAGES, function (stage) {
each(visualCodingFuncs[stage] || [], function (visualCoding) {
visualCoding(ecModel);
});
});
......@@ -379,7 +381,7 @@ define(function (require) {
_doRender: function (ecModel, event) {
var api = this._extensionAPI;
// Render all components
zrUtil.each(this._componentsList, function (component) {
each(this._componentsList, function (component) {
var componentModel = component.__model;
component.render(componentModel, ecModel, api, event);
......@@ -392,7 +394,7 @@ define(function (require) {
});
}, this);
zrUtil.each(this._chartsList, function (chart) {
each(this._chartsList, function (chart) {
chart.__keepAlive = false;
}, this);
......@@ -413,7 +415,7 @@ define(function (require) {
}, this);
// Remove groups of charts
zrUtil.each(this._chartsList, function (chart) {
each(this._chartsList, function (chart) {
if (!chart.__keepAlive) {
chart.remove(ecModel, api);
}
......@@ -421,10 +423,10 @@ define(function (require) {
},
dispose: function () {
zrUtil.each(this._components, function (component) {
each(this._components, function (component) {
component.dispose();
});
zrUtil.each(this._charts, function (chart) {
each(this._charts, function (chart) {
chart.dispose();
});
......@@ -458,6 +460,12 @@ define(function (require) {
*/
var dataProcessorFuncs = {};
/**
* @type {Array.<Function>}
* @inner
*/
var optionPreprocessorFuncs = [];
/**
* Visual coding functions of each stage
* @type {Array.<Object.<string, Function>>}
......@@ -479,6 +487,14 @@ define(function (require) {
return new ECharts(dom, theme, opts);
},
/**
* Register option preprocessor
* @param {Function} preprocessorFunc
*/
registerPreprocessor: function (preprocessorFunc) {
optionPreprocessorFuncs.push(preprocessorFunc);
},
/**
* @param {string} stage
* @param {Function} processorFunc
......@@ -587,5 +603,7 @@ define(function (require) {
echarts.registerVisualCoding('echarts', require('./visual/defaultColor'));
echarts.registerPreprocessor(require('./preprocessor/backwardCompat'));
return echarts;
});
\ No newline at end of file
// Compatitable with 2.0
define(function (require) {
var zrUtil = require('zrender/core/util');
var POSSIBLE_STYLES = [
'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle',
'chordStyle', 'label'
];
var each = zrUtil.each;
function compatItemStyle(opt) {
var itemStyleOpt = opt.itemStyle;
if (itemStyleOpt) {
each(POSSIBLE_STYLES, function (styleName) {
var normalItemStyleOpt = itemStyleOpt.normal;
var emphasisItemStyleOpt = itemStyleOpt.emphasis;
opt[styleName] = opt[styleName] || {
};
if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
if (!opt[styleName].normal) {
opt[styleName].normal = normalItemStyleOpt[styleName];
}
else {
zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]);
}
normalItemStyleOpt[styleName] = null;
}
if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
if (!opt[styleName].emphasis) {
opt[styleName].emphasis = emphasisItemStyleOpt[styleName];
}
else {
zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]);
}
emphasisItemStyleOpt[styleName] = null;
}
});
}
}
function compatMapSeries(opt) {
}
return function (option) {
zrUtil.each(option.series, function (seriesOpt) {
compatItemStyle(seriesOpt);
var data = seriesOpt.data;
if (data) {
for (var i = 0; i < data.length; i++) {
compatItemStyle(data[i]);
}
}
});
}
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册