提交 20803788 编写于 作者: K kener

axis label支持点击事件 #287

上级 c35ce56a
......@@ -19,7 +19,9 @@ define(function (require) {
var LineShape = require('zrender/shape/Line');
var ecConfig = require('../config');
var ecData = require('../util/ecData');
var zrUtil = require('zrender/tool/util');
var zrColor = require('zrender/tool/color');
/**
* 构造函数
......@@ -127,6 +129,24 @@ define(function (require) {
this.shapeList.push(axShape);
},
_axisLabelClickable : function(clickable, axShape) {
if (clickable) {
ecData.pack(
axShape, undefined, -1, undefined, -1, axShape.style.text
);
axShape.hoverable = true;
axShape.clickable = true;
axShape.highlightStyle = {
color : zrColor.lift(axShape.style.color, 1),
brushType: 'fill'
};
return axShape;
}
else {
return axShape;
}
},
refixAxisShape : function(zeroX, zeroY) {
if (!this.option.axisLine.onZero) {
return;
......
......@@ -260,6 +260,7 @@ define(function (require) {
var dataLength = this.option.data.length;
var rotate = this.option.axisLabel.rotate;
var margin = this.option.axisLabel.margin;
var clickable = this.option.axisLabel.clickable;
var textStyle = this.option.axisLabel.textStyle;
var dataTextStyle;
......@@ -311,7 +312,9 @@ define(function (require) {
axShape.style.y
];
}
this.shapeList.push(new TextShape(axShape));
this.shapeList.push(new TextShape(
this._axisLabelClickable(clickable, axShape)
));
}
}
else {
......@@ -364,11 +367,13 @@ define(function (require) {
axShape.style.y
];
}
this.shapeList.push(new TextShape(axShape));
this.shapeList.push(new TextShape(
this._axisLabelClickable(clickable, axShape)
));
}
}
},
_buildSplitLine : function () {
var axShape;
//var data = this.option.data;
......
......@@ -131,6 +131,7 @@ define(function (require) {
var dataLength = this._valueList.length;
var rotate = this.option.axisLabel.rotate;
var margin = this.option.axisLabel.margin;
var clickable = this.option.axisLabel.clickable;
var textStyle = this.option.axisLabel.textStyle;
if (this.isHorizontal()) {
......@@ -173,7 +174,9 @@ define(function (require) {
axShape.style.y
];
}
this.shapeList.push(new TextShape(axShape));
this.shapeList.push(new TextShape(
this._axisLabelClickable(clickable, axShape)
));
}
}
else {
......@@ -218,7 +221,9 @@ define(function (require) {
axShape.style.y
];
}
this.shapeList.push(new TextShape(axShape));
this.shapeList.push(new TextShape(
this._axisLabelClickable(clickable, axShape)
));
}
}
},
......
......@@ -314,6 +314,7 @@ define(function() {
interval: 'auto',
rotate: 0,
margin: 8,
// clickable: false,
// formatter: null,
textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
color: '#333'
......@@ -372,6 +373,7 @@ define(function() {
show: true,
rotate: 0,
margin: 8,
// clickable: false,
// formatter: null,
textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
color: '#333'
......
......@@ -547,7 +547,7 @@ define(function (require) {
var seriesIndex = ecData.get(target, 'seriesIndex');
var dataIndex = ecData.get(target, 'dataIndex');
dataIndex = this.component.dataZoom
dataIndex = seriesIndex != -1 && this.component.dataZoom
? this.component.dataZoom.getRealDataIndex(
seriesIndex,
dataIndex
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册