0.0.8 • Published 6 years ago

nuke-biz-chart v0.0.8

Weekly downloads
38
License
-
Repository
gitlab
Last release
6 years ago

Chart

g2-mobile rax 版本封装

基本使用

import { Chart, Geom, Axis, Coord,Animate} from 'nuke-biz-chart';

//...
const data = [
    {"time": '周一',"tem": 10,"city": "beijing"},
    {"time": '周二',"tem": 22,"city": "beijing"},
    {"time": '周三',"tem": 20,"city": "beijing"},
    {"time": '周四',"tem": 26,"city": "beijing"},
    {"time": '周五',"tem": 20,"city": "beijing"},
    {"time": '周六',"tem": 26,"city": "beijing"},
    {"time": '周日',"tem": 28,"city": "beijing"},
    {"time": '周一',"tem": 5,"city": "newYork"},
    {"time": '周二',"tem": 12,"city": "newYork"},
    {"time": '周三',"tem": 26,"city": "newYork"},
    {"time": '周四',"tem": 20,"city": "newYork"},
    {"time": '周五',"tem": 28,"city": "newYork"},
    {"time": '周六',"tem": 26,"city": "newYork"},
    {"time": '周日',"tem": 20,"city": "newYork"}
];
const cols = {
    time: { alias: '时间' },
    tem: { alias: '温度' }
};
<Chart id="nuke-biz-chart-test2" data={data} width={750} height={350} cols={cols}>
    <Axis name="time" config={{label: {fontSize: 12}}} />
    <Axis name="tem" config={{label: {fontSize: 12}}} />
    <Geom type="line" position="time*tem" color="city" size={2}  shape="smooth" />
    <Animate type="waveh" config={{duration: 2000,easing: 'elastic'}} />
</Chart>

API

Chart 标签

属性配置说明类型默认值
id必传且同页面不重复string
width必传,宽number
height必传,高number
cols列别名obj

Axis 坐标轴

必须包裹在 <Chart>标签内,如果是直角坐标系,则需传 x、y 个

属性配置说明类型默认值
namex或y轴字段名string
config配置项,参考 g2 axisobject

Geom 图形

必须包裹在 <Chart>标签内

属性配置说明类型默认值
type图形类型,枚举值,'point', 'line', 'area', 'bar', 'pie', 'polygon', 'schema'string'bar'
positionx轴*y轴,参考 g2 geom positionstring
color颜色区分,参考 g2 geom colorstring
shape形状,随着type 不同,枚举值有不同,参考下方表格string
size大小设置,随着type 不同,含义不同,参考 g2 geom sizestring
style用于快速配置图形的样式。参数符合 canvas 图形属性,参考 g2 geom styleobject

ps: shape 取值受 Geom type 的影响

typeshape 类型解释
point'circle','rect'-
line'line','smooth','dash'dash :虚线,smooth: 平滑线
area'line','smooth'-

Coord 坐标系

必须包裹在 <Chart>标签内

用于设置直角坐标系还是极坐标系,直角坐标系可不用传。

属性配置说明类型默认值
type坐标系类型,枚举值,'rect' 直角坐标系, 'polar' 极坐标系string'rect'
config坐标系旋转配置,参考 g2 chart coordcfg
const pieData = [
    {a:'l',b: 5, label: '小朋友1'},
    {a:'l',b: 12, label: '小朋友2'},
    {a:'l',b: 3, label: '小朋友3'}
];
<Chart id="nuke-biz-chart-test5" data={pieData} width={450} height={450}>
    <Axis visible={false} />
    <Coord type="polar" config={{transposed: true,inner:0.6}} />
    <Geom type="pie" position="a*b" color="label" />
</Chart>

Animate 绘制动画

必须包裹在 <Chart>标签内

属性配置说明类型默认值
type坐标系类型,枚举值,'waveh','wavec','scalex','scaley','scalexy'string
config动画参数配置,参考 g2 chart animatecfg
<Animate type="waveh" config={{duration: 2000,easing: 'elastic'}} />
0.0.8

6 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago