lineX
上一篇
line
下一篇
lineY
Loading...
lineX
和lineY
图形标记配置相似,lineX
图形标记用于绘制垂直于 x 轴的辅助线,常用于绘制平均值或其他聚合数据辅助线。
(() => {const chart = new G2.Chart();chart.options({type: "view",autoFit: true,height: 200,children: [{type: "rect",data: {type: "fetch",value: "https://assets.antv.antgroup.com/g2/unemployment2.json",},encode: { x: "rate" },transform: [{ type: "binX", y: "count" }],style: { inset: 0.5 },},{type: "lineX",data: [10.2],style: { stroke: "#000", strokeOpacity: 0.45, lineDash: [3, 4] },labels: [{text: "lineX text",position: "top-left",textBaseline: "bottom",fill: "#000",fillOpacity: 0.45,background: true,backgroundFill: "#000",backgroundOpacity: 0.15,},],},],});chart.render();return chart.getContainer();})();
更多的案例,可以查看图表示例 - 线标注页面。
配置 lineX
标记的视觉通道。
尝试一下:
属性 | 描述 | 类型 | 默认值 | 必选 |
---|---|---|---|---|
stroke | 图形的描边 | string | Function<string> | - | |
strokeOpacity | 描边透明度 | number | Function<number> | - | |
lineWidth | 图形描边的宽度 | number | Function<number> | - | |
lineDash | 描边的虚线配置,第一个值为虚线每个分段的长度,第二个值为分段间隔的距离。lineDash 设为[0, 0]的效果为没有描边。 | [number,number] | Function<[number, number]> | - | |
opacity | 图形的整体透明度 | number | Function<number> | - | |
shadowColor | 图形阴影颜色 | string | Function<string> | - | |
shadowBlur | 图形阴影的高斯模糊系数 | number | Function<number> | - | |
shadowOffsetX | 设置阴影距图形的水平距离 | number | Function<number> | - | |
shadowOffsetY | 设置阴影距图形的垂直距离 | number | Function<number> | - | |
cursor | 鼠标样式。同 css 的鼠标样式,默认 'default'。 | string | Function<string> | default |