Comments (7)
我猜你是在写地图数据是吗?如果是建议你下最新代码,全国34个省市级地图已经基本弄好了,先看看是否满足需求。
如果想开发别的,建议先从zrender入手,了解path的设置 http://ecomfe.github.io/zrender/doc/example/demo.html
from echarts.
不是地图数据 自定义的闭合曲线
两个平行的贝赛尔曲线围成的闭合曲线
给它加上鼠标事件
但是在图形的正下方有一块区域,不在图形内但是也会触发事件
area.js里面的_isInsidePolygon有点不明白
if (x < v) {// 在线的左侧,为什么要取反
inside = !inside;
}
from echarts.
哦,确实是,可以直接在这里 http://ecomfe.github.io/zrender/doc/example/demo.html 用下面代码验证
贝赛尔曲线拟合出的多边形用数学计算判断会有问题,特别是高阶的,目前没啥好办法,如果可以考虑不支持IE8-,最简单的方法是在area.js第40行加上这句“return _pixelMethod(shapeClazz, area, x, y);”,不分图形全都用像素拾取的方法判断hover
//--------------
zr.clear();
var p1 = {
x : 100,
y : 90
};
var cp = {
x : 200,
y : 90
};
var p2 = {
x : 500,
y : 290
};
var p21 = {
x : 100,
y : 100
};
var cp1 = {
x : 200,
y : 100
};
var p11 = {
x : 500,
y : 300
};
var polygon = [];
function bezierCurveTo(p1, cp, p2, width) {
var t = 0;
var c1x;
//将要求出的控制点的x
var c1y;
//将要求出的控制点的y
var c2x;
//将要求出的终点的x
var c2y;
//将要求出的终点的y
var px;
//二次贝赛尔曲线上的点的x
var py;
//二次贝赛尔曲线上的点的y
while (t < 1) {
/*
控制点是由起点和初始的控制点组成的一次/线性贝赛尔曲线上的点,
所以由一次/线性贝赛尔曲线函数表达式求出c1x,c1y
*/
c1x = p1.x + (cp.x - p1.x ) * t;
c1y = p1.y + (cp.y - p1.y ) * t;
/*
终点是由初始的控制点和初始的终点组成的一次/线性贝赛尔曲线上的点,
所以由一次/线性贝赛尔曲线函数表达式求出c2x,c2y
*/
c2x = cp.x + (p2.x - cp.x ) * t;
c2y = cp.y + (p2.y - cp.y ) * t;
/*
二次贝赛尔曲线上的点是由控制点和终点组成的一次/线性贝赛尔曲线上的点,
所以由一次/线性贝赛尔曲线函数表达式求出px,py
*/
px = c1x + (c2x - c1x ) * t;
py = c1y + (c2y - c1y ) * t;
//ctx.lineTo(px,py);
polygon.push({
x : px,
y : py
});
t += 0.001;
}
}
var arrow = '';
bezierCurveTo(p1,cp,p2);
arrow += 'M' + polygon[0].x+',' + polygon[0].y + ' C';
polygon.reduce(function(f,p){
arrow += p.x +',' +p.y+' ';
},0);
polygon = [];
bezierCurveTo(p11,cp1,p21);
arrow += 'L' + polygon[0].x+',' + polygon[0].y + ' C';
polygon.reduce(function(f,p){
arrow += p.x +',' +p.y+' ';
},0);
arrow += ' z';
//arrow += 'M200,200 L100,300 300,300 Z';
var ARROW_LIST = [{
'id' : '0591',
shape:'path',
style:{
'text' : 'ARROW',
'path' : arrow,
x : 0,
y : 0,
'textX' : 280,
'textY' : 340
},
draggable:true
}];
zr.addShape(ARROW_LIST[0]);
// 绘画
zr.render();
from echarts.
谢谢 明白了
from echarts.
有没有方法画不同颜色的、平行的(不是简单的平行,所有起始点在一条直线上,所有终点在一条直线上)带宽度的贝赛尔曲线 有没有思路 求指导
from echarts.
from echarts.
你现在不就是了吗?还是要下面这种效果?
我觉得这都只是数学问题,从贝塞尔曲线方程本身或许有思路
http://zh.wikipedia.org/zh-cn/%E8%B2%9D%E8%8C%B2%E6%9B%B2%E7%B7%9A
from echarts.
Related Issues (20)
- [Feature] 折线图series上的label支持和x轴一样的根据密度分布显示 HOT 2
- [Bug] Bar chart column width with a single data point is extremely wide. HOT 1
- [Bug] series.custom.label.textBorderColor设置任何值都不生效,但是textBorderWidth生效 HOT 2
- [Feature] effectScatter-hightEffect color HOT 2
- [Feature] Using the x-axis of the Line time type want to control the distance between two data points that are connected (i.e. not connecting data points beyond a certain time interval) HOT 7
- [Feature] Get the height and width of the rectangle when using series->type:treemap->label:formatter function HOT 4
- [Bug] 柱形图 个数少一个 和tooltip的数量不匹配 HOT 2
- [Bug] axisLabel width无效 HOT 3
- [Bug] Rendering performance issue HOT 4
- How to get the height of the bar in a bar chart or the width of the column in a column chart for the each individual data bar point in the label-formatter callback. HOT 3
- how to handle the separate events inside stacked area chart HOT 1
- Different colors of the series line on the Y-axis in different ranges of the X-axis HOT 1
- [Feature] 汇总表中自定义合计的算法 HOT 2
- [Feature] 在Echarts图标的表格/标题中添加上标/下标 HOT 3
- boxplot箱体超限 HOT 4
- [Bug] After upgrading to 5.5.0, the x-axis overlaps HOT 3
- 使用datazoom请求数据生成新图表后,新图表中无法使用reset按钮怎么办 HOT 1
- Multi data Area Chart HOT 1
- [Bug] dataset decals HOT 5
- [Bug] Using Candlestick's zoom in vue3 will generate an error and the zoom function cannot be used normally. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from echarts.