Skip to content

Repository files navigation

G2Plot-Column

Plugin based on G2Plot v2.LIVE DEMO

Install

$ npm i --save g2plot-column

Usage

import{P}from'@antv/g2plot';import{defaultOptions,adaptor}from'../src';constdata=[{name: 'Internet Explorer',value: 26,symbol: 'https://gw.alipayobjects.com/zos/rmsportal/eOYRaLPOmkieVvjyjTzM.png'}{name: 'Chrome',value: 40,symbol: 'https://gw.alipayobjects.com/zos/rmsportal/dWJWRLWfpOEbwCyxmZwu.png'},{name: 'Firefox',value: 30,symbol: 'https://gw.alipayobjects.com/zos/rmsportal/ZEPeDluKmAoTioCABBTc.png'},{name: 'Safari',value: 24,symbol: 'https://gw.alipayobjects.com/zos/rmsportal/eZYhlLzqWLAYwOHQAXmc.png'},{name: 'Opera',value: 15,symbol: 'https://gw.alipayobjects.com/zos/rmsportal/vXiGOWCGZNKuVVpVYQAw.png'},{name: 'Undetectable',value: 8,symbol: 'https://gw.alipayobjects.com/zos/rmsportal/NjApYXminrnhBgOXyuaK.png'},];constoptions={
data,xField: 'name',yField: 'value',height: 600,curvature: 0.8,autoFit: true,symbolSize: [40,40],color:'red',shapeAttrs:{fill:'green',}//padding: 40, //发现顶部图标被挡住的时候 暂时可以设置一个padding解决};constcolumn=newP('app',options,adaptor,defaultOptions);column.render();// column.update({data}); // update chart 

Attributes

options

NameTypeDescription
dataArraydata source,example:[{xField},{yField},symbol,color,shapeAttrs]
xFieldstringx-axis field name in data
yFieldstringy-axis field name in data
heightnumberchart height
widthnumberchart width
autoFitBooleanfit width,default:false
curvaturenumbercurvature,ranges:0-1,default:0.8,curvature=0 is triangle
symbolSizeArraysymbol size,default:[30,30]
paddingArray | numberpadding,default:0
colorstringshape common color/fill
shapeAttrsobjectshape common shape attrs

options.data

NameTypeDescription
symbolstringimage path
colorstringcurrent shape color, priority is higher than common color
shapeAttrsobjectcurrent shape attrs,priority is higher than common shapeStyle

About

🤖 Customize the column chart of g2plot

Resources

Stars

9 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages