提交 ec08c772 编写于 作者: L lang

Value, coord and point

上级 2ea759a6
......@@ -15,7 +15,7 @@ define(function(require) {
type: 'cartesian2d',
/**
* If contain coord
* If contain point
*/
containPoint: function (x, y) {
return this.getAxis('x').contain(x)
......@@ -23,7 +23,7 @@ define(function(require) {
},
/**
* Convert series data to coorindates
* Convert series data to a list of points
* @param {module:echarts/data/List} data
* @return {Array}
* Return list of coordinates. For example:
......
......@@ -51,6 +51,15 @@ define(function(require) {
type: 'polar',
/**
* If contain coord
*/
containPoint: function (point) {
var coord = this.pointToCoord(point);
return this._radiusAxis.contain(coord[0])
&& this._angleAxis.contain(coord[1]);
},
/**
* @return {module:echarts/coord/polar/AngleAxis}
*/
......@@ -66,7 +75,7 @@ define(function(require) {
},
/**
* Convert series data to a list of coorindates
* Convert series data to a list of (x, y) points
* @param {module:echarts/data/List} data
* @return {Array}
* Return list of coordinates. For example:
......@@ -79,7 +88,7 @@ define(function(require) {
},
/**
* Convert a single data item to coordinate.
* Convert a single data item to (x, y) point.
* Parameter data is an array which the first element is radius and the second is angle
* @param {Array.<number>} data
* @return {Array.<number>}
......@@ -95,13 +104,27 @@ define(function(require) {
},
/**
* Convert a coord to data
* @param {Array.<number>} coord
* Convert a (x, y) point to data
* @param {Array.<number>} point
* @return {Array.<number>}
*/
pointToData: function (point) {
var coord = this.pointToCoord(point);
return [
this._radiusAxis.radiusToData(coord[0]),
this._angleAxis.angleToData(coord[1]) / Math.PI * 180
];
},
/**
* Convert a (x, y) point to (radius, angle) coord
* @param {Array.<number>} point
* @return {Array.<number>}
*/
pointToData: function (coord) {
var dx = coord[0] - this.cx;
var dy = coord[1] - this.cy;
pointToCoord: function (point) {
var dx = point[0] - this.cx;
var dy = point[1] - this.cy;
var radius = Math.sqrt(dx * dx + dy * dy);
dx /= radius;
......@@ -109,10 +132,7 @@ define(function(require) {
var angle = Math.atan2(dy, dx);
return [
this._radiusAxis.radiusToData(radius),
this._angleAxis.angleToData(angle) / Math.PI * 180
];
return [radius, angle];
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册