antvis / g2plot Goto Github PK
View Code? Open in Web Editor NEW:dango: An interactive and responsive charting library based on G2.
Home Page: https://g2plot.antv.antgroup.com
License: MIT License
:dango: An interactive and responsive charting library based on G2.
Home Page: https://g2plot.antv.antgroup.com
License: MIT License
饼图中间需要分割线
responsive 默认值需要设置为true
环形图默认值太瘦了,需要调优
复现配置项
it('创建饼图, 量级小, spider label', () => {
const canvasDiv = createCanvasDiv('canvasDiv1')
const pie = new Pie(canvasDiv, {
width: 600,
height: 600,
data: smallData,
label: {
visible: true,
type: 'spider',
style: {
// todo 自定义连线颜色
}
},
angleField: 'y',
colorField: 'x',
padding: [0, 0, 0, 0],
animation: false,
radius: 1,
title: {
text: '饼图 - spider label',
},
description: {
text: '1.label默认展示为“colorField value(上)angleField value(下,默认换行显示)”; \n2.[todo]label连线颜色设为灰色; \n3.[todo]label添加hover交互; \n',
},
legend: {
visible: false,
},
events: {
'label:mousemove': (...args) => {
console.info('fixme: spiderLabel 设置该事件的时候 会不生效');
},
}
});
pie.render();
});
document.getElementsByClassName('ring-guide-html')[0].innerHTML = htmlString;
当页面中有多个环图时,此时依靠 classname 取的环图的结点,有问题,交互会错乱。
可以使用你们的demo area-basic.html
进行 测试
添加
lable: {
visible: false
}
Although the names of chart types have many variations in Chinese, they do have uniform terminology in English. As a library based on chart taxonomy, the naming of chart types needs to be consistent with international conventions, otherwise it will be confusing to users.
For example:
ring
-> donut
(or doughnut, but donut is neater)stack XXX
-> stacked XXX
group XXX
-> grouped XXX
More resources to refer to:
responsive 打开,xAxis 配置为 dateTime 类型,但实际数据不是标准的时间格式,moment 解析不出来。
底层应该兼容下,默认为 cat 类型吧,再抛出 warning ?
此处创建的是一个 G2.View,但是命名上一直是一个plot,并且外部调用直接都是 xxxPlot.getLayer().plot
很容易造成误解(G2 view和plot概念不清)
是否可以在 Layer类提供一个getG2view的方法,利用方法名说明使用方式
主题配置legend为top-left的时候,bar 和area 的legend,在计算padding的时候 position是‘bottom-center’
目前的图层存在以下问题:
图表属性的title 以及description 还有坐标轴xAxis 和yAxis 的 title 都有这个问题
是否保证一个命名规则,规则大概为:
-
分割例如:
如果可以的话, 看到一个改一个,逐步改掉吧~
如果要禁用 tooltip,那么 g2plot 是
tooltip: {
visible: false
}
看看其他图表库:
tooltip: false
tooltip: false
为什么要在这种大家都觉得约定俗成的配置项上做创新?本身这个配置项就够长了,我写个禁用还要占个三行这是什么毛病
/** 获取数据标签的renderer实例 */
protected _getDataLabel(): Label | null {
const labelController = this._getElement().get('labelController');
return labelController.labelsContainer ? labelController.labelsContainer.get('labelsRenderer') : null;
}
// 获取标签点
private _getLabelItems(): TextType[] {
const labelsRenderer = this._getDataLabel();
const labelItems = labelsRenderer.get('items');
return labelItems;
}
如题,theme中的default只保存默认全局样式。水波图和仪表盘的样式注册迁回各自的包里吧
复现 测试用例,当labelType不为spider的时候,就生效了(主要原因还是spiderLabel的实现不是通过register的方式 导致的)
const canvasDiv = createCanvasDiv('canvasDiv1')
const pie = new Pie(canvasDiv, {
width: 600,
height: 600,
data: smallData,
label: {
visible: true,
type: 'spider',
style: {
// todo 自定义连线颜色
}
},
angleField: 'y',
colorField: 'x',
padding: [0, 0, 0, 0],
animation: false,
radius: 1,
title: {
text: '饼图 - spider label',
},
description: {
text: '1.label默认展示为“colorField value(上)angleField value(下,默认换行显示)”; \n2.[todo]label连线颜色设为灰色; \n3.[todo]label添加hover交互; \n',
},
legend: {
visible: false,
},
events: {
'label:mousemove': (...args) => {
console.info('todo: spiderLabel 设置该事件的时候 会不生效');
},
}
});
pie.render();
目前,配置label.textStyle
是不生效的,看了 g2的labelController
层,并没有使用用户配置labelOptions.textStyle, 是不打算 开放 label.textStyle
的配置吗?只能在 theme 中配置全局
label.textStyle
? 这么做的原因是什么? @paleface001
复现测试单例如下:
const pie = new Pie(canvasDiv, {
width: 600,
height: 600,
data: largeData,
label: {
visible: true,
type: 'custom-pie',
formatter: (text, item, index) => {
const origin = item._origin;
return `${origin['type']}\n\n${origin['value']}`;
},
// 🔥 此处的配置是无效的 🔥
textStyle: {
lineHeight: 16,
fill: 'red',
}
},
angleField: 'value',
colorField: 'type',
padding: [0, 0, 0, 0],
animation: false,
radius: 0.75,
innerRadius: 0.25,
title: {
text: '饼图 - custom pie label',
},
description: {
text: '1. 量级大,100条数据;',
},
legend: {
visible: false,
},
});
图表默认配置优化
https://yuque.antfin-inc.com/antv/g2-4/kclgfa
每一个图表的TS类型定义
使用TS改写默认的line-basic DEMO,会有TS类型错误
const cfg: LineConfig = {
padding: 'auto',
data: [{ x: 'a', y: 1 }, { x: 'b', y: 2 }],
xField: 'x',
yField: 'y',
};
const plot = new Line(document.getElementById('canvas'), cfg);
问题:
https://github.com/antvis/g2plot/blob/e507f2ed127cd9a0c164ba3c4f561ddded358ef0/src/base/Plot.ts#L201
这里获取的是 plotBBox,和plotRange含义可以一致?
range是否可以理解为一个object对象,而不是bbox对象?
https://github.com/antvis/g2plot/blob/master/demos/stackBar.html#L92
Stackar => StackBar
这边应该用 shapeData 里的数据
https://github.com/antvis/g2plot/blob/770b9f64d426da0fa7d520c2250714d2b8893ce6/src/plots/line/animation/clipInWithData.ts#L20
另 同一文件 96 行的 getPositionByRatio
方法可以用 g 里 path.getPoint(ratio)
替换。这样不管是折线还是 smooth 贝塞尔线条都是准的。
没有看到和G2Plot有关的任何文档,在哪里可以看到?
水滴图的 defaultColor 不是主题的defaultColor
柱状图,条形图,原color属性是用别的替代了,还是bug了。
color为一个颜色数组的时候全部显示第一个色值。
https://github.com/antvis/g2plot/blob/master/docs/advanced/stateAndChartsConnetion.zh-CN.md
2). 状态量的更新和更新事假的分发
应该为“
2). 状态量的更新和更新事件的分发
”
label type= spider的formatter 参数需要与ounter inner的保持一致
label formatter 需要饼图计算后的百分比数据
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.