├── .babelrc ├── .eslintignore ├── .eslintrc.js ├── .fatherrc.js ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── .prettierrc.js ├── .storybook ├── .eslintrc ├── main.js ├── preview.js └── webpack.config.js ├── CHANGELOG.md ├── README.md ├── SECURITY.md ├── __stories__ ├── area.stories.tsx ├── base.stories.tsx ├── box.stories.tsx ├── bugs.stories.tsx ├── candle.stories.tsx ├── dashboard.stories.tsx ├── feature.stories.tsx ├── funnel.stories.tsx ├── g.stories.tsx ├── geometry.stories.tsx ├── heatMap.stories.tsx ├── interval.stories.tsx ├── line.stories.tsx ├── path.stories.tsx ├── pie.stories.tsx ├── plot.stories.tsx ├── plots │ └── area.stories.tsx ├── point.stories.tsx ├── radar.stories.tsx ├── temp.stories.tsx └── theme.stories.tsx ├── demos ├── adepter │ ├── coord.jsx │ └── geom-label.jsx ├── area │ ├── areaWithNull.jsx │ ├── basicArea.jsx │ ├── basicAreaWithNegativeValues.jsx │ ├── colorBlock.jsx │ ├── intervalArea.jsx │ ├── percentStackingArea.jsx │ └── stackingArea.jsx ├── box │ └── basicBox.jsx ├── bugs │ ├── plot-bar.jsx │ └── view-changeData.jsx ├── candle │ ├── data.js │ └── stock.jsx ├── components │ ├── annotation-text.js │ ├── annotation.jsx │ ├── autoFit.jsx │ ├── axis.jsx │ ├── coordinate.jsx │ ├── facet.jsx │ └── view.jsx ├── dashboard │ └── basicDashboard.jsx ├── external │ └── index.html ├── features │ ├── JsxTooltip.jsx │ ├── changeData.jsx │ ├── chartManager.jsx │ ├── effects.jsx │ ├── facet.jsx │ ├── fiber-reconciler.jsx │ ├── filter.jsx │ ├── interaction.jsx │ ├── pure.jsx │ ├── resize.jsx │ ├── selected.jsx │ ├── slider.jsx │ ├── tooltip-linkage.jsx │ └── transform.jsx ├── funnel │ └── basicFunnel.jsx ├── g-components │ └── basic.tsx ├── geom │ ├── LineAdvance.jsx │ ├── area.jsx │ ├── interval-group.jsx │ ├── interval.jsx │ ├── line.jsx │ └── path.jsx ├── heatMap │ ├── calendar.jsx │ └── heatMap.jsx ├── interval │ ├── basicBar.tsx │ ├── basicColumn.jsx │ ├── bezier.jsx │ ├── colorGroupedStackedColumns.jsx │ ├── comparedBar.jsx │ ├── gradientBar.jsx │ ├── groupedBar.jsx │ ├── groupedColumns.jsx │ ├── groupedStackedColumns.jsx │ ├── histogram.jsx │ ├── intervalColumn.jsx │ ├── percentStackedColumn.jsx │ ├── polarCoordinate.jsx │ ├── roundedColumn.jsx │ ├── stackedBars.jsx │ └── stackedColumn.jsx ├── line │ ├── gradientPolyline.jsx │ ├── ordinaryCurve.jsx │ ├── ordinaryPolyline.jsx │ └── stepPolyline.jsx ├── pie │ ├── RoseChart-limitedAngleRange.jsx │ ├── basicPie.jsx │ ├── multicolorNightingaleRoseillustration.jsx │ ├── nestedPie.jsx │ ├── nightingaleRoseIllustration.jsx │ ├── nightingaleRosette.jsx │ └── visualizationOfDailyWork.jsx ├── plot │ ├── gauge.jsx │ ├── line.jsx │ ├── plots.jsx │ └── ring.jsx ├── point │ ├── basicPoint.jsx │ ├── bubble.jsx │ └── multiShapeScatter.jsx ├── radar │ └── radar.jsx └── theme │ └── index.jsx ├── docs ├── BizCharts │ ├── API文档 │ │ ├── Axis.md │ │ ├── BizCharts 概览.md │ │ ├── Chart.md │ │ ├── Connector.md │ │ ├── Coord.md │ │ ├── DataSet.md │ │ ├── Facet.md │ │ ├── Geom.md │ │ ├── Guide.md │ │ ├── Label.md │ │ ├── Legend.md │ │ ├── Scale.md │ │ ├── Slider.md │ │ ├── Theme.md │ │ ├── Tooltip.md │ │ ├── Transform.md │ │ ├── View.md │ │ ├── canvas 属性.md │ │ ├── data.json │ │ ├── 图表事件.md │ │ └── 自定义 Shape.md │ ├── Demo │ │ ├── 2015 年波士顿每天的平均温度可视化.md │ │ ├── 2维行列分面.md │ │ ├── BizCharts 使用 onLegendItemClick 管理 legend 状态.md │ │ ├── BizCharts 导出图片.md │ │ ├── BizCharts-基础饼图.md │ │ ├── BizCharts@3.x Demo.md │ │ ├── BizCharts分组条形图.md │ │ ├── BizCharts分组柱状图.md │ │ ├── BizCharts基础条形图.md │ │ ├── BizCharts基础漏斗图(各层总和100%).md │ │ ├── BizCharts基础漏斗图(最上层100%).md │ │ ├── BizCharts基础面积图.md │ │ ├── BizCharts堆叠条形图.md │ │ ├── BizCharts堆叠柱状图.md │ │ ├── BizCharts堆叠柱状图使用 Label 显示当前总数.md │ │ ├── BizCharts堆叠面积图.md │ │ ├── BizCharts散点图.md │ │ ├── BizCharts百分比堆叠柱状图.md │ │ ├── BizCharts自定义柱状图.md │ │ ├── BizCharts饼图-分割空白.md │ │ ├── Circle Packing.md │ │ ├── Guide-DataMarker.md │ │ ├── Guide-html.md │ │ ├── Guide-region.md │ │ ├── Guide.Html.md │ │ ├── Guide均值线与图例联动.md │ │ ├── Invalid Date in fecha.format.md │ │ ├── Invalid Time: 20200229.md │ │ ├── Kagi Chart.md │ │ ├── Pizza Chart.md │ │ ├── Polar Heatmap.md │ │ ├── Punch Card.md │ │ ├── Radial Bar Chart.md │ │ ├── Wind Rose.md │ │ ├── bizcharts-plugin-slider.md │ │ ├── bizcharts分面柱图.md │ │ ├── color映射多字段,通过*连接.md │ │ ├── diverging 正负对比条形图.md │ │ ├── g2-brush 多边形.md │ │ ├── g2-brush 折线图.md │ │ ├── g2-brush 柱状图.md │ │ ├── g2-brush 结合 DataSet.md │ │ ├── g2-brush 过滤图形.md │ │ ├── g2-brush 高亮图形.md │ │ ├── interval-onplotclick.md │ │ ├── legend-custom.md │ │ ├── legend-position.md │ │ ├── list分面.md │ │ ├── onAxisLabelClick.md │ │ ├── streamgraph.md │ │ ├── tree 分面.md │ │ ├── voronoi图.md │ │ ├── 一维箱形图.md │ │ ├── 个性化 legend.md │ │ ├── 个性化 tooltip.md │ │ ├── 个性化标签饼图.md │ │ ├── 仪表盘.md │ │ ├── 仪表盘(多色).md │ │ ├── 仪表盘(文字).md │ │ ├── 使用html语法显示图表标题.md │ │ ├── 元素周期表.md │ │ ├── 六边形分箱.md │ │ ├── 六边形大小分箱图.md │ │ ├── 分块热力图.md │ │ ├── 分片饼图.md │ │ ├── 分组层叠柱状图.md │ │ ├── 分组箱形图.md │ │ ├── 分面条形图.md │ │ ├── 列分面.md │ │ ├── 刻度仪表盘.md │ │ ├── 北京市2010至2015年空气质量指数.md │ │ ├── 区域图(存在空值).md │ │ ├── 区域着色1.md │ │ ├── 区域着色2.md │ │ ├── 区间条形图.md │ │ ├── 区间柱状图.md │ │ ├── 区间面积图.md │ │ ├── 华夫图.md │ │ ├── 单元测试覆盖率可视化.md │ │ ├── 单色南丁格尔玫瑰图.md │ │ ├── 南丁格尔玫瑰图.md │ │ ├── 南丁格尔玫瑰彩图.md │ │ ├── 南丁格尔玫瑰环图.md │ │ ├── 双环图.md │ │ ├── 双轴图表.md │ │ ├── 双轴图隐藏Y轴.md │ │ ├── 双轴并列柱图.md │ │ ├── 和弦图.md │ │ ├── 回归曲线.md │ │ ├── 图例位置.md │ │ ├── 图例默认选中.md │ │ ├── 图片华夫图.md │ │ ├── 圆头折线图.md │ │ ├── 圆形分面.md │ │ ├── 圆角堆叠柱状图.md │ │ ├── 圆角柱状图.md │ │ ├── 圆角矩形.md │ │ ├── 地平线图.md │ │ ├── 基础BizCharts饼图.md │ │ ├── 基础柱状图.md │ │ ├── 基础环图.md │ │ ├── 基础箱形图.md │ │ ├── 基础箱形图(有异常值).md │ │ ├── 基础雷达图.md │ │ ├── 基础雷达图(线).md │ │ ├── 基础面积图(有负值).md │ │ ├── 基础饼图-内部文本.md │ │ ├── 堆叠柱状图Label展示.md │ │ ├── 多层面积图.md │ │ ├── 多层饼图.md │ │ ├── 多形状散点图.md │ │ ├── 多条折线图(增加趋势预测).md │ │ ├── 多条阶梯折线图.md │ │ ├── 多环图.md │ │ ├── 多级 tree 分面.md │ │ ├── 多色散点图.md │ │ ├── 大规模区域图.md │ │ ├── 子弹图.md │ │ ├── 实时更新数据的折线图.md │ │ ├── 对比漏斗图.md │ │ ├── 对称漏斗图.md │ │ ├── 尖底漏斗图.md │ │ ├── 尾部跟随图例.md │ │ ├── 层叠直方图.md │ │ ├── 带文本的气泡图.md │ │ ├── 带有label的条形图.md │ │ ├── 带有slider的柱状图.md │ │ ├── 带有坐标轴的南丁格尔玫瑰图.md │ │ ├── 带标识的柱状图.md │ │ ├── 带虚线部分的折线图.md │ │ ├── 弧长链接图.md │ │ ├── 径向系统树图.md │ │ ├── 径向紧凑树图.md │ │ ├── 扰动点图.md │ │ ├── 折线图特定区域变色.md │ │ ├── 日历色块图.md │ │ ├── 日常作息可视化.md │ │ ├── 旭日图.md │ │ ├── 时间序列气泡图.md │ │ ├── 普通折线图.md │ │ ├── 普通折线图(曲线).md │ │ ├── 普通折线图(渐变色).md │ │ ├── 极坐标 voronoi 图.md │ │ ├── 极坐标下的层叠柱状图.md │ │ ├── 极坐标弧长链接图.md │ │ ├── 极坐标相邻关系图.md │ │ ├── 极坐标系下箱形图.md │ │ ├── 柱状图 Region覆盖.md │ │ ├── 柱状图带更新动效.md │ │ ├── 柱状图饼图联动.md │ │ ├── 柱线混合图.md │ │ ├── 核函数概率密度分布.md │ │ ├── 核函数概率密度回归曲线.md │ │ ├── 核函数概率密度回归曲线(两字段).md │ │ ├── 桑基图布局.md │ │ ├── 气泡图-自定义 shape.md │ │ ├── 气泡图.md │ │ ├── 水平日历色块图.md │ │ ├── 水波图 - 自定义圆形路径.md │ │ ├── 水波图 - 自定义路径.md │ │ ├── 水波图.md │ │ ├── 渐变折线图.md │ │ ├── 渐变条形图带label.md │ │ ├── 渐变色面积图.md │ │ ├── 滑动图例的大小.md │ │ ├── 瀑布图.md │ │ ├── 热力图.md │ │ ├── 热力图动态更新.md │ │ ├── 特殊数据点标注和特殊数据区间标注.md │ │ ├── 玉珏图.md │ │ ├── 玫瑰图-限定角度范围.md │ │ ├── 玫瑰图镜像分面.md │ │ ├── 甘特图.md │ │ ├── 生态树布局.md │ │ ├── 百分比堆叠面积图.md │ │ ├── 直方图.md │ │ ├── 相邻层次图.md │ │ ├── 矩形分箱图.md │ │ ├── 矩形大小分箱图.md │ │ ├── 矩形树图.md │ │ ├── 矩阵分面.md │ │ ├── 符号华夫图.md │ │ ├── 紧凑树布局.md │ │ ├── 缩进树布局.md │ │ ├── 股票图.md │ │ ├── 股票图与范围区域图.md │ │ ├── 自定义 tooltip 为表格.md │ │ ├── 自定义tooltip样式.md │ │ ├── 自定义柱状图.md │ │ ├── 色块图.md │ │ ├── 范围区域图与线图.md │ │ ├── 螺旋坐标系.md │ │ ├── 行分面.md │ │ ├── 访问地区分布图 AreaMap.md │ │ ├── 词云.md │ │ ├── 负值X轴对齐.md │ │ ├── 路径图.md │ │ ├── 镜像分面(转置).md │ │ ├── 镜像分面.md │ │ ├── 阶梯折线图.md │ │ ├── 雨量流量关系图.md │ │ ├── 雨量流量对比.md │ │ ├── 雷达图 圆圈底纹.md │ │ ├── 雷达图复杂曲线.md │ │ ├── 韦恩图.md │ │ ├── 饼图-三角.md │ │ ├── 饼图-分割空白.md │ │ ├── 饼图-半径大小.md │ │ ├── 饼图-柱状图.md │ │ ├── 饼图-花瓣图.md │ │ ├── 饼图-限定角度范围.md │ │ ├── 饼图选中联动.md │ │ ├── 饼图默认选中.md │ │ └── 高度自适应.md │ ├── 使用指南 │ │ ├── DataSet Package.md │ │ ├── G2 的数据处理流程.md │ │ ├── data.json │ │ ├── 主题.md │ │ ├── 几何标记和数据调整.md │ │ ├── 图表交互.md │ │ ├── 图表构成.md │ │ ├── 图表类型.md │ │ ├── 如何自定义动画.md │ │ ├── 快速入门.md │ │ ├── 按需加载.md │ │ ├── 源数据的处理.md │ │ ├── 答疑Issue复现教程.md │ │ ├── 闰年日期0229异常处理.md │ │ └── 高定制Tooltip插件.md │ └── 实战 │ │ ├── BizCharts 3.x_G2 格式化指南.md │ │ └── data.json ├── BizCharts@4.x │ ├── API文档 │ │ ├── G组件 │ │ │ ├── Canvas.md │ │ │ ├── Circle.md │ │ │ ├── Ellipse.md │ │ │ ├── Group.md │ │ │ ├── Image.md │ │ │ ├── Line.md │ │ │ ├── Marker.md │ │ │ ├── Path.md │ │ │ ├── Polygon.md │ │ │ ├── Polyline.md │ │ │ ├── Rect.md │ │ │ ├── Text.md │ │ │ └── 通用属性.md │ │ ├── 图形组件 │ │ │ ├── Area.md │ │ │ ├── Edge.md │ │ │ ├── Geom 通用图形组件.md │ │ │ ├── Heatmap.md │ │ │ ├── Interval.md │ │ │ ├── Line.md │ │ │ ├── LineAdvance.md │ │ │ ├── Path.md │ │ │ ├── Point.md │ │ │ ├── Polygon.md │ │ │ └── Schema.md │ │ ├── 基础组件 │ │ │ ├── Annotation.md │ │ │ ├── Axis.md │ │ │ ├── Chart.md │ │ │ ├── Coordinate.md │ │ │ ├── Facet.md │ │ │ ├── Interaction.md │ │ │ ├── Legend.md │ │ │ ├── Slider.md │ │ │ ├── Tooltip.md │ │ │ └── View.md │ │ └── 扩展组件&Hooks │ │ │ ├── Effects.md │ │ │ ├── useChartInstance.md │ │ │ └── useView.md │ ├── Demo │ │ ├── 自定义Legend的使用.md │ │ ├── 3D效果柱状图(Interval).md │ │ ├── Annotation.DataMarker Annotation.DataRegion.md │ │ ├── Annotation.Html替代axis label.md │ │ ├── Annotation.Region Demo.md │ │ ├── Annotation.Text(BizCharts@4).md │ │ ├── Annotation显示隐藏.md │ │ ├── Axis label 旋转.md │ │ ├── BizCharts分组条形图(BizCharts@4).md │ │ ├── Facet 登录注册成功率分面图(BizCharts@4.x).md │ │ ├── Facet使用Demo(BizCharts@4.x).md │ │ ├── Guide均值线与图例联动(BizCharts@4).md │ │ ├── Interaction使用Demo(BizCharts@4.x).md │ │ ├── Invalid Time: 20200229(BizCharts@4).md │ │ ├── KPI进度图.md │ │ ├── PieChart使用Demo.md │ │ ├── Style样式配置.md │ │ ├── Tooltip允许鼠标移入+activeRegion (要点击一下图表,具体看代码注释).md │ │ ├── X轴可拖拽的点图.md │ │ ├── color映射多字段,分组堆叠柱状图(BizCharts@4).md │ │ ├── diverging 正负对比图(BizCharts@4).md │ │ ├── geom style回调.md │ │ ├── label颜色自定义(BizCharts@4).md │ │ ├── onAxisLabelClick label.md │ │ ├── tab切换 Annotation.md │ │ ├── tooltip formatter数据格式化.md │ │ ├── tree分面(BizCharts@4).md │ │ ├── 一维箱形图(BizCharts@4).md │ │ ├── 两组分组柱状图(BizCharts@4).md │ │ ├── 使用filter实现默认隐藏某图例下的数据.md │ │ ├── 使用memo实现更改图表无关状态时图表不刷新.md │ │ ├── 修复Invalid Date in fecha.format.md │ │ ├── 内置预设的折线图形LineAdvance.md │ │ ├── 分组堆叠柱状图(BizCharts@4).md │ │ ├── 分组条形图(BizCharts@4).md │ │ ├── 分组柱多折线混合图.md │ │ ├── 分组柱状图 数值量级差异过大 type=log.md │ │ ├── 分组柱状图(BizCharts@4).md │ │ ├── 分组柱状图数值为null时居中展示.md │ │ ├── 分组柱状图(adjust).md │ │ ├── 分组柱线混合图.md │ │ ├── 分组滚动柱状图(BizCharts@4).md │ │ ├── 分面条形图(BizCharts@4).md │ │ ├── 区间条形图(BizCharts@4).md │ │ ├── 区间柱状图(BizCharts@4).md │ │ ├── 区间面积图(BizCharts@4).md │ │ ├── 南丁格尔玫瑰图(BizCharts@4).md │ │ ├── 南丁格尔玫瑰环图(BizCharts@4).md │ │ ├── 双Y轴、Axis Tooltip format.md │ │ ├── 双轴折柱混合图表(BizCharts@4).md │ │ ├── 可缩放的散点图.md │ │ ├── 图例单选.md │ │ ├── 图表标题(BizChart@4).md │ │ ├── 圆形分面(BizCharts@4).md │ │ ├── 圆角柱状图(BizCharts@4).md │ │ ├── 在表格中使用.md │ │ ├── 坐标轴显示首尾刻度点.md │ │ ├── 坐标轴标题(BizCharts@4).md │ │ ├── 基础仪表盘(BizCharts@4).md │ │ ├── 基础图表全局主题配置.md │ │ ├── 基础散点图(BizCharts@4).md │ │ ├── 基础条形图(BizCharts@4).md │ │ ├── 基础柱状图(BizCharts@4).md │ │ ├── 基础柱状图(Interval).md │ │ ├── 基础漏斗图(BizCharts@4).md │ │ ├── 基础点图(Point).md │ │ ├── 基础箱型图(BizCharts@4).md │ │ ├── 基础面积图(BizCharts@4).md │ │ ├── 基础面积图(Area).md │ │ ├── 基础饼图(BizCharts@4).md │ │ ├── 堆叠条形图(BizCharts@4).md │ │ ├── 堆叠柱状图(BizCharts@4).md │ │ ├── 堆叠柱状图:label自动隐藏.md │ │ ├── 堆叠柱状图排序(BizCharts@4).md │ │ ├── 堆叠面积图(BizCharts@4).md │ │ ├── 多view slider(BizCharts@4.x).md │ │ ├── 多层饼图(BizCharts@4.0).md │ │ ├── 多形状散点图(BizCharts@4).md │ │ ├── 多条阶梯折线图(BizCharts@4).md │ │ ├── 多段区间条形图(BizCharts@4).md │ │ ├── 多级 tree 分面(BizCharts@4).md │ │ ├── 多色南丁格尔玫瑰图(BizCharts@4).md │ │ ├── 多色折线图(BizCharts@4).md │ │ ├── 多色虚实折线图(BizCharts@4).md │ │ ├── 存在空值的面积图(BizCharts@4).md │ │ ├── 实时更新折线图(BizCharts@4.x).md │ │ ├── 对比漏斗图(bizCharts@4).md │ │ ├── 尖底漏斗图(BizCharts@4).md │ │ ├── 嵌套饼图(BizCharts@4).md │ │ ├── 带有label的条形图(BizCharts@4).md │ │ ├── 平滑虚线折线图.md │ │ ├── 平行柱 控制 间距.md │ │ ├── 弧形链接图(BizCharts@4).md │ │ ├── 弧形链接线(Edge).md │ │ ├── 折线-水位图(辅助线).md │ │ ├── 折线图特定区域变色(BizCharts@4).md │ │ ├── 控制透明色.md │ │ ├── 散点图+趋势线(BizCharts@4).md │ │ ├── 数据全部为零时显示Y轴.md │ │ ├── 日历色块图(BizCharts@4).md │ │ ├── 日常作息可视化(BizCharts@4).md │ │ ├── 旭日图(BizCharts@4).md │ │ ├── 普通折线图(BizCharts@4).md │ │ ├── 有负值的基础面积图(BizCharts@4).md │ │ ├── 极坐标下的柱状图(Coordinate).md │ │ ├── 极坐标分组柱状图(BizCharts@4).md │ │ ├── 极简Demo.md │ │ ├── 极简环图(BizCharts@4).md │ │ ├── 柱状图 color label callback自定义配置.md │ │ ├── 柱状图背景常亮.md │ │ ├── 柱状图鼠标hover样式.md │ │ ├── 框选高亮散点图(BizCharts@4).md │ │ ├── 桑基图布局(BizCharts@4).md │ │ ├── 气泡图(BizCharts@4).md │ │ ├── 气泡散点图.md │ │ ├── 水波图(BizCharts@4.x).md │ │ ├── 渐变条形图带label(BizCharts@4).md │ │ ├── 渐变网格折线图 LineAdvance.md │ │ ├── 渐变色折线图(BizCharts@4).md │ │ ├── 渐变色配置示范.md │ │ ├── 热力图(BizCharts@4).md │ │ ├── 热力图(Heatmap).md │ │ ├── 父容器transform scale导致tooltip位置错误.md │ │ ├── 玫瑰图-限定角度范围(BizCharts@4).md │ │ ├── 环图 pieStyle 样式问题.md │ │ ├── 环形盘(BizCharts@4).md │ │ ├── 百分比堆叠柱状图(BizCharts@4).md │ │ ├── 百分比堆叠面积图(BizCharts@4).md │ │ ├── 直方图(BizCharts@4).md │ │ ├── 矩形树图(BizCharts@4).md │ │ ├── 禁止lable自动隐藏和旋转.md │ │ ├── 箱形图(Schema).md │ │ ├── 缩略轴使用demo.md │ │ ├── 股票图与范围区域图(BizCharts@4).md │ │ ├── 股票图于柱状图(BizCharts@4).md │ │ ├── 自定义 tooltip 为表格(BizCharts@4).md │ │ ├── 自定义active-region背景色.md │ │ ├── 自定义tooltip样式_Legend Marker(BizCharts@4).md │ │ ├── 自定义主题(bizcharts@4.x).md │ │ ├── 自定义图例(BizCharts@4).md │ │ ├── 自定义图形交互 registerInteraction.md │ │ ├── 自定义柱状图hover背景色.md │ │ ├── 自定义柱状图(BizCharts@4).md │ │ ├── 色块图(BizCharts@4).md │ │ ├── 色块图(Polygon).md │ │ ├── 词云(BizCharts@4.x).md │ │ ├── 财年累计返利趋势变化.md │ │ ├── 路径动画(Path).md │ │ ├── 选中样式设置(BizCharts@4).md │ │ ├── 阶梯折线图(BizCharts@4).md │ │ ├── 雷达图 Axis配置与 Tooltip开启crosshairs.md │ │ ├── 雷达图 圆圈底纹(Bizcharts@4).md │ │ ├── 雷达图(BizCharts@4).md │ │ ├── 雷达图(Line组件).md │ │ ├── 雷达图-图片标注(BizCharts@4).md │ │ ├── 雷达图复杂曲线(BizCharts@4).md │ │ ├── 非对称漏斗图(BizCharts@4).md │ │ ├── 饼图-分割图(Bizcharts@4).md │ │ ├── 饼图默认选中(@BizCharts 4.x).md │ │ ├── 饼图(theta).md │ │ └── 默认选中-基础条形图(BizCharts@4).md │ ├── Plots │ │ ├── plot 升级指南 │ │ │ └── 4.1 Plots 升级文档.md │ │ ├── 图表 │ │ │ ├── AreaChart.md │ │ │ ├── BarChart.md │ │ │ ├── BulletChart.md │ │ │ ├── CalendarChart.md │ │ │ ├── ColumnChart.md │ │ │ ├── DensityHeatmapChart.md │ │ │ ├── DonutChart.md │ │ │ ├── FunnelChart.md │ │ │ ├── GaugeChart.md │ │ │ ├── GroupedBarChart.md │ │ │ ├── GroupedColumnChart.md │ │ │ ├── GroupedRoseChart.md │ │ │ ├── HeatmapChart.md │ │ │ ├── HistogramChart.md │ │ │ ├── LineChart.md │ │ │ ├── LiquidChart.md │ │ │ ├── PieChart.md │ │ │ ├── RadarChart.md │ │ │ ├── RangeBarChart.md │ │ │ ├── RangeColumnChart.md │ │ │ ├── RoseChart.md │ │ │ ├── ScatterChart.md │ │ │ ├── StackedAreaChart.md │ │ │ ├── StackedBarChart.md │ │ │ ├── StackedColumnChart.md │ │ │ ├── StackedRoseChart.md │ │ │ ├── StepLineChart.md │ │ │ ├── TreemapChart.md │ │ │ ├── WaterfallChart.md │ │ │ └── WordCloudChart.md │ │ └── 迷你图表 │ │ │ ├── ProgressChart.md │ │ │ ├── TinyAreaChart.md │ │ │ └── TinyLineChart.md │ └── 使用指南 │ │ ├── data.json │ │ ├── 基础教程 │ │ ├── BizCharts 4.0 升级.md │ │ ├── GComponent的使用介绍.md │ │ ├── 图表事件使用.md │ │ ├── 快速开始.md │ │ └── 数据格式化和重命名.md │ │ └── 开发者教程 │ │ ├── DataSet Api.md │ │ ├── DataSet Transform.md │ │ ├── Label属性及自定义label.md │ │ ├── 使用DataSet.md │ │ ├── 绘图属性Style.md │ │ ├── 自定义主题.md │ │ ├── 自定义图形.md │ │ └── 配置动画.md ├── BizGoblin │ ├── API文档 │ │ ├── Axis.md │ │ ├── Chart.md │ │ ├── Coord.md │ │ ├── Geom.md │ │ ├── Guide.md │ │ ├── Legend.md │ │ └── Tooltip.md │ ├── Demo │ │ ├── BizGoblin折线图.md │ │ ├── bizGoblin多折线图.md │ │ ├── bizgoblin分组柱状图.md │ │ ├── bizgoblin区域图(存在空值).md │ │ ├── bizgoblin区间柱状图.md │ │ ├── bizgoblin圆弧柱状图.md │ │ ├── bizgoblin基础条形图.md │ │ ├── bizgoblin基础柱状图.md │ │ ├── bizgoblin基础面积图.md │ │ ├── bizgoblin基础饼图.md │ │ ├── bizgoblin层叠柱状图.md │ │ ├── bizgoblin层叠面积图.md │ │ ├── bizgoblin带负值面积图.md │ │ ├── bizgoblin散点图.md │ │ ├── bizgoblin玫瑰图.md │ │ ├── bizgoblin百分比层叠柱状图.md │ │ ├── bizgoblin百分比层叠面积图.md │ │ ├── bizgoblin雷达图.md │ │ ├── bizgolin气泡图.md │ │ └── 自定义图例.md │ └── 使用指南 │ │ ├── 图表介绍.md │ │ ├── 常见问题.md │ │ └── 快速入门.md ├── category_list.json └── 常见问题 │ └── faq.md ├── gulpfile.js ├── manifest.json ├── package.json ├── src ├── adapter │ ├── Guide.tsx │ └── paddingCheck.ts ├── animations.ts ├── boundary │ ├── ErrorBoundary.tsx │ └── withContainer.tsx ├── components │ ├── Annotation │ │ ├── arc.tsx │ │ ├── base.tsx │ │ ├── dataMarker.tsx │ │ ├── dataRegion.tsx │ │ ├── html.tsx │ │ ├── image.tsx │ │ ├── index.tsx │ │ ├── line.tsx │ │ ├── reactElement │ │ │ ├── component.ts │ │ │ └── index.tsx │ │ ├── region.tsx │ │ ├── regionFilter.tsx │ │ └── text.tsx │ ├── Axis │ │ └── index.tsx │ ├── Chart │ │ ├── chartHelper.ts │ │ ├── events.ts │ │ └── index.tsx │ ├── Coordinate │ │ ├── coord.tsx │ │ └── index.tsx │ ├── Effects │ │ └── index.tsx │ ├── Facet │ │ └── index.tsx │ ├── Interaction │ │ ├── brush.tsx │ │ └── index.tsx │ ├── Legend │ │ ├── actions.ts │ │ └── index.tsx │ ├── Slider │ │ └── index.tsx │ ├── Tooltip │ │ ├── ReactTooltip.tsx │ │ ├── actions.ts │ │ ├── index.scss │ │ ├── index.tsx │ │ └── inner.tsx │ └── View │ │ ├── index.tsx │ │ └── viewHelper.ts ├── connector │ └── createTooltipConnector.ts ├── context │ ├── canvas.tsx │ ├── group.tsx │ ├── root.tsx │ └── view.tsx ├── core.ts ├── createPlot.tsx ├── extend │ └── scale │ │ ├── linear-tick.ts │ │ └── scale.ts ├── g-components │ ├── Base │ │ ├── Helper.ts │ │ ├── events.ts │ │ └── index.tsx │ ├── Canvas.tsx │ ├── Circle.tsx │ ├── Ellipse.tsx │ ├── Group.tsx │ ├── Image.tsx │ ├── Line.tsx │ ├── Marker.tsx │ ├── Path.tsx │ ├── Polygon.tsx │ ├── Polyline.tsx │ ├── Rect.tsx │ ├── Text.tsx │ ├── index.ts │ └── reconciler │ │ └── index.tsx ├── g2-all.ts ├── geometry │ ├── Area.tsx │ ├── Base.tsx │ ├── Edge.tsx │ ├── Heatmap.tsx │ ├── Interval.tsx │ ├── Label.tsx │ ├── Line.tsx │ ├── LineAdvance.tsx │ ├── Path.tsx │ ├── Point.tsx │ ├── Polygon.tsx │ ├── Schema.tsx │ ├── actions.ts │ └── index.tsx ├── global.d.ts ├── hooks │ ├── useChartInstance.tsx │ ├── useChartView.tsx │ └── useTheme.ts ├── index.tsx ├── interface.ts ├── plots │ ├── AreaChart.tsx │ ├── BarChart.tsx │ ├── BubbleChart.tsx │ ├── BulletChart.tsx │ ├── CalendarChart.tsx │ ├── ColumnChart.tsx │ ├── DensityHeatmapChart.tsx │ ├── DonutChart.tsx │ ├── DualAxesChart.tsx │ ├── FunnelChart.tsx │ ├── GaugeChart.tsx │ ├── GroupedBarChart.tsx │ ├── GroupedColumnChart.tsx │ ├── GroupedRoseChart.tsx │ ├── HeatmapChart.tsx │ ├── HistogramChart.tsx │ ├── LineChart.tsx │ ├── LiquidChart.tsx │ ├── PercentStackedAreaChart.tsx │ ├── PercentStackedBarChart.tsx │ ├── PercentStackedColumnChart.tsx │ ├── PieChart.tsx │ ├── PlotAdapter.tsx │ ├── ProgressChart.tsx │ ├── RadarChart.tsx │ ├── RangeBarChart.tsx │ ├── RangeColumnChart.tsx │ ├── RingProgressChart.tsx │ ├── RoseChart.tsx │ ├── ScatterChart.tsx │ ├── StackedAreaChart.tsx │ ├── StackedBarChart.tsx │ ├── StackedColumnChart.tsx │ ├── StackedRoseChart.tsx │ ├── StepLineChart.tsx │ ├── TinyAreaChart.tsx │ ├── TinyColumnChart.tsx │ ├── TinyLineChart.tsx │ ├── TreemapChart.tsx │ ├── WaterfallChart.tsx │ ├── WordCloudChart.tsx │ ├── core │ │ ├── dependents.ts │ │ ├── interface.ts │ │ └── polyfill.ts │ ├── index.tsx │ ├── plots.tsx │ └── sparkline.tsx ├── theme │ └── index.tsx └── utils │ ├── cloneDeep.ts │ ├── compareProps.ts │ ├── constant.ts │ ├── data-transform │ ├── fold.ts │ ├── minifyNum.ts │ ├── partition.ts │ ├── percentage.ts │ ├── simple-sort-by.ts │ ├── splitBySeparator.ts │ └── sum.ts │ ├── getElementSize.ts │ ├── index.ts │ ├── isEqual.ts │ ├── pickWithout.ts │ ├── plotTools.ts │ ├── shallowEqual.ts │ ├── tranPropsToArray.ts │ └── transBooleanCfg.ts ├── tsconfig.json ├── uitest ├── create.js ├── index.js └── snapshot │ ├── Gemo-line.test.json │ ├── area-areaWithNull 测试.test.json │ ├── area-stackingArea 测试.test.json │ ├── feature-g2Funciton 测试.test.json │ ├── feature-pure 测试.test.json │ ├── geometry-interval 测试.test.json │ └── geometry-line 测试.test.json ├── unittest ├── annotation │ ├── base-spec.tsx │ └── react-spec.tsx ├── boundary │ └── ErrorBoundary-spec.tsx ├── components │ ├── Chart-data-update-spec.tsx │ ├── Chart-spec.tsx │ ├── Facet-spec.tsx │ ├── Facet-spex-2.tsx │ ├── Legend-spec.tsx │ ├── react-tooltip-spec.tsx │ └── resize-observer-spec.tsx ├── event-spec.tsx ├── exports │ └── theme-spec.tsx ├── geometry │ ├── Interval-spec.tsx │ ├── Line-spec.tsx │ ├── LineAdvance-spec.tsx │ └── Point-spec.tsx ├── pickWithout-spec.tsx ├── plots-base │ ├── BasePlot-spec.tsx │ └── __snapshots__ │ │ └── BasePlot-spec.tsx.snap ├── plots │ ├── AreaChart-spec.tsx │ ├── BarChart-spec.tsx │ ├── BubbleChart-spec.tsx │ ├── BulletChart-spec.tsx │ ├── CalendarChart-spec.tsx │ ├── ColumnChart-spec.tsx │ ├── DensityHeatmapChart-spec.tsx │ ├── DonutChart-spec.tsx │ ├── FunnelChart-spec.tsx │ ├── GaugeChart-spec.tsx │ ├── GroupedBarChart-spec.tsx │ ├── GroupedColumnChart-spec.tsx │ ├── GroupedRoseChart-spec.tsx │ ├── HeatmapChart-spec.tsx │ ├── LineChart-spec.tsx │ ├── LiquidChart-spec.tsx │ ├── PercentStackedAreaChart-spec.tsx │ ├── PercentStackedBarChart-spec.tsx │ ├── PercentStackedColumnChart-spec.tsx │ ├── PieChart-spec.tsx │ ├── ProgressChart-spec.tsx │ ├── RadarChart-spec.tsx │ ├── RangeBarChart-spec.tsx │ ├── RangeColumnChart-spec.tsx │ ├── RingProgressChart-spec.tsx │ ├── RoseChart-spec.tsx │ ├── ScatterChart-spec.tsx │ ├── StackedAreaChart-spec.tsx │ ├── StackedBarChart-spec.tsx │ ├── StackedColumnChart-spec.tsx │ ├── StackedRoseChart-spec.tsx │ ├── StepLineChart-spec.tsx │ ├── TinyAreaChart-spec.tsx │ ├── TinyColumnChart-spec.tsx │ ├── TinyLineChart-spec.tsx │ ├── TreemapChart-spec.tsx │ ├── WaterfallChart-spec.tsx │ ├── WordCloudChart-spec.tsx │ ├── __snapshots__ │ │ ├── BarChart-spec.tsx.snap │ │ ├── CalendarChart-spec.tsx.snap │ │ ├── ColumnChart-spec.tsx.snap │ │ ├── DensityHeatmapChart-spec.tsx.snap │ │ ├── FunnelChart-spec.tsx.snap │ │ ├── GaugeChart-spec.tsx.snap │ │ ├── GroupedBarChart-spec.tsx.snap │ │ ├── GroupedColumnChart-spec.tsx.snap │ │ ├── GroupedRoseChart-spec.tsx.snap │ │ ├── HeatmapChart-spec.tsx.snap │ │ ├── LineChart-spec.tsx.snap │ │ ├── LiquidChart-spec.tsx.snap │ │ ├── PercentStackedAreaChart-spec.tsx.snap │ │ ├── PercentStackedBarChart-spec.tsx.snap │ │ ├── PercentStackedColumnChart-spec.tsx.snap │ │ ├── PieChart-spec.tsx.snap │ │ ├── ProgressChart-spec.tsx.snap │ │ ├── RadarChart-spec.tsx.snap │ │ ├── RangeBarChart-spec.tsx.snap │ │ ├── RangeColumnChart-spec.tsx.snap │ │ ├── RingProgressChart-spec.tsx.snap │ │ ├── RoseChart-spec.tsx.snap │ │ ├── ScatterChart-spec.tsx.snap │ │ ├── StackedAreaChart-spec.tsx.snap │ │ ├── StackedBarChart-spec.tsx.snap │ │ ├── StackedColumnChart-spec.tsx.snap │ │ ├── StackedRoseChart-spec.tsx.snap │ │ ├── StepLineChart-spec.tsx.snap │ │ ├── TinyAreaChart-spec.tsx.snap │ │ ├── TinyColumnChart-spec.tsx.snap │ │ └── TinyLineChart-spec.tsx.snap │ └── _update-option-spec.tsx ├── scale │ ├── cust-scale-spec.tsx │ ├── cust-scale │ │ ├── scale.ts │ │ └── tickMethod.ts │ └── scale-spec.tsx ├── setup.js ├── shallowEqual-spec.tsx ├── tools │ ├── simulate.ts │ └── sleep.ts ├── utils │ ├── percentage-spec.tsx │ └── transBooleanCfg-spec.tsx └── version-spec.tsx └── webpack.config.js /.eslintignore: -------------------------------------------------------------------------------- 1 | lib/ 2 | .storybook/ 3 | __stories__/ 4 | test/_helpers/ 5 | webpack.config.js 6 | umd/ 7 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // 文档可以看 https://pro.ant.design/blog/use-eslint-typescript-cn 2 | module.exports = { 3 | extends: [require.resolve('@umijs/fabric/dist/eslint')], 4 | globals: {}, 5 | rules: { 6 | 'import/no-extraneous-dependencies': 0, 7 | 'no-self-compare': 0, 8 | 'max-classes-per-file': 0, 9 | 'no-underscore-dangle': 0, 10 | 'lines-between-class-members': 0, 11 | '@typescript-eslint/lines-between-class-members': 0, 12 | ' @typescript-eslint/consistent-type-imports': 0, 13 | 'class-methods-use-this': 0, 14 | 'no-lonely-if': 0, 15 | 'no-param-reassign': 0, 16 | 'no-useless-escape': 0, 17 | 'no-plusplus': 0, 18 | 'react/no-typos': 0, 19 | 'prefer-destructuring': 0 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /.fatherrc.js: -------------------------------------------------------------------------------- 1 | export default { 2 | entry: 'src/index.tsx', 3 | esm: { 4 | type: 'babel', 5 | importLibToEs: true, 6 | }, 7 | cjs: 'babel', 8 | // umd: true, 9 | }; 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | BizCharts Version: 2 | Platform: 3 | Mini Showcase(like screenshots): 4 | forck and create a demo: https://bizcharts.net/product/BizCharts4/demo/306 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .history 3 | node_modules 4 | lib 5 | esm 6 | es 7 | umd 8 | .eslintcache 9 | 10 | # npm 11 | yarn.lock 12 | npm-debug.log 13 | yarn-error.log 14 | 15 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | const fabric = require('@umijs/fabric'); 2 | 3 | module.exports = { 4 | ...fabric.prettier, 5 | }; 6 | -------------------------------------------------------------------------------- /.storybook/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "import/no-extraneous-dependencies": [2, { 4 | "devDependencies": true 5 | }], 6 | "global-require": 2 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.storybook/main.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | addons: [ 5 | '@storybook/addon-knobs', 6 | '@storybook/addon-links', 7 | '@storybook/addon-actions', 8 | '@storybook/addon-backgrounds', 9 | '@storybook/addon-docs', 10 | ] 11 | }; -------------------------------------------------------------------------------- /.storybook/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = ({ config }) => { 4 | // babel loader is father 30% 5 | config.module.rules.push({ 6 | test: /\.(ts|tsx)$/, 7 | loader: require.resolve('babel-loader'), 8 | options: { 9 | presets: [ 10 | '@babel/preset-typescript', 11 | [ 12 | 'umi', 13 | { 14 | targets: { 15 | browsers: ['last 2 versions'], 16 | }, 17 | }, 18 | ], 19 | ], 20 | }, 21 | }); 22 | config.resolve.extensions.push('.ts', '.tsx'); 23 | config.module.rules.push( 24 | { 25 | test: /\.s?css$/, 26 | use: ['style-loader', 'raw-loader', 'sass-loader'], 27 | include: [path.resolve(__dirname, '../css/')], 28 | }, 29 | { 30 | test: /\.svg$/, 31 | use: [ 32 | { 33 | loader: 'babel-loader', 34 | query: { 35 | presets: ['airbnb'], 36 | }, 37 | }, 38 | ], 39 | }, 40 | { 41 | test: /\.jsx$/, 42 | use: [ 43 | { 44 | loader: 'babel-loader', 45 | query: { 46 | presets: ['airbnb'], 47 | }, 48 | }, 49 | ], 50 | }, 51 | ); 52 | config.resolve.extensions.push('.js', '.jsx'); 53 | config.resolve.alias={ 54 | ...config.resolve.alias, 55 | '@antv/g2': path.resolve(__dirname, '../node_modules/@antv/g2'), 56 | } 57 | return config; 58 | }; 59 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting Security Issues 2 | If you believe you have found a security vulnerability in BizCharts, we encourage you to let us know right away. We will investigate all legitimate reports and do our best to quickly fix the problem. 3 | 4 | 5 | Please send the content to the following e-mail: 6 | - huanian.chn@alibaba-inc.com (以昕) 7 | - fengyue@alibaba-inc.com (风月) 8 | -------------------------------------------------------------------------------- /__stories__/area.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import areaWithNull from '../demos/area/areaWithNull'; 5 | import basicArea from '../demos/area/basicArea'; 6 | import basicAreaWithNegativeValues from '../demos/area/basicAreaWithNegativeValues'; 7 | import colorBlock from '../demos/area/colorBlock'; 8 | import intervalArea from '../demos/area/intervalArea'; 9 | import percentStackingArea from '../demos/area/percentStackingArea'; 10 | import stackingArea from '../demos/area/stackingArea'; 11 | 12 | storiesOf('area', module).add('存在空值的面积图', areaWithNull); 13 | storiesOf('area', module).add('基础面积图', basicArea); 14 | storiesOf('area', module).add('有负值的基础面积图', basicAreaWithNegativeValues); 15 | storiesOf('area', module).add('色块图', colorBlock); 16 | storiesOf('area', module).add('区间面积图', intervalArea); 17 | storiesOf('area', module).add('百分比堆叠面积图', percentStackingArea); 18 | storiesOf('area', module).add('堆叠面积图', stackingArea); 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /__stories__/base.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | import { withInfo } from '@storybook/addon-info'; 4 | 5 | import AutoFit, { ChangeSize } from '../demos/components/autoFit'; 6 | import Coordinate from '../demos/components/coordinate'; 7 | import View from '../demos/components/view'; 8 | import Annotation from '../demos/components/annotation'; 9 | import AnnotationText from '../demos/components/annotation-text'; 10 | 11 | 12 | withInfo({ info: '' }); 13 | 14 | const stories = storiesOf('基础组件', module); 15 | stories.add('Chart autoFit', AutoFit); 16 | stories.add('Change Chart Size', ChangeSize); 17 | stories.add('Coordinate', Coordinate); 18 | stories.add('annotation', Annotation); 19 | stories.add('annotation-text', AnnotationText); 20 | stories.add('View', View); 21 | -------------------------------------------------------------------------------- /__stories__/box.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import basicBox from '../demos/box/basicBox' 5 | 6 | storiesOf('box', module).add('基础箱型图', basicBox); 7 | -------------------------------------------------------------------------------- /__stories__/bugs.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import ViewChange from '../demos/bugs/view-changeData'; 5 | import Columntree from '../demos/features/facet'; 6 | 7 | storiesOf('bugs', module) 8 | .add('Columntree', () => ) 9 | .add('ViewChange', () => ); 10 | -------------------------------------------------------------------------------- /__stories__/candle.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import stock from '../demos/candle/stock' 5 | 6 | storiesOf('candle', module).add('股票图于柱状图', stock); 7 | -------------------------------------------------------------------------------- /__stories__/dashboard.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import basicDashboard from '../demos/dashboard/basicDashboard' 5 | 6 | storiesOf('dashboard', module).add('基础仪表盘', basicDashboard); 7 | -------------------------------------------------------------------------------- /__stories__/feature.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import Pure from '../demos/features/pure'; 5 | import Transform from '../demos/features/transform'; 6 | import Effects from '../demos/features/effects'; 7 | import Resize from '../demos/features/resize'; 8 | import ChangeData from '../demos/features/changeData'; 9 | import Slider from '../demos/features/slider'; 10 | import Selected from '../demos/features/selected'; 11 | import ChartManager from '../demos/features/chartManager'; 12 | import Filter from '../demos/features/filter'; 13 | import Reconciler from '../demos/features/fiber-reconciler'; 14 | import TooltipLinkage from '../demos/features/tooltip-linkage'; 15 | import JsxTooltip from '../demos/features/JsxTooltip'; 16 | 17 | storiesOf('features', module) 18 | .add('Pure', Pure) 19 | .add('transform', Transform) 20 | .add('effects', Effects) 21 | .add('resize', Resize) 22 | .add('changeData', ChangeData) 23 | .add('slider', Slider) 24 | .add('selected', Selected) 25 | .add('chartManager', ChartManager) 26 | .add('filter', Filter) 27 | .add('TooltipLinkage', TooltipLinkage) 28 | .add('JsxTooltip', JsxTooltip) 29 | .add('reconciler', () => ); 30 | -------------------------------------------------------------------------------- /__stories__/funnel.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import basicFunnel from '../demos/funnel/basicFunnel' 5 | 6 | storiesOf('funnel', module).add('基础漏斗图', basicFunnel); 7 | -------------------------------------------------------------------------------- /__stories__/g.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import Demo from '../demos/g-components/basic' 5 | 6 | storiesOf('g-components', module).add('basic', Demo); 7 | -------------------------------------------------------------------------------- /__stories__/geometry.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import Line from '../demos/geom/line'; 5 | import Interval from '../demos/geom/interval'; 6 | import IntervalGroup from '../demos/geom/interval-group'; 7 | import LineAdvance from '../demos/geom/LineAdvance'; 8 | 9 | storiesOf('geometry', module).add('line', Line); 10 | storiesOf('geometry', module).add('Interval', Interval); 11 | storiesOf('geometry', module).add('Interval-group', IntervalGroup); 12 | storiesOf('geometry', module).add('LineAdvance', LineAdvance); 13 | -------------------------------------------------------------------------------- /__stories__/heatMap.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import calendar from '../demos/heatMap/calendar'; 5 | import heatMap from '../demos/heatMap/heatMap'; 6 | 7 | storiesOf('heatMap', module).add('热力图', heatMap); 8 | storiesOf('heatMap', module).add('日历热力图', calendar); 9 | -------------------------------------------------------------------------------- /__stories__/line.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import gradientPolyline from '../demos/line/gradientPolyline'; 5 | import ordinaryCurve from '../demos/line/ordinaryCurve'; 6 | import ordinaryPolyline from '../demos/line/ordinaryPolyline'; 7 | import stepPolyline from '../demos/line/stepPolyline'; 8 | 9 | storiesOf('line', module).add('渐变色折线图', gradientPolyline); 10 | storiesOf('line', module).add('普通曲线图', ordinaryCurve); 11 | storiesOf('line', module).add('普通折线图', ordinaryPolyline); 12 | storiesOf('line', module).add('阶梯折线图', stepPolyline); 13 | -------------------------------------------------------------------------------- /__stories__/path.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import Path from '../demos/geom/path'; 5 | 6 | storiesOf('path', module).add('路径图', Path); 7 | -------------------------------------------------------------------------------- /__stories__/pie.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import RoseChartLimitedAngleRange from '../demos/pie/RoseChart-limitedAngleRange' 5 | import basicPie from '../demos/pie/basicPie' 6 | import multicolorNightingaleRoseillustration from '../demos/pie/multicolorNightingaleRoseillustration' 7 | import nestedPie from '../demos/pie/nestedPie' 8 | import nightingaleRoseIllustration from '../demos/pie/nightingaleRoseIllustration' 9 | import nightingaleRosette from '../demos/pie/nightingaleRosette' 10 | import visualizationOfDailyWork from '../demos/pie/visualizationOfDailyWork' 11 | 12 | storiesOf('pie', module).add('玫瑰图-限定角度范围', RoseChartLimitedAngleRange); 13 | storiesOf('pie', module).add('基础饼图', basicPie); 14 | storiesOf('pie', module).add('多色南丁格尔玫瑰图', multicolorNightingaleRoseillustration); 15 | storiesOf('pie', module).add('嵌套饼图', nestedPie); 16 | storiesOf('pie', module).add('南丁格尔玫瑰环图', nightingaleRoseIllustration); 17 | storiesOf('pie', module).add('南丁格尔玫瑰图', nightingaleRosette); 18 | storiesOf('pie', module).add('日常作息可视化', visualizationOfDailyWork); 19 | -------------------------------------------------------------------------------- /__stories__/plot.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | import { withInfo } from '@storybook/addon-info'; 4 | 5 | import { text, withKnobs, boolean, number, object, select } from '@storybook/addon-knobs'; 6 | 7 | import Line from '../demos/plot/line'; 8 | import Ring from '../demos/plot/ring'; 9 | import Plots from '../demos/plot/plots'; 10 | import Gauge from '../demos/plot/gauge'; 11 | withInfo({ info: '' }); 12 | 13 | const stories = storiesOf('createPlot', module); 14 | stories.add('line', () => ( 15 | 21 | )); 22 | 23 | stories.add('ring', Ring); 24 | stories.add('plot-Charts', Plots); 25 | stories.add('自定义min max的gauge', Gauge); 26 | -------------------------------------------------------------------------------- /__stories__/plots/area.stories.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import AreaChart from '../../src/plots/AreaChart'; 5 | 6 | storiesOf('box', module).add('面积图', () => { 7 | const [ data, setData ] = useState([]); 8 | const option = { 9 | xField: 'Date', 10 | yField: 'scales', 11 | xAxis: { 12 | range: [0, 1], 13 | tickCount: 5, 14 | }, 15 | } 16 | useEffect(() => { 17 | fetch('https://gw.alipayobjects.com/os/bmw-prod/1d565782-dde4-4bb6-8946-ea6a38ccf184.json') 18 | .then((res) => res.json()) 19 | .then((data) => { 20 | setData(data); 21 | }); 22 | }, []) 23 | return 24 | }); 25 | -------------------------------------------------------------------------------- /__stories__/point.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import basicPoint from '../demos/point/basicPoint' 5 | import bubble from '../demos/point/bubble' 6 | import multiShapeScatter from '../demos/point/multiShapeScatter' 7 | 8 | storiesOf('point', module).add('基础散点图', basicPoint); 9 | storiesOf('point', module).add('气泡图', bubble); 10 | storiesOf('point', module).add('多形状散点图', multiShapeScatter); 11 | -------------------------------------------------------------------------------- /__stories__/radar.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | import radar from '../demos/radar/radar' 5 | 6 | storiesOf('radar', module).add('雷达图', radar); 7 | -------------------------------------------------------------------------------- /__stories__/temp.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | 4 | storiesOf('开发手册', module).add('模版', () =>
); 5 | -------------------------------------------------------------------------------- /__stories__/theme.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { storiesOf } from '@storybook/react'; 3 | import { withInfo } from '@storybook/addon-info'; 4 | 5 | import ThemedChart from '../demos/theme'; 6 | withInfo({ info: '' }); 7 | 8 | const stories = storiesOf('Theme', module); 9 | stories.add('Chart Theme', ThemedChart); 10 | -------------------------------------------------------------------------------- /demos/adepter/coord.jsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/BizCharts/0be043c2fe36dd1ef56fa252e7a075a0a31115b5/demos/adepter/coord.jsx -------------------------------------------------------------------------------- /demos/adepter/geom-label.jsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/BizCharts/0be043c2fe36dd1ef56fa252e7a075a0a31115b5/demos/adepter/geom-label.jsx -------------------------------------------------------------------------------- /demos/bugs/plot-bar.jsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/no-extraneous-dependencies */ 2 | import React from "react"; 3 | import { BarChart } from '../../src'; 4 | const data = [ 5 | { 6 | year: "1991", 7 | value: 5 8 | }, 9 | { 10 | year: "1992", 11 | value: 4 12 | }, 13 | { 14 | year: "1993", 15 | value: 3.5 16 | }, 17 | { 18 | year: "1994", 19 | value: 5 20 | }, 21 | { 22 | year: "1995", 23 | value: 4.9 24 | } 25 | ]; 26 | 27 | function Basic(options) { 28 | return ( 29 |
30 | 36 | 37 |
38 | ); 39 | } 40 | 41 | export default Basic; 42 | -------------------------------------------------------------------------------- /demos/components/axis.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { 3 | Chart, 4 | Area, 5 | Axis, 6 | Tooltip, 7 | } from "../../src"; 8 | 9 | const data = [ 10 | { 11 | year: "1991", 12 | value: 3 13 | }, 14 | { 15 | year: "1992", 16 | value: 4 17 | }, 18 | { 19 | year: "1993", 20 | value: 3.5 21 | }, 22 | { 23 | year: "1994", 24 | value: 5 25 | }, 26 | { 27 | year: "1995", 28 | value: 4.9 29 | }, 30 | { 31 | year: "1996", 32 | value: 6 33 | }, 34 | { 35 | year: "1997", 36 | value: 7 37 | }, 38 | { 39 | year: "1998", 40 | value: 9 41 | }, 42 | { 43 | year: "1999", 44 | value: 13 45 | } 46 | ]; 47 | function Basic() { 48 | const cols = { 49 | value: { 50 | min: 0 51 | }, 52 | year: { 53 | range: [0, 1] 54 | } 55 | }; 56 | return ( 57 |
58 | 59 | 60 | 61 | 66 | 75 | 76 |
77 | ); 78 | } 79 | 80 | export default Basic; 81 | -------------------------------------------------------------------------------- /demos/components/coordinate.jsx: -------------------------------------------------------------------------------- 1 | 2 | import React from "react"; 3 | import { 4 | Chart, 5 | Interval, 6 | Legend, 7 | Coordinate 8 | } from "../../src"; 9 | 10 | const data = [ 11 | { type: '一线城市', value: 0.19 }, 12 | { type: '二线城市', value: 0.21 }, 13 | { type: '三线城市', value: 0.27 }, 14 | { type: '四线及以下', value: 0.33 }, 15 | ]; 16 | 17 | export default function Demo() { 18 | return 19 | 20 | 21 | 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /demos/external/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demos/features/interaction.jsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/BizCharts/0be043c2fe36dd1ef56fa252e7a075a0a31115b5/demos/features/interaction.jsx -------------------------------------------------------------------------------- /demos/features/pure.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { 3 | Chart, 4 | Interval, 5 | } from "../../src"; 6 | 7 | const data = [ 8 | { 9 | year: "1991", 10 | value: 3 11 | }, 12 | { 13 | year: "1992", 14 | value: 4 15 | }, 16 | { 17 | year: "1993", 18 | value: 3.5 19 | }, 20 | { 21 | year: "1994", 22 | value: 5 23 | }, 24 | { 25 | year: "1995", 26 | value: 4.9 27 | }, 28 | { 29 | year: "1996", 30 | value: 6 31 | }, 32 | { 33 | year: "1997", 34 | value: 7 35 | }, 36 | { 37 | year: "1998", 38 | value: 9 39 | }, 40 | { 41 | year: "1999", 42 | value: 13 43 | } 44 | ]; 45 | function Basic() { 46 | return ( 47 |
48 | 49 | 50 | 51 |
52 | ); 53 | } 54 | 55 | export default Basic; 56 | -------------------------------------------------------------------------------- /demos/features/selected.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Chart, Interval, Interaction } from '../../src'; 3 | 4 | const data = [ 5 | { year: '1951 年', sales: 38 }, 6 | { year: '1952 年', sales: 52 }, 7 | { year: '1956 年', sales: 61 }, 8 | { year: '1957 年', sales: 45 }, 9 | { year: '1958 年', sales: 48 }, 10 | { year: '1959 年', sales: 38 }, 11 | { year: '1960 年', sales: 38 }, 12 | { year: '1962 年', sales: 38 }, 13 | ]; 14 | 15 | 16 | function Demo() { 17 | return 18 | { 19 | elements[1].setState('selected', true); 20 | }} active-region /> 21 | 22 | 23 | } 24 | 25 | export default Demo; 26 | -------------------------------------------------------------------------------- /demos/features/slider.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Chart, Line, Slider } from "../../src"; 3 | 4 | // 数据源 5 | const data = [ 6 | { 7 | month: "Jan", 8 | value: 51 9 | }, 10 | { 11 | month: "Feb", 12 | value: 91 13 | }, 14 | { 15 | month: "Mar", 16 | value: 34 17 | }, 18 | { 19 | month: "Apr", 20 | value: 47 21 | }, 22 | { 23 | month: "May", 24 | value: 63 25 | }, 26 | { 27 | month: "June", 28 | value: 58 29 | }, 30 | { 31 | month: "July", 32 | value: 56 33 | }, 34 | { 35 | month: "Aug", 36 | value: 77 37 | }, 38 | { 39 | month: "Sep", 40 | value: 99 41 | }, 42 | { 43 | month: "Oct", 44 | value: 106 45 | }, 46 | { 47 | month: "Nov", 48 | value: 88 49 | }, 50 | { 51 | month: "Dec", 52 | value: 56 53 | } 54 | ]; 55 | 56 | function Demo() { 57 | return 58 | 59 | 60 | 61 | } 62 | 63 | 64 | 65 | export default Demo; 66 | 67 | 68 | -------------------------------------------------------------------------------- /demos/geom/area.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { 3 | Chart, 4 | Area, 5 | Tooltip, 6 | } from "../../src"; 7 | 8 | const data = [ 9 | { 10 | year: "1991", 11 | value: 3 12 | }, 13 | { 14 | year: "1992", 15 | value: 4 16 | }, 17 | { 18 | year: "1993", 19 | value: 3.5 20 | }, 21 | { 22 | year: "1994", 23 | value: 5 24 | }, 25 | { 26 | year: "1995", 27 | value: 4.9 28 | }, 29 | { 30 | year: "1996", 31 | value: 6 32 | }, 33 | { 34 | year: "1997", 35 | value: 7 36 | }, 37 | { 38 | year: "1998", 39 | value: 9 40 | }, 41 | { 42 | year: "1999", 43 | value: 13 44 | } 45 | ]; 46 | function Basic() { 47 | const cols = { 48 | value: { 49 | min: 0 50 | }, 51 | year: { 52 | range: [0, 1] 53 | } 54 | }; 55 | return ( 56 |
57 | 58 | 63 | 72 | 73 |
74 | ); 75 | } 76 | 77 | export default Basic; 78 | -------------------------------------------------------------------------------- /demos/geom/interval-group.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { 3 | Chart, 4 | Interval, 5 | Tooltip, 6 | } from "../../src"; 7 | 8 | const data = [ 9 | { name: 'London', 月份: 'Jan.', 月均降雨量: 18.9 }, 10 | { name: 'London', 月份: 'Feb.', 月均降雨量: 28.8 }, 11 | { name: 'London', 月份: 'Mar.', 月均降雨量: 39.3 }, 12 | { name: 'London', 月份: 'Apr.', 月均降雨量: 81.4 }, 13 | { name: 'London', 月份: 'May', 月均降雨量: 47 }, 14 | { name: 'London', 月份: 'Jun.', 月均降雨量: 20.3 }, 15 | { name: 'London', 月份: 'Jul.', 月均降雨量: 24 }, 16 | { name: 'London', 月份: 'Aug.', 月均降雨量: 35.6 }, 17 | { name: 'Berlin', 月份: 'Jan.', 月均降雨量: 12.4 }, 18 | { name: 'Berlin', 月份: 'Feb.', 月均降雨量: 23.2 }, 19 | { name: 'Berlin', 月份: 'Mar.', 月均降雨量: 34.5 }, 20 | { name: 'Berlin', 月份: 'Apr.', 月均降雨量: 99.7 }, 21 | { name: 'Berlin', 月份: 'May', 月均降雨量: 52.6 }, 22 | { name: 'Berlin', 月份: 'Jun.', 月均降雨量: 35.5 }, 23 | { name: 'Berlin', 月份: 'Jul.', 月均降雨量: 37.4 }, 24 | { name: 'Berlin', 月份: 'Aug.', 月均降雨量: 42.4 }, 25 | ]; 26 | 27 | export default function() { 28 | return ( 29 | 39 | 40 | ) 41 | } 42 | -------------------------------------------------------------------------------- /demos/geom/interval.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { 3 | Chart, 4 | Interval, 5 | Coordinate, 6 | Tooltip, 7 | } from "../../src"; 8 | 9 | const data = [ 10 | { 11 | year: "1991", 12 | value: 3 13 | }, 14 | { 15 | year: "1992", 16 | value: 4 17 | }, 18 | { 19 | year: "1993", 20 | value: 3.5 21 | }, 22 | { 23 | year: "1994", 24 | value: 5 25 | }, 26 | { 27 | year: "1995", 28 | value: 4.9 29 | }, 30 | { 31 | year: "1996", 32 | value: 6 33 | }, 34 | { 35 | year: "1997", 36 | value: 7 37 | }, 38 | { 39 | year: "1998", 40 | value: 9 41 | }, 42 | { 43 | year: "1999", 44 | value: 13 45 | } 46 | ]; 47 | function Basic(props) { 48 | const cfg = props || {} 49 | const cols = { 50 | value: { 51 | min: 0 52 | }, 53 | year: { 54 | range: [0, 1] 55 | } 56 | }; 57 | return ( 58 |
59 | 60 | 61 | 62 | 63 | 64 |
65 | ); 66 | } 67 | 68 | export default Basic; 69 | -------------------------------------------------------------------------------- /demos/heatMap/heatMap.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react'; 2 | import { 3 | Chart, 4 | Tooltip, 5 | Axis, 6 | Legend, 7 | Annotation, 8 | Heatmap 9 | } from '../../src'; 10 | 11 | 12 | function Demo() { 13 | const [data, setData] = useState([]); 14 | useEffect(() => { 15 | fetch('https://alifd.alibabausercontent.com/materials/@bizcharts/heatmap-image/0.3.0/mock.json') 16 | .then(res => res.json()) 17 | .then(resData => { 18 | setData(resData); 19 | }) 20 | }, []) 21 | 22 | return 31 | 34 | 35 | 36 | 37 | 42 | 43 | } 44 | 45 | export default Demo; -------------------------------------------------------------------------------- /demos/interval/basicColumn.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Chart, Interval, Interaction } from '../../src'; 3 | 4 | const data = [ 5 | { year: '1951 年', sales: 38 }, 6 | { year: '1952 年', sales: 52 }, 7 | { year: '1956 年', sales: 61 }, 8 | { year: '1957 年', sales: 45 }, 9 | { year: '1958 年', sales: 48 }, 10 | { year: '1959 年', sales: 38 }, 11 | { year: '1960 年', sales: 38 }, 12 | { year: '1962 年', sales: 38 }, 13 | ]; 14 | 15 | 16 | function Demo() { 17 | return 18 | 19 | 20 | 21 | } 22 | 23 | export default Demo; 24 | -------------------------------------------------------------------------------- /demos/interval/groupedColumns.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { 3 | Chart, 4 | Tooltip, 5 | Interval, 6 | } from "../../src"; 7 | 8 | const data = [ 9 | { name: 'London', 月份: 'Jan.', 月均降雨量: 18.9 }, 10 | { name: 'London', 月份: 'Feb.', 月均降雨量: 28.8 }, 11 | { name: 'London', 月份: 'Mar.', 月均降雨量: 39.3 }, 12 | { name: 'London', 月份: 'Apr.', 月均降雨量: 81.4 }, 13 | { name: 'London', 月份: 'May', 月均降雨量: 47 }, 14 | { name: 'London', 月份: 'Jun.', 月均降雨量: 20.3 }, 15 | { name: 'London', 月份: 'Jul.', 月均降雨量: 24 }, 16 | { name: 'London', 月份: 'Aug.', 月均降雨量: 35.6 }, 17 | { name: 'Berlin', 月份: 'Jan.', 月均降雨量: 12.4 }, 18 | { name: 'Berlin', 月份: 'Feb.', 月均降雨量: 23.2 }, 19 | { name: 'Berlin', 月份: 'Mar.', 月均降雨量: 34.5 }, 20 | { name: 'Berlin', 月份: 'Apr.', 月均降雨量: 99.7 }, 21 | { name: 'Berlin', 月份: 'May', 月均降雨量: 52.6 }, 22 | { name: 'Berlin', 月份: 'Jun.', 月均降雨量: 35.5 }, 23 | { name: 'Berlin', 月份: 'Jul.', 月均降雨量: 37.4 }, 24 | { name: 'Berlin', 月份: 'Aug.', 月均降雨量: 42.4 }, 25 | ]; 26 | 27 | function Grouped() { 28 | return ( 29 | 30 | 40 | 41 | 42 | ); 43 | } 44 | 45 | export default Grouped; 46 | -------------------------------------------------------------------------------- /demos/interval/intervalColumn.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { 3 | Chart, 4 | Interval, 5 | } from "../../src"; 6 | 7 | const Columnrange = () => { 8 | const data = [ 9 | { 10 | x: "分类一", 11 | y: [76, 100] 12 | }, 13 | { 14 | x: "分类二", 15 | y: [56, 108] 16 | }, 17 | { 18 | x: "分类三", 19 | y: [38, 129] 20 | }, 21 | { 22 | x: "分类四", 23 | y: [58, 155] 24 | }, 25 | { 26 | x: "分类五", 27 | y: [45, 120] 28 | }, 29 | { 30 | x: "分类六", 31 | y: [23, 99] 32 | }, 33 | { 34 | x: "分类七", 35 | y: [18, 56] 36 | }, 37 | { 38 | x: "分类八", 39 | y: [18, 34] 40 | } 41 | ]; 42 | return ( 43 | 44 | 45 | 46 | ); 47 | } 48 | 49 | export default Columnrange; 50 | -------------------------------------------------------------------------------- /demos/interval/polarCoordinate.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { 3 | Chart, 4 | Tooltip, 5 | Interval, 6 | Coordinate 7 | } from "../../src"; 8 | 9 | const data = [ 10 | { name: 'London', 月份: 'Jan.', 月均降雨量: 18.9 }, 11 | { name: 'London', 月份: 'Feb.', 月均降雨量: 28.8 }, 12 | { name: 'London', 月份: 'Mar.', 月均降雨量: 39.3 }, 13 | { name: 'London', 月份: 'Apr.', 月均降雨量: 81.4 }, 14 | { name: 'London', 月份: 'May', 月均降雨量: 47 }, 15 | { name: 'London', 月份: 'Jun.', 月均降雨量: 20.3 }, 16 | { name: 'London', 月份: 'Jul.', 月均降雨量: 24 }, 17 | { name: 'London', 月份: 'Aug.', 月均降雨量: 35.6 }, 18 | { name: 'Berlin', 月份: 'Jan.', 月均降雨量: 12.4 }, 19 | { name: 'Berlin', 月份: 'Feb.', 月均降雨量: 23.2 }, 20 | { name: 'Berlin', 月份: 'Mar.', 月均降雨量: 34.5 }, 21 | { name: 'Berlin', 月份: 'Apr.', 月均降雨量: 99.7 }, 22 | { name: 'Berlin', 月份: 'May', 月均降雨量: 52.6 }, 23 | { name: 'Berlin', 月份: 'Jun.', 月均降雨量: 35.5 }, 24 | { name: 'Berlin', 月份: 'Jul.', 月均降雨量: 37.4 }, 25 | { name: 'Berlin', 月份: 'Aug.', 月均降雨量: 42.4 }, 26 | ]; 27 | 28 | function Grouped() { 29 | return ( 30 | 31 | 41 | 42 | 43 | 44 | ); 45 | } 46 | 47 | export default Grouped; 48 | 49 | -------------------------------------------------------------------------------- /demos/interval/stackedColumn.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { 3 | Chart, 4 | Tooltip, 5 | Interval, 6 | } from "../../src"; 7 | 8 | const data = [ 9 | { name: 'London', 月份: 'Jan.', 月均降雨量: 18.9 }, 10 | { name: 'London', 月份: 'Feb.', 月均降雨量: 28.8 }, 11 | { name: 'London', 月份: 'Mar.', 月均降雨量: 39.3 }, 12 | { name: 'London', 月份: 'Apr.', 月均降雨量: 81.4 }, 13 | { name: 'London', 月份: 'May', 月均降雨量: 47 }, 14 | { name: 'London', 月份: 'Jun.', 月均降雨量: 20.3 }, 15 | { name: 'London', 月份: 'Jul.', 月均降雨量: 24 }, 16 | { name: 'London', 月份: 'Aug.', 月均降雨量: 35.6 }, 17 | { name: 'Berlin', 月份: 'Jan.', 月均降雨量: 12.4 }, 18 | { name: 'Berlin', 月份: 'Feb.', 月均降雨量: 23.2 }, 19 | { name: 'Berlin', 月份: 'Mar.', 月均降雨量: 34.5 }, 20 | { name: 'Berlin', 月份: 'Apr.', 月均降雨量: 99.7 }, 21 | { name: 'Berlin', 月份: 'May', 月均降雨量: 52.6 }, 22 | { name: 'Berlin', 月份: 'Jun.', 月均降雨量: 35.5 }, 23 | { name: 'Berlin', 月份: 'Jul.', 月均降雨量: 37.4 }, 24 | { name: 'Berlin', 月份: 'Aug.', 月均降雨量: 42.4 }, 25 | ]; 26 | 27 | function Demo() { 28 | return ( 29 | 30 | 39 | 40 | 41 | ); 42 | } 43 | 44 | export default Demo; 45 | -------------------------------------------------------------------------------- /demos/line/gradientPolyline.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Chart, Line } from '../../src'; 3 | 4 | // 数据源 5 | const data = [ 6 | { month: "2015-01-01", acc: 84.0 }, 7 | { month: "2015-02-01", acc: 14.9 }, 8 | { month: "2015-03-01", acc: 17.0 }, 9 | { month: "2015-04-01", acc: 20.2 }, 10 | { month: "2015-05-01", acc: 55.6 }, 11 | { month: "2015-06-01", acc: 56.7 }, 12 | { month: "2015-07-01", acc: 30.6 }, 13 | { month: "2015-08-01", acc: 63.2 }, 14 | { month: "2015-09-01", acc: 24.6 }, 15 | { month: "2015-10-01", acc: 14.0 }, 16 | { month: "2015-11-01", acc: 9.4 }, 17 | { month: "2015-12-01", acc: 7.3 } 18 | ]; 19 | 20 | function Demo() { 21 | return 22 | 27 | 28 | } 29 | 30 | 31 | 32 | export default Demo; 33 | 34 | 35 | -------------------------------------------------------------------------------- /demos/line/ordinaryPolyline.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Chart, Line, Point } from '../../src'; 3 | 4 | let year = 1990; 5 | 6 | 7 | // 数据源 8 | const data = new Array(1200).fill('').map(() => { 9 | return { 10 | year: year++, 11 | value: Math.round(Math.random()) 12 | } 13 | }); 14 | 15 | 16 | function Demo() { 17 | return 25 | 26 | 27 | 28 | } 29 | 30 | export default Demo; 31 | 32 | 33 | -------------------------------------------------------------------------------- /demos/line/stepPolyline.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Chart, Line } from "../../src"; 3 | 4 | // 数据源 5 | const data = [ 6 | { 7 | month: "Jan", 8 | value: 51 9 | }, 10 | { 11 | month: "Feb", 12 | value: 91 13 | }, 14 | { 15 | month: "Mar", 16 | value: 34 17 | }, 18 | { 19 | month: "Apr", 20 | value: 47 21 | }, 22 | { 23 | month: "May", 24 | value: 63 25 | }, 26 | { 27 | month: "June", 28 | value: 58 29 | }, 30 | { 31 | month: "July", 32 | value: 56 33 | }, 34 | { 35 | month: "Aug", 36 | value: 77 37 | }, 38 | { 39 | month: "Sep", 40 | value: 99 41 | }, 42 | { 43 | month: "Oct", 44 | value: 106 45 | }, 46 | { 47 | month: "Nov", 48 | value: 88 49 | }, 50 | { 51 | month: "Dec", 52 | value: 56 53 | } 54 | ]; 55 | 56 | function Demo() { 57 | return 58 | 59 | 60 | } 61 | 62 | 63 | 64 | export default Demo; 65 | 66 | 67 | -------------------------------------------------------------------------------- /demos/pie/RoseChart-limitedAngleRange.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | Chart, 4 | Interval, 5 | Tooltip, 6 | Axis, 7 | Coordinate 8 | } from '../../src'; 9 | 10 | function Labelline () { 11 | const data = [ 12 | { type: '分类一', value: 27 }, 13 | { type: '分类二', value: 25 }, 14 | { type: '分类三', value: 18 }, 15 | { type: '分类四', value: 15 }, 16 | { type: '分类五', value: 10 }, 17 | { type: 'Other', value: 5 }, 18 | ]; 19 | 20 | 21 | return ( 22 | 23 | 28 | 34 | 35 | 52 | 53 | ); 54 | } 55 | 56 | export default Labelline; 57 | -------------------------------------------------------------------------------- /demos/pie/multicolorNightingaleRoseillustration.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | Chart, 4 | Interval, 5 | Tooltip, 6 | Axis, 7 | Coordinate 8 | } from '../../src'; 9 | 10 | function Labelline () { 11 | const data = [ 12 | { year: '2001', population: 41.8 }, 13 | { year: '2002', population: 38 }, 14 | { year: '2003', population: 33.7 }, 15 | { year: '2004', population: 30.7 }, 16 | { year: '2005', population: 25.8 }, 17 | { year: '2006', population: 31.7 }, 18 | { year: '2007', population: 33 }, 19 | { year: '2008', population: 46 }, 20 | { year: '2009', population: 38.3 }, 21 | { year: '2010', population: 28 }, 22 | { year: '2011', population: 42.5 }, 23 | { year: '2012', population: 30.3 }, 24 | ]; 25 | 26 | 27 | return ( 28 | 29 | 30 | 31 | 32 | 45 | 46 | ); 47 | } 48 | 49 | export default Labelline; 50 | -------------------------------------------------------------------------------- /demos/pie/nightingaleRoseIllustration.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | Chart, 4 | Interval, 5 | Tooltip, 6 | Axis, 7 | Coordinate 8 | } from '../../src'; 9 | 10 | function Labelline () { 11 | const data = [ 12 | { year: '2001', population: 41.8 }, 13 | { year: '2002', population: 38 }, 14 | { year: '2003', population: 33.7 }, 15 | { year: '2004', population: 30.7 }, 16 | { year: '2005', population: 25.8 }, 17 | { year: '2006', population: 31.7 }, 18 | { year: '2007', population: 33 }, 19 | { year: '2008', population: 46 }, 20 | { year: '2009', population: 38.3 }, 21 | { year: '2010', population: 28 }, 22 | { year: '2011', population: 42.5 }, 23 | { year: '2012', population: 30.3 }, 24 | ]; 25 | 26 | 27 | return ( 28 | 29 | 30 | 31 | 32 | 44 | 45 | ); 46 | } 47 | 48 | export default Labelline; 49 | -------------------------------------------------------------------------------- /demos/pie/nightingaleRosette.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | Chart, 4 | Interval, 5 | Tooltip, 6 | Axis, 7 | Coordinate 8 | } from '../../src'; 9 | 10 | function Labelline () { 11 | const data = [ 12 | { year: '2001', population: 41.8 }, 13 | { year: '2002', population: 38 }, 14 | { year: '2003', population: 33.7 }, 15 | { year: '2004', population: 30.7 }, 16 | { year: '2005', population: 25.8 }, 17 | { year: '2006', population: 31.7 }, 18 | { year: '2007', population: 33 }, 19 | { year: '2008', population: 46 }, 20 | { year: '2009', population: 38.3 }, 21 | { year: '2010', population: 28 }, 22 | { year: '2011', population: 42.5 }, 23 | { year: '2012', population: 30.3 }, 24 | ]; 25 | 26 | 27 | return ( 28 | 29 | 30 | 31 | 32 | 45 | 46 | ); 47 | } 48 | 49 | export default Labelline; 50 | -------------------------------------------------------------------------------- /demos/plot/gauge.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { GaugeChart } from '../../src'; 3 | 4 | function Demo() { 5 | return ( 6 | 27 | ); 28 | } 29 | 30 | export default Demo; 31 | -------------------------------------------------------------------------------- /demos/plot/ring.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Pie } from '@antv/g2plot'; 3 | import { createPlot } from '../../src'; 4 | 5 | const RingChart = createPlot(Pie); 6 | 7 | const data = [ 8 | { 9 | "x": "大健康", 10 | "y": 20 11 | }, 12 | { 13 | "x": "大淘系", 14 | "y": 20 15 | }, 16 | { 17 | "x": "大文娱", 18 | "y": 20 19 | }, 20 | { 21 | "x": "大物流", 22 | "y": 20 23 | }, 24 | { 25 | "x": "海外", 26 | "y": 20 27 | }, 28 | { 29 | "x": "基金", 30 | "y": 121 31 | }, 32 | { 33 | "x": "生活服务", 34 | "y": 140 35 | }, 36 | { 37 | "x": "新零售", 38 | "y": 151 39 | }, 40 | { 41 | "x": "新兴业务", 42 | "y": 200 43 | }, 44 | { 45 | "x": "云智能", 46 | "y": 79 47 | }, 48 | { 49 | "x": "待定", 50 | "y": 30 51 | }, 52 | { 53 | "x": "行业未定义", 54 | "y": 60 55 | } 56 | ]; 57 | const config = { 58 | "title": { 59 | "visible": true, 60 | "text": "环形图" 61 | }, 62 | "description": { 63 | "visible": true, 64 | "text": "一个简单的环形图" 65 | }, 66 | "label": { 67 | "type": "spider" 68 | }, 69 | "width": 580, 70 | "height": 460, 71 | "autoFit": false, 72 | "colorField": "x", 73 | "angleField": "y", 74 | } 75 | 76 | function Basic() { 77 | return 78 | } 79 | 80 | export default Basic; 81 | -------------------------------------------------------------------------------- /demos/point/basicPoint.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react'; 2 | import { 3 | Chart, 4 | Point, 5 | } from '../../src'; 6 | 7 | 8 | function Demo() { 9 | const [data, setData] = useState([]); 10 | useEffect(() => { 11 | fetch('https://alifd.alibabausercontent.com/materials/@bizcharts/point-scatter/0.2.8/mock.json') 12 | .then(res => res.json()) 13 | .then(resData => { 14 | setData(resData); 15 | }) 16 | }, []) 17 | 18 | return 25 | 32 | 33 | } 34 | 35 | export default Demo; 36 | -------------------------------------------------------------------------------- /demos/point/multiShapeScatter.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react'; 2 | import { 3 | Chart, 4 | Point, 5 | } from '../../src'; 6 | 7 | 8 | function Demo() { 9 | const [data, setData] = useState([]); 10 | useEffect(() => { 11 | fetch('https://alifd.alibabausercontent.com/materials/@bizcharts/point-scatter/0.2.8/mock.json') 12 | .then(res => res.json()) 13 | .then(resData => { 14 | setData(resData); 15 | }) 16 | }, []) 17 | 18 | return 24 | 31 | 32 | } 33 | 34 | export default Demo; -------------------------------------------------------------------------------- /docs/BizCharts/API文档/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 7, 3 | "name": "API文档", 4 | "name_en": "api", 5 | "product_id": 1, 6 | "parent_id": null, 7 | "rank": "0", 8 | "gmt_create": "2019-11-25T07:01:16.000Z", 9 | "gmt_modified": "2020-06-09T12:13:54.000Z", 10 | "is_deleted": 0, 11 | "is_avaliable": 1, 12 | "is_alinw": 0, 13 | "type": "normal", 14 | "externalPath": "/product/bizcharts/category/7/page/12", 15 | "creator_userid": null, 16 | "updator_userid": 11, 17 | "children": [] 18 | } -------------------------------------------------------------------------------- /docs/BizCharts/Demo/Guide-html.md: -------------------------------------------------------------------------------- 1 | # Guide-html 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/77cfefb0-9979-11ea-9761-adf4e02ffa04.png) 4 | 5 | ```js 6 | /** 7 | * guide-html 8 | */ 9 | 10 | import React from 'react'; 11 | import { Chart, Geom, Axis, Guide } from 'bizcharts@3.5.8'; 12 | 13 | const { Html } = Guide; 14 | 15 | class GuideHtml extends React.Component { 16 | render() { 17 | const data = [ 18 | { genre: 'Sports', sold: 275 }, 19 | { genre: 'Strategy', sold: 115 }, 20 | { genre: 'Action', sold: 120 }, 21 | { genre: 'Shooter', sold: 350 }, 22 | { genre: 'Other', sold: 150 }, 23 | ]; 24 | 25 | const scales = { 26 | sold: { alias: '销售量' }, 27 | genre: { alias: '游戏种类' }, 28 | }; 29 | 30 | return ( 31 | 32 | 33 | 34 | 35 | 36 | { 39 | console.log(yScale); 40 | return `
最大值是${yScale.sold.max},
最小值是${yScale.sold.min}
`; // 位置信息 41 | }} 42 | /> 43 |
44 |
45 | ); 46 | } 47 | } 48 | 49 | ReactDOM.render(, mountNode) 50 | 51 | ``` 52 | -------------------------------------------------------------------------------- /docs/BizCharts/Demo/Invalid Time: 20200229.md: -------------------------------------------------------------------------------- 1 | # Invalid Time: 20200229 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/77e3c5d0-9979-11ea-9761-adf4e02ffa04.png) 4 | 5 | ```js 6 | /** 7 | * 基础图表 8 | */ 9 | 10 | import React from 'react'; 11 | import ReactDOM from 'react-dom'; 12 | import { Chart, Geom, Axis } from 'bizcharts@3.5.8'; 13 | import moment from 'moment'; 14 | 15 | const data = [ 16 | {"date": '20200228', "value": "60"}, 17 | {"date": '20200229', "value": "80"}, 18 | {"date": '20200301', "value": "99"}, 19 | {"date": '20200302', "value": "89"}, 20 | {"date": '20200303', "value": "79"}, 21 | {"date": '20200304', "value": "89"}, 22 | {"date": '20200305', "value": "49"}, 23 | {"date": '20200306', "value": "79"}, 24 | {"date": '20200307', "value": "69"}, 25 | ]; 26 | 27 | const scale = { 28 | // date: {type: 'cat'}, 29 | value: { 30 | type: "linear", 31 | formatter: val => { 32 | return val + "%"; 33 | }, 34 | tickCount: 5, 35 | ticks: ["0", "25", "50", "75", "100"], 36 | } 37 | }; 38 | 39 | ReactDOM.render(( 40 | { 41 | const date = moment(item.date).format('YYYY-MM-DD'); 42 | return Object.assign({ date }, item); 43 | })} scale={scale}> 44 | 45 | 46 | 47 | 48 | ), mountNode); 49 | 50 | ``` 51 | -------------------------------------------------------------------------------- /docs/BizCharts/Demo/voronoi图.md: -------------------------------------------------------------------------------- 1 | # voronoi图 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/77cb34c0-9979-11ea-a591-9be663db1ad5.png) 4 | 5 | ```js 6 | import $ from "jquery"; 7 | import React from "react"; 8 | import { 9 | G2, 10 | Chart, 11 | Geom, 12 | Axis, 13 | Tooltip, 14 | Coord, 15 | Label, 16 | Legend, 17 | View, 18 | Guide, 19 | Shape, 20 | Facet, 21 | Util 22 | } from "bizcharts@3.5.8"; 23 | import DataSet from "@antv/data-set"; 24 | 25 | let data; 26 | $.ajax({ 27 | url: "https://alifd.alibabausercontent.com/materials/@bizcharts/relation-voronoi/0.2.8/mock.json", 28 | async : false, 29 | success: (iData) => { data = iData } 30 | }); 31 | 32 | class Voronoi extends React.Component { 33 | render() { 34 | const { DataView } = DataSet; 35 | const ds = new DataSet(); 36 | const dv = ds.createView().source(data); 37 | dv.transform({ 38 | type: "diagram.voronoi", 39 | fields: ["x", "y"], 40 | size: [800, 600], 41 | as: ["_x", "_y"] 42 | }); 43 | return ( 44 |
45 | 46 | 47 | 48 | 50 | 51 |
52 | ); 53 | } 54 | } 55 | 56 | ReactDOM.render(, mountNode) 57 | 58 | ``` 59 | -------------------------------------------------------------------------------- /docs/BizCharts/Demo/区间柱状图.md: -------------------------------------------------------------------------------- 1 | # 区间柱状图 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/77b5d800-9979-11ea-bd36-0f0eda3e7ac1.png) 4 | 5 | ```js 6 | import React from "react"; 7 | import { 8 | G2, 9 | Chart, 10 | Geom, 11 | Axis, 12 | Tooltip, 13 | Coord, 14 | Label, 15 | Legend, 16 | View, 17 | Guide, 18 | Shape, 19 | Facet, 20 | Util 21 | } from "bizcharts@3.5.8"; 22 | 23 | class Columnrange extends React.Component { 24 | render() { 25 | const data = [ 26 | { 27 | x: "分类一", 28 | y: [76, 100] 29 | }, 30 | { 31 | x: "分类二", 32 | y: [56, 108] 33 | }, 34 | { 35 | x: "分类三", 36 | y: [38, 129] 37 | }, 38 | { 39 | x: "分类四", 40 | y: [58, 155] 41 | }, 42 | { 43 | x: "分类五", 44 | y: [45, 120] 45 | }, 46 | { 47 | x: "分类六", 48 | y: [23, 99] 49 | }, 50 | { 51 | x: "分类七", 52 | y: [18, 56] 53 | }, 54 | { 55 | x: "分类八", 56 | y: [18, 34] 57 | } 58 | ]; 59 | return ( 60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 |
68 | ); 69 | } 70 | } 71 | 72 | ReactDOM.render(, mountNode) 73 | 74 | ``` 75 | -------------------------------------------------------------------------------- /docs/BizCharts/Demo/圆头折线图.md: -------------------------------------------------------------------------------- 1 | # 圆头折线图 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/2fcef0c0-69f4-11eb-b6ac-c11ccf54cc02.png) 4 | 5 | ```js 6 | // data-set 可以按需引入,除此之外不要引入别的包 7 | import React from 'react'; 8 | import { Chart, Axis, Geom } from 'bizcharts@3.5.8'; 9 | 10 | const data = [ 11 | { year: '1991', value: 6 }, 12 | { year: '1992', value: 8 }, 13 | { year: '1993', value: 5.5 }, 14 | { year: '1994', value: 7 }, 15 | { year: '1995', value: 9.9 }, 16 | { year: '1996', value: 6 }, 17 | { year: '1997', value: 5 }, 18 | { year: '1998', value: 10 }, 19 | { year: '1999', value: 19 } 20 | ]; 21 | 22 | class Demo extends React.Component { 23 | render() { 24 | return ( 25 | 29 | 30 | 31 | 38 | 39 | 40 | 41 | ); 42 | } 43 | } 44 | 45 | // CDN END 46 | ReactDOM.render(, mountNode) 47 | 48 | ``` 49 | -------------------------------------------------------------------------------- /docs/BizCharts/Demo/多形状散点图.md: -------------------------------------------------------------------------------- 1 | # 多形状散点图 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/77c1e5f0-9979-11ea-bd36-0f0eda3e7ac1.png) 4 | 5 | ```js 6 | import $ from "jquery"; 7 | import React from 'react'; 8 | import { 9 | Chart, 10 | Geom, 11 | Axis, 12 | Tooltip, 13 | Legend, 14 | } from 'bizcharts@3.5.8'; 15 | 16 | let data; 17 | $.ajax({ 18 | url: "https://alifd.alibabausercontent.com/materials/@bizcharts/point-scatter-shapes/0.1.3/mock.json", 19 | async : false, 20 | success: (iData) => { data = iData } 21 | }); 22 | 23 | class Scatter extends React.Component { 24 | render() { 25 | return ( 26 |
27 | 28 | 34 | 35 | 36 | 45 | 46 | 47 |
48 | ); 49 | } 50 | } 51 | 52 | ReactDOM.render(, mountNode) 53 | 54 | ``` 55 | -------------------------------------------------------------------------------- /docs/BizCharts/Demo/雷达图复杂曲线.md: -------------------------------------------------------------------------------- 1 | # 雷达图复杂曲线 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/77b3b520-9979-11ea-bd36-0f0eda3e7ac1.png) 4 | 5 | ```js 6 | import $ from "jquery"; 7 | // data-set 可以按需引入,除此之外不要引入别的包 8 | import React from 'react'; 9 | import { Chart, Axis, Tooltip, Geom, Coord } from 'bizcharts@3.5.8'; 10 | let data; 11 | $.ajax({ 12 | url: "https://alifd.alibabausercontent.com/materials/@bizcharts/radar-flower-line/0.1.2/mock.json", 13 | async : false, 14 | success: (iData) => { data = iData } 15 | }); 16 | 17 | // 下面的代码会被作为 cdn script 注入 注释勿删 18 | // CDN START 19 | const scale = { 20 | x: { 21 | tickInterval: 30, 22 | }, 23 | }; 24 | 25 | class RadarFlowerLine extends React.Component { 26 | constructor() { 27 | super(); 28 | this.state = { 29 | coordType: 'polar', 30 | }; 31 | } 32 | 33 | componentDidMount() { 34 | setTimeout(() => { 35 | this.setState({ 36 | coordType: 'rect', 37 | }); 38 | }, 2000); 39 | } 40 | 41 | render() { 42 | return ( 43 | 44 | 45 | 46 | 47 | 48 | 49 | ); 50 | } 51 | } 52 | 53 | // CDN END 54 | ReactDOM.render(, mountNode) 55 | 56 | ``` 57 | -------------------------------------------------------------------------------- /docs/BizCharts/使用指南/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 12, 3 | "name": "使用指南", 4 | "name_en": "docs", 5 | "product_id": 1, 6 | "parent_id": null, 7 | "rank": "1", 8 | "gmt_create": "2019-11-27T08:26:08.000Z", 9 | "gmt_modified": "2019-12-05T11:10:53.000Z", 10 | "is_deleted": 0, 11 | "is_avaliable": 1, 12 | "is_alinw": 0, 13 | "type": "normal", 14 | "externalPath": "/product/bizcharts/category/12/page/7", 15 | "creator_userid": null, 16 | "updator_userid": 1, 17 | "children": [] 18 | } -------------------------------------------------------------------------------- /docs/BizCharts/使用指南/主题.md: -------------------------------------------------------------------------------- 1 | # 主题 2 | 3 | 4 | >**引用: [G2 Theme](https://antv.alipay.com/zh-cn/g2/3.x/tutorial/theme.html)** 5 | 6 | ## 图表主题 7 | Bizcharts 提供了两种内建的主题: `default` and `dark`. 8 | 9 | 10 | ## 如何改变主题 11 | 12 | 你可以通过 `BizCharts.setTheme(themeName)` API 来改变主题。 13 | 14 | Exmaple: 15 | 16 | ```js 17 | BizCharts.setTheme('dark'); 18 | ``` 19 | 20 | ## 自定义主题 21 | 当调用 `BizCharts.setTheme()` API 传入的参数是一个对象时,这个时候代表使用你自定义的主题配置。 22 | 23 | Example: 24 | ```js 25 | const seaTheme = { 26 | animate:false, 27 | colors:{}, 28 | shapes:{}, 29 | }; 30 | BizCharts.setTheme(seaTheme); 31 | ``` 32 | 33 | 更多的自定义配置项, 请参考 [Theme API](../../7/page/41) 34 | -------------------------------------------------------------------------------- /docs/BizCharts/使用指南/图表交互.md: -------------------------------------------------------------------------------- 1 | # 图表交互 2 | 3 | ## 默认交互 4 | 包括: 5 | - active 激活,鼠标hover。 6 | - select 选中,鼠标点击选择、框选。 7 | 8 | ## 激活 9 | 开启以及关闭 shape 对于鼠标 hover 时的响应效果,默认为各个 `` 内置了 active 效果 。可以通过 *active* 属性关闭及开启。 10 | 例如: 11 | ```js 12 | 13 | 14 | ``` 15 | 16 | ## 选中 17 | 各个几何标记 geom 选中的模式包含如下三种: 18 | 1. 不可选中; 19 | 2. 单选; 20 | 3. 多选; 21 | 4. 选中是否可取消选中。 22 | 23 | 选中模式的设置方式如下: 24 | 25 | ```js 26 | ; // 关闭 27 | ; // 打开 28 | ; 34 | ``` 35 | 36 | 默认情况下,G2 中只有饼图支持选中交互,其他 geom 的选中模式默认情况下都是关闭的。 37 | 38 | **图表交互控制可以跟[图表事件](../../7/page/24#图表事件)结合用来定制图表的自定义交互** 39 | 40 | -------------------------------------------------------------------------------- /docs/BizCharts/使用指南/源数据的处理.md: -------------------------------------------------------------------------------- 1 | # 源数据的处理 2 | 3 | *文档转自G2* 4 | 5 | **BizCharts 支持两种格式的源数据** 6 | - JSON数组 7 | - DataView 对象 8 | 9 | ### JSON 数组 10 | Example: 11 | 12 | ```js 13 | var data = [ 14 | {"gender":"男","count":40}, 15 | {"gender":"女","count":30} 16 | ]; 17 | ``` 18 | 19 | ### DataView 对象 20 | * 单独使用 DataView 21 | * 如果仅仅是对数据进行加工,不需要图表联动 22 | 23 | * 通过状态量实现图表联动 24 | 在G2 3.0 中使用 DataSet 的状态量(State) 可以很容易的实现图表的联动,步骤如下: 25 | 1. 创建 DataSet 对象,指定状态量 26 | 2. 创建 DataView 对象,在 transform 中使用状态量 27 | 3. 创建图表,引用前面创建 DataView 28 | 4. 改变状态量,所有 DataView 更新 29 | 30 | 31 | 详见 [DataSet Package](../../7/page/37)。 32 | -------------------------------------------------------------------------------- /docs/BizCharts/使用指南/答疑Issue复现教程.md: -------------------------------------------------------------------------------- 1 | # 答疑Issue复现教程 2 | 3 | 4 | ## 编辑复现demo 5 | - 打开官网相关图表demo,编辑代码以复现遇到的问题。 6 | - 样例代码:[https://bizcharts.net/gist/2eneuOO3zao](https://bizcharts.net/gist/2eneuOO3zao) 7 | 8 | ## 保存demo 9 | - https://bizcharts.net/product/BizCharts4/demo/305 10 | - 之后点击代码编辑器右上方的保存,在弹窗中输入问题描述,并点击确定保存。 11 | 12 | 13 | 14 | ## 分享链接到钉钉答疑群 15 | - demo保存之后页面会自动刷新,拷贝页面链接分享到答疑,并艾特相关同学进行答疑。 16 | - ![拷贝demo链接](https://img.alicdn.com/tfs/TB1SxxhDAP2gK0jSZPxXXacQpXa-595-239.png) 17 | 18 | ## 钉钉答疑群 19 | - 开源一群:钉钉群号21708548(已满) 20 | - 开源二群:钉钉群号30230048(可加新同学) 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/BizCharts/实战/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 59, 3 | "name": "实战", 4 | "name_en": "use", 5 | "product_id": 1, 6 | "parent_id": null, 7 | "rank": "4", 8 | "gmt_create": "2020-03-26T02:01:55.000Z", 9 | "gmt_modified": "2020-03-26T02:10:40.000Z", 10 | "is_deleted": 0, 11 | "is_avaliable": 1, 12 | "is_alinw": 0, 13 | "type": "normal", 14 | "externalPath": "/product/bizcharts/category/59/page/70", 15 | "creator_userid": 1, 16 | "updator_userid": 1, 17 | "children": [] 18 | } -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Canvas.md: -------------------------------------------------------------------------------- 1 | # Canvas 2 | 3 | 4 | 5 | G组件的最外层必要组件,控制整个图表组件的渲染方式和画布容器大小。 6 | 7 | ## 使用方法 8 | 解构使用 9 | ```js 10 | import { GComponents } from 'bizcharts'; 11 | const { Canvas, Ellipse, Rect } = GComponents; 12 | ... 13 | 14 | ... 15 | 16 | ``` 17 | 也可按需使用 18 | ```js 19 | import Canvas from "bizcharts/g-components/Canvas"; 20 | ... 21 | 22 | ... 23 | 24 | ``` 25 | 26 | 27 | ## API 28 | 29 | ### renderer 30 | __ 31 | 32 | 可选择当前使用的渲染引擎,根据选择绘制不同的渲染组件,可选值为 'canvas' | 'svg',默认选择canvas。 33 | 34 | ### width 35 | __ 36 | 37 | 宽度 38 | 39 | ### height 40 | __ 41 | 42 | 高度 43 | 44 | ### container 45 | __ 46 | 47 | 画布容器,可以是容器 id 或者 DOM 元素 48 | 49 | ### cursor 50 | __ 51 | 画布的 cursor 样式,其中 `Cursor` 为样式类型,可参考 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor)。 -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Circle.md: -------------------------------------------------------------------------------- 1 | # Circle 2 | 3 | 4 | 5 | ## 组件使用 6 | [两种使用方式](/product/BizCharts4/category/61/page/181#使用方式) 7 | 8 | ## attrs属性 9 | 10 | 使用方式 11 | ```js 12 | 13 | ``` 14 | 15 | ### 通用属性 16 | [绘图属性](./169) 17 | 18 | ### x 19 | __ 20 | 圆心坐标的 x 坐标。 21 | 22 | ### y 23 | __ 24 | 圆心坐标的 y 坐标。 25 | 26 | ### r 27 | __ 28 | 圆的半径。 -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Ellipse.md: -------------------------------------------------------------------------------- 1 | # Ellipse 2 | 3 | 4 | 5 | ## 组件使用 6 | [两种使用方式](/product/BizCharts4/category/61/page/181#使用方式) 7 | 8 | ## attrs属性 9 | 10 | 使用方式 11 | ```js 12 | 22 | ``` 23 | 24 | ### 通用属性 25 | [绘图属性](./169) 26 | 27 | ### x 28 | __ 29 | 圆心坐标的 x 坐标。 30 | 31 | ### y 32 | __ 33 | 圆心坐标的 y 坐标。 34 | 35 | ### rx 36 | __ 37 | 椭圆的水平半径。 38 | 39 | ### ry 40 | __ 41 | 椭圆的垂直半径。 -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Group.md: -------------------------------------------------------------------------------- 1 | # Group 2 | 3 | 4 | 5 | Group组件作为父组件,可把组件内的多个Shape图形组件作为一个整体来进行渲染绘制,优化性能。 6 | 7 | ## 使用方法 8 | 9 | ```js 10 | 11 | 12 | 20 | 21 | 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Image.md: -------------------------------------------------------------------------------- 1 | # Image 2 | 3 | 4 | 5 | ## 组件使用 6 | [两种使用方式](/product/BizCharts4/category/61/page/181#使用方式) 7 | 8 | ## attrs属性 9 | 10 | 使用方式 11 | ```js 12 | 19 | ``` 20 | 21 | ### 通用属性 22 | [绘图属性](./169) 23 | 24 | ### x 25 | __ 26 | 起始点的 x 坐标。 27 | 28 | ### y 29 | __ 30 | 起始点的 y 坐标。 31 | 32 | ### width 33 | __ 34 | 图片宽度。 35 | 36 | ### height 37 | __ 38 | 图片高度。 39 | 40 | ### img 41 | __ 42 | 图片地址、图片对象或 canvas 对象。 -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Line.md: -------------------------------------------------------------------------------- 1 | # Line 2 | 3 | 4 | 5 | ## 组件使用 6 | [两种使用方式](/product/BizCharts4/category/61/page/181#使用方式) 7 | 8 | ## attrs属性 9 | 10 | 使用方式 11 | ```js 12 | 20 | ``` 21 | 22 | ### 通用属性 23 | [绘图属性](./169) 24 | 25 | ### x1 26 | __ 27 | 起始点的 x 坐标。 28 | 29 | ### y1 30 | __ 31 | 起始点的 y 坐标。 32 | 33 | ### x2 34 | __ 35 | 结束点的 x 坐标。 36 | 37 | ### y2 38 | __ 39 | 结束点的 y 坐标。 -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Marker.md: -------------------------------------------------------------------------------- 1 | # Marker 2 | 3 | 4 | 5 | ## 组件使用 6 | [两种使用方式](/product/BizCharts4/category/61/page/181#使用方式) 7 | 8 | ## attrs属性 9 | 10 | 使用方式 11 | ```js 12 | 21 | ``` 22 | 23 | ### 通用属性 24 | [绘图属性](./169) 25 | 26 | ### x 27 | __ 28 | 中心点的 x 坐标。 29 | 30 | ### y 31 | __ 32 | 中心点的 y 坐标。 33 | 34 | ### r 35 | __ 36 | 中心点的半径。 37 | 38 | ### symbol 39 | __ 40 | 41 | - 几何图形的类型,目前支持以下 5 种常见的几何图形: 42 | - `circle`: 圆形 43 | - `square`: 正方形 44 | - `diamond`: 菱形 45 | - `triangle`: 三角形 46 | - `triangle-down`: 倒三角形 -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Path.md: -------------------------------------------------------------------------------- 1 | # Path 2 | 3 | 4 | 5 | ## 组件使用 6 | [两种使用方式](/product/BizCharts4/category/61/page/181#使用方式) 7 | 8 | ## attrs属性 9 | 10 | 使用方式 11 | ```js 12 | 16 | ``` 17 | 18 | ### 通用属性 19 | [绘图属性](./169) 20 | 21 | ### path 22 | __ 23 | 24 | - 路径,支持 `字符串`和 `数组` 两种形式,详情可以参考 [SVG path](https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths)。 25 | - 字符串形式: `M 100,100 L 200,200` 26 | - 数组形式: `[ [ 'M', 100, 100 ], [ 'L', 200, 200 ] ]` 27 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Polygon.md: -------------------------------------------------------------------------------- 1 | # Polygon 2 | 3 | 4 | 5 | ## 组件使用 6 | [两种使用方式](/product/BizCharts4/category/61/page/181#使用方式) 7 | 8 | ## attrs属性 9 | 10 | 使用方式 11 | ```js 12 | 20 | ``` 21 | ### 通用属性 22 | [绘图属性](./169) 23 | 24 | ### points 25 | __ 26 | 形如 [ [ x1, y1 ], [ x2, y2 ], ... ] 的点集合。 -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Polyline.md: -------------------------------------------------------------------------------- 1 | # Polyline 2 | 3 | 4 | 5 | ## 组件使用 6 | [两种使用方式](/product/BizCharts4/category/61/page/181#使用方式) 7 | 8 | ## attrs属性 9 | 10 | 使用方式 11 | ```js 12 | 20 | ``` 21 | 22 | ### 通用属性 23 | [绘图属性](./169) 24 | 25 | ### points 26 | __ 27 | 形如 [ [ x1, y1 ], [ x2, y2 ], ... ] 的点集合。 -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Rect.md: -------------------------------------------------------------------------------- 1 | # Rect 2 | 3 | 4 | 5 | ## 组件使用 6 | [两种使用方式](/product/BizCharts4/category/61/page/181#使用方式) 7 | 8 | ## attrs属性 9 | 10 | 使用方式 11 | ```js 12 | 22 | ``` 23 | 24 | ### 通用属性 25 | [绘图属性](./169) 26 | 27 | ### x 28 | __ 29 | 起始点 x 坐标。 30 | 31 | ### y 32 | __ 33 | 起始点 y 坐标。 34 | 35 | ### width 36 | __ 37 | 宽度。 38 | 39 | ### height 40 | __ 41 | 高度。 42 | 43 | ### radius 44 | __ 45 | - 圆角,支持整数或数组形式, 分别对应左上、右上、右下、左下角的半径。支持的形式有: 46 | - `1`: 相当于 [ 1, 1, 1, 1 ] 47 | - `[ 1 ]`: 相当于 [ 1, 1, 1, 1 ] 48 | - `[ 1, 2 ]`: 相当于 [ 1, 2, 1, 2 ] 49 | - `[ 1, 2, 3 ]`: 相当于 [ 1, 2, 3, 2 ] 50 | - `[ 1, 2, 3, 4 ]` -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/G组件/Text.md: -------------------------------------------------------------------------------- 1 | # Text 2 | 3 | 4 | 5 | ## 组件使用 6 | [两种使用方式](/product/BizCharts4/category/61/page/181#使用方式) 7 | 8 | ## attrs属性 9 | 10 | 使用方式 11 | ```js 12 | 21 | ``` 22 | 23 | ### 通用属性 24 | [绘图属性](./169) 25 | 26 | ### x 27 | __ 28 | 文字的位置坐标 x。 29 | 30 | ### y 31 | __ 32 | 文字的位置坐标 y。 33 | 34 | ### text 35 | __ 36 | 显示文字。 37 | 38 | ### fontStyle 39 | __ 40 | 设置字体样式。 41 | 42 | ### fontVariant 43 | _<'normal' | 'small-caps' | string>_ 44 | 设置小型大写字母的字体显示文本,可选值'normal' | 'small-caps' 或字符串。 45 | 46 | ### fontWeight 47 | _<'normal' | 'bold' | 'bolder' | 'lighter' | number>_ 48 | 设置字体粗细,可选值'normal' | 'bold' | 'bolder' | 'lighter'或数值。 49 | 50 | ### fontSize 51 | __ 52 | 设置字体的尺寸。 53 | 54 | ### fontFamily 55 | __ 56 | 设置字体类型。 57 | 58 | ### textAlign 59 | __ 60 | - 设置文本内容的对齐方式, 支持的属性值有: 61 | - center 62 | - end 63 | - left 64 | - right 65 | - start 66 | 67 | ### textBaseline 68 | __ 69 | - 设置在绘制文本时使用的当前文本基线, 支持的属性值有: 70 | - top 71 | - middle 72 | - bottom -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/基础组件/Slider.md: -------------------------------------------------------------------------------- 1 | # Slider 2 | 3 | 当数据量过大的时候可使用缩略轴控制数据窗口。 4 | 5 | 注意:版本 >= 4.0.3 6 | 7 | 代码示例 8 | ``` 9 | import { Chart Slider Line } from 'bizcharts'; 10 | 11 | 12 | 13 | 14 | 15 | ``` 16 | 17 | 18 | 19 | ## API 20 | 21 | ### height 22 | __ 23 | - 描述:slider 高度 24 | 25 | ### trendCfg 26 | __ 27 | - 描述:滑块背景区域配置 28 | ```js 29 | { 30 | data: number[], // 背景图显示的数据 31 | smooth?: boolean, // 是否平滑 32 | isArea?: boolean, // 是否显示区域 33 | backgroundStyle?: object, // 背景图样式 34 | lineStyle?: object, // 线条样式 35 | areaStyle?: object, // 数据区域样式 36 | } 37 | ``` 38 | 39 | ### backgroundStyle 40 | __ 41 | - 描述:滑块背景样式 42 | 43 | ### foregroundStyle 44 | __ 45 | - 描述:滑块前景样式 46 | 47 | ### handlerStyle 48 | __ 49 | - 描述:滑块两个操作块样式 50 | 51 | ### textStyle 52 | __ 53 | - 描述:文本样式 54 | 55 | ### minLimit 56 | __ 57 | - 描述:允许滑动位置的最大值,0-1的数值。 58 | 59 | ### maxLimit 60 | __ 61 | - 描述:允许滑动位置的最小值, 0-1的数值。 62 | 63 | ### start 64 | __ 65 | - 描述:滑块初始化的起始位置, 0-1的数值。 66 | 67 | ### end 68 | __ 69 | - 描述:滑块初始化的结束位置, 0-1的数值。 70 | 71 | ### formatter 72 | __ 73 | - 描述:滑块初始和结束文本格式化。 74 | ```js 75 | formatter(val: any, datum: Datum, idx: number) => any; 76 | ``` 77 | 78 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/基础组件/View.md: -------------------------------------------------------------------------------- 1 | # View 2 | 3 | 视图,由 Chart 生成和管理,拥有自己独立的数据源、坐标系和图层,用于异构数据的可视化以及图表组合,一个 Chart 由一个或者多个视图 View 组成。因此 view 上的 api 同 chart 基本相同。 4 | 5 | * 在同一个容器中出现两个或者更多不同坐标系的图表时,可以采用View组件来实现,如多层饼图。 6 | * 在同一个容器中的两个图表需要采用不同的数据源时,如对比漏斗图。 7 | 8 | 9 | ## API 10 | 11 | ### region 12 | __ 13 | 14 | - 描述:绘制区域的范围,x和y的取值范围均为0到1。我们的起始点是从**左上角**开始的,终点为右下角。 15 | 16 | 参见: 17 | ```js 18 | 22 | ``` 23 | > 3.X的 start和end属性将在4.1后废弃。请使用region替代。 24 | 25 | ### data 26 | __ __ 27 | 28 | - 描述:使用同 `Chart` 的data属性。如果不配置则使用父级的Chart的data数据。 29 | 30 | 31 | ### scale 32 | __ 33 | 34 | - 描述:使用同 `Chart` 的 [scale 属性](77#scale)。 35 | 36 | 37 | ### padding 38 | 39 | - 描述:使用同 `Chart` 的 [padding 属性](77#padding)。 40 | 41 | ### animate 42 | __ 43 | - 描述:开启或者关闭动画。 44 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/扩展组件&Hooks/Effects.md: -------------------------------------------------------------------------------- 1 | # Effects 2 | 3 | BizCharts@4.0新添加了Effects组件,可以直接使用[G2的语法](https://g2.antv.vision/zh/docs/manual/about-g2)对chart对象进行配置,方便开发人员测试与扩展属性。 4 | 5 | 6 | ## API 7 | 8 | 传入方法的入参chart即为G2的chart对象。 9 | 10 | ```js 11 | 12 | {(chart) => { 13 | // 处理过滤器之后的数据 14 | chart.getData().forEach(() => { 15 | return 16 | }) 17 | }} 18 | 19 | ``` -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/扩展组件&Hooks/useChartInstance.md: -------------------------------------------------------------------------------- 1 | # useChartInstance 2 | 3 | 4 | 5 | 用于获得G2的chart实例的hooks。 6 | 图表可以有多个图层,每个图层都是一个图表, 由父级view.createView。rootChart 即指最顶层chart实例。 7 | g2 开放了许多开发者使用的api,详细请见: 8 | https://antv-g2.gitee.io/zh/docs/api/g2 9 | 10 | 使用案例 11 | 以下 12 | ```js 13 | 14 | function Slider(props: ISliderProps) { 15 | const chart = useChartInstance(); 16 | chart.option('slider', props); 17 | return null; 18 | } 19 | 20 | // 这样我们的一个简化的Slider组件就完成了。可以查看g2开发者文档,封装你自己的图表组件。 21 | // 使用 22 | 23 | 24 | 25 | 26 | 27 | ``` -------------------------------------------------------------------------------- /docs/BizCharts@4.x/API文档/扩展组件&Hooks/useView.md: -------------------------------------------------------------------------------- 1 | # useView 2 | 3 | 4 | 5 | 用于获取view对象的hooks。 -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/Interaction使用Demo(BizCharts@4.x).md: -------------------------------------------------------------------------------- 1 | # Interaction使用Demo(BizCharts@4.x) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/fa11d8a0-137f-11eb-85d9-95fcbab24c56.png) 4 | 5 | ```js 6 | import React from "react"; 7 | import { Chart, Interval, Interaction } from "bizcharts"; 8 | 9 | const data = [ 10 | { year: "1951 年", sales: 38 }, 11 | { year: "1952 年", sales: 52 }, 12 | { year: "1956 年", sales: 61 }, 13 | { year: "1957 年", sales: 45 }, 14 | { year: "1958 年", sales: 48 }, 15 | { year: "1959 年", sales: 38 }, 16 | { year: "1960 年", sales: 38 }, 17 | { year: "1962 年", sales: 38 }, 18 | ]; 19 | 20 | function Demo() { 21 | return ( 22 |
23 | 24 | 25 | 26 | 27 | 28 |
29 | ); 30 | } 31 | 32 | ReactDOM.render(, mountNode); 33 | 34 | ``` 35 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/PieChart使用Demo.md: -------------------------------------------------------------------------------- 1 | # PieChart使用Demo 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/9dafb180-0709-11ec-87eb-ffd7ec19ab6e.png) 4 | 5 | ```js 6 | import React from 'react'; 7 | import ReactDOM from 'react-dom'; 8 | import { PieChart } from 'bizcharts'; 9 | 10 | // 数据源 11 | const data = [ 12 | { 13 | type: '分类一', 14 | value: 27, 15 | }, 16 | { 17 | type: '分类二', 18 | value: 25, 19 | }, 20 | { 21 | type: '分类三', 22 | value: 18, 23 | }, 24 | { 25 | type: '分类四', 26 | value: 15, 27 | }, 28 | { 29 | type: '分类五', 30 | value: 10, 31 | }, 32 | { 33 | type: '其它', 34 | value: 5, 35 | }, 36 | ]; 37 | 38 | function Demo() { 39 | return ( 40 | `${v.type}\n${v.value}` 58 | }} 59 | /> 60 | ); 61 | } 62 | 63 | ReactDOM.render(, mountNode); 64 | ``` 65 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/Style样式配置.md: -------------------------------------------------------------------------------- 1 | # Style样式配置 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/c80d0020-1387-11eb-a381-f150021acaf9.png) 4 | 5 | ```js 6 | import { Chart, Interval } from 'bizcharts'; 7 | 8 | const data = [ 9 | { year: '1951 年', sales: 38 }, 10 | { year: '1952 年', sales: 52 }, 11 | { year: '1956 年', sales: 61 }, 12 | { year: '1957 年', sales: 45 }, 13 | { year: '1958 年', sales: 48 }, 14 | { year: '1959 年', sales: 38 }, 15 | { year: '1960 年', sales: 38 }, 16 | { year: '1962 年', sales: 38 }, 17 | ]; 18 | 19 | 20 | function Demo() { 21 | return 22 | { 28 | return { 29 | content: val, 30 | style: { 31 | fill: 'red', 32 | fontSize: 18, 33 | fontWeight: 'bold', 34 | }, 35 | }; 36 | }, 37 | ]} 38 | /> 39 | 40 | } 41 | 42 | ReactDOM.render(, mountNode); 43 | ``` 44 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/区间柱状图(BizCharts@4).md: -------------------------------------------------------------------------------- 1 | # 区间柱状图(BizCharts@4) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/ba375f10-bb0e-11ec-9fda-8da6a31bb9f4.png) 4 | 5 | ```js 6 | import React from "react"; 7 | import { 8 | Chart, 9 | Interval, 10 | Coord, 11 | Interaction 12 | } from "bizcharts"; 13 | 14 | class Columnrange extends React.Component { 15 | render() { 16 | const data = [ 17 | { 18 | x: "分类一", 19 | y: [26, 50] 20 | }, 21 | { 22 | x: "分类一", 23 | y: [76, 100] 24 | }, 25 | { 26 | x: "分类二", 27 | y: [56, 108] 28 | }, 29 | { 30 | x: "分类三", 31 | y: [38, 129] 32 | }, 33 | { 34 | x: "分类四", 35 | y: [58, 155] 36 | }, 37 | { 38 | x: "分类五", 39 | y: [45, 120] 40 | }, 41 | { 42 | x: "分类六", 43 | y: [23, 99] 44 | }, 45 | { 46 | x: "分类七", 47 | y: [18, 56] 48 | }, 49 | { 50 | x: "分类八", 51 | y: [18, 34] 52 | } 53 | ]; 54 | return ( 55 | <> 56 |
57 | 58 | 59 | 60 | 61 | 62 |
63 | 64 | 65 | 66 | 67 | ); 68 | } 69 | } 70 | 71 | ReactDOM.render(, mountNode) 72 | ``` 73 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/可缩放的散点图.md: -------------------------------------------------------------------------------- 1 | # 可缩放的散点图 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/2845d2f0-e3c1-11eb-985f-8b0d2837a174.png) 4 | 5 | ```js 6 | import React, { useState, useEffect } from 'react'; 7 | import { 8 | Chart, 9 | Point, 10 | } from 'bizcharts'; 11 | 12 | let chartIns; 13 | function Demo() { 14 | const [data, setData] = useState(); 15 | useEffect(() => { 16 | fetch('https://alifd.alibabausercontent.com/materials/@bizcharts/point-scatter/0.2.8/mock.json') 17 | .then(res => res.json()) 18 | .then(data => { 19 | console.log(data) 20 | setData(data); 21 | }) 22 | }, []) 23 | 24 | return <> 25 | 26 | { 32 | chartIns = c; 33 | c.on('beforepaint', () => { 34 | // 获取框选出来的数据 35 | console.log(c.filteredData) 36 | }) 37 | c.interaction('view-zoom'); 38 | 39 | // 阻止默认事件,否则会整个窗口滚动 40 | c.getCanvas().on('mousewheel', ev => { ev.preventDefault(); }) 41 | 42 | })} 43 | > 44 | 51 | 52 | 55 | 56 | } 57 | 58 | ReactDOM.render(, mountNode); 59 | ``` 60 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/图表标题(BizChart@4).md: -------------------------------------------------------------------------------- 1 | # 图表标题(BizChart@4) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/8a43f3d0-d623-11ea-a29f-815c67f294bf.png) 4 | 5 | ```js 6 | import { Chart, Interval } from 'bizcharts'; 7 | 8 | const data = [ 9 | { year: '1951 年', sales: 38 }, 10 | { year: '1952 年', sales: 52 }, 11 | { year: '1956 年', sales: 61 }, 12 | { year: '1957 年', sales: 45 }, 13 | { year: '1958 年', sales: 48 }, 14 | { year: '1959 年', sales: 38 }, 15 | { year: '1960 年', sales: 38 }, 16 | { year: '1962 年', sales: 38 }, 17 | ]; 18 | 19 | 20 | function Demo() { 21 | return <> 22 |

xx品牌历年商品销售数据

23 |
数据统计来源为mock的数据(万元)
24 | 25 | 26 | 27 | 28 | } 29 | 30 | ReactDOM.render(, mountNode); 31 | ``` 32 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/基础散点图(BizCharts@4).md: -------------------------------------------------------------------------------- 1 | # 基础散点图(BizCharts@4) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/ce1e85e0-54b6-11eb-8f83-8fe238d8e233.png) 4 | 5 | ```js 6 | import React, { useState, useEffect } from 'react'; 7 | import { 8 | Chart, 9 | Point, 10 | } from 'bizcharts'; 11 | 12 | let chartIns; 13 | function Demo() { 14 | const [data, setData] = useState(); 15 | useEffect(() => { 16 | fetch('https://alifd.alibabausercontent.com/materials/@bizcharts/point-scatter/0.2.8/mock.json') 17 | .then(res => res.json()) 18 | .then(data => { 19 | console.log(data) 20 | setData(data); 21 | }) 22 | }, []) 23 | 24 | return <> 25 | 26 | { 32 | chartIns = c; 33 | c.on('beforepaint', () => { 34 | // 获取框选出来的数据 35 | console.log(c.filteredData) 36 | }) 37 | })} 38 | > 39 | 46 | 47 | 50 | 51 | } 52 | 53 | ReactDOM.render(, mountNode); 54 | ``` 55 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/基础条形图(BizCharts@4).md: -------------------------------------------------------------------------------- 1 | # 基础条形图(BizCharts@4) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/08735400-613c-11eb-b6ac-c11ccf54cc02.png) 4 | 5 | ```js 6 | import React from "react"; 7 | import { 8 | G2, 9 | Chart, 10 | Geom, 11 | Axis, 12 | Tooltip, 13 | Coordinate, 14 | Label, 15 | Legend, 16 | Interval, 17 | Util 18 | } from "bizcharts"; 19 | 20 | class Basic extends React.Component { 21 | render() { 22 | const data = [ 23 | { 24 | country: "中国", 25 | population: 131744 26 | }, 27 | { 28 | country: "印度", 29 | population: 104970 30 | }, 31 | { 32 | country: "美国", 33 | population: 29034 34 | }, 35 | { 36 | country: "印尼", 37 | population: 23489 38 | }, 39 | { 40 | country: "巴西", 41 | population: 18203 42 | } 43 | ]; 44 | data.sort((a, b) => a.population - b.population) 45 | return ( 46 | 47 | 48 | 49 | 50 | ); 51 | } 52 | } 53 | 54 | ReactDOM.render(, mountNode) 55 | 56 | ``` 57 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/基础柱状图(BizCharts@4).md: -------------------------------------------------------------------------------- 1 | # 基础柱状图(BizCharts@4) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/e0ec3350-9979-11ea-8225-e30c1937e15c.png) 4 | 5 | ```js 6 | import { Chart, Interval, Tooltip } from 'bizcharts'; 7 | 8 | const data = [ 9 | { year: '1951 年', sales: 38 }, 10 | { year: '1952 年', sales: 52 }, 11 | { year: '1956 年', sales: 61 }, 12 | { year: '1957 年', sales: 45 }, 13 | { year: '1958 年', sales: 48 }, 14 | { year: '1959 年', sales: 38 }, 15 | { year: '1960 年', sales: 38 }, 16 | { year: '1962 年', sales: 38 }, 17 | ]; 18 | 19 | 20 | function Demo() { 21 | return 22 | 23 | 24 | 25 | } 26 | 27 | ReactDOM.render(, mountNode); 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/基础柱状图(Interval).md: -------------------------------------------------------------------------------- 1 | # 基础柱状图(Interval) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/b0b31880-5690-11ed-bfcb-853eef9a9748.png) 4 | 5 | ```js 6 | import { Chart, Interval, Tooltip, getTheme } from 'bizcharts'; 7 | 8 | const data = [ 9 | { year: '1951 年', sales: 0 }, 10 | { year: '1952 年', sales: 52 }, 11 | { year: '1956 年', sales: 61 }, 12 | { year: '1957 年', sales: 45 }, 13 | { year: '1958 年', sales: 48 }, 14 | { year: '1959 年', sales: 38 }, 15 | { year: '1960 年', sales: 38 }, 16 | { year: '1962 年', sales: 38 }, 17 | ]; 18 | 19 | 20 | function Demo() { 21 | return 22 | 23 | 24 | 25 | } 26 | 27 | ReactDOM.render(, mountNode); 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/基础点图(Point).md: -------------------------------------------------------------------------------- 1 | # 基础点图(Point) 2 | 3 | ![预览](https://z.alicdn.com/alickn/chu-ko-no/2020-4-28/bizcharts/427633e8-bcab-43db-aec5-450bbd412138/427633e8-bcab-43db-aec5-450bbd412138.png) 4 | 5 | ```js 6 | import { Chart, Point } from 'bizcharts'; 7 | 8 | const data = [ 9 | { year: '1951 年', sales: 38 }, 10 | { year: '1952 年', sales: 52 }, 11 | { year: '1956 年', sales: 61 }, 12 | { year: '1957 年', sales: 45 }, 13 | { year: '1958 年', sales: 48 }, 14 | { year: '1959 年', sales: 38 }, 15 | { year: '1960 年', sales: 38 }, 16 | { year: '1962 年', sales: 38 }, 17 | ]; 18 | 19 | 20 | function Demo() { 21 | return 22 | 23 | 24 | } 25 | 26 | ReactDOM.render(, mountNode); 27 | ``` 28 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/基础面积图(BizCharts@4).md: -------------------------------------------------------------------------------- 1 | # 基础面积图(BizCharts@4) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/ada284d0-a82c-11ed-adea-01ad76f1a13d.png) 4 | 5 | ```js 6 | import React from 'react'; 7 | import { 8 | Chart, 9 | Area, 10 | Line, 11 | Tooltip, 12 | Axis, 13 | Coordinate 14 | } from 'bizcharts'; 15 | 16 | function Labelline () { 17 | const data = [ 18 | { year: '1991', value: 15468 }, 19 | { year: '1992', value: 16100 }, 20 | { year: '1993', value: 15900 }, 21 | { year: '1994', value: 17409 }, 22 | { year: '1995', value: 17000 }, 23 | { year: '1996', value: 31056 }, 24 | { year: '1997', value: 31982 }, 25 | { year: '1998', value: 32040 }, 26 | { year: '1999', value: 33233 }, 27 | ]; 28 | 29 | const scale = { 30 | value: { 31 | min: 10000, 32 | nice: true, 33 | }, 34 | year: { 35 | range: [0, 1], 36 | }, 37 | }; 38 | 39 | return ( 40 | 41 | 42 | 43 | 44 | 45 | ); 46 | } 47 | 48 | ReactDOM.render(, mountNode); 49 | 50 | ``` 51 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/基础面积图(Area).md: -------------------------------------------------------------------------------- 1 | # 基础面积图(Area) 2 | 3 | ![预览](https://z.alicdn.com/alickn/chu-ko-no/2020-4-29/bizcharts/1e5066f9-0846-4ba6-8651-ad7b21c1b2ee/1e5066f9-0846-4ba6-8651-ad7b21c1b2ee.png) 4 | 5 | ```js 6 | import React from 'react'; 7 | import { 8 | Chart, 9 | Area, 10 | } from 'bizcharts'; 11 | 12 | function Labelline () { 13 | const data = [ 14 | { year: '1991', value: 15468 }, 15 | { year: '1992', value: 16100 }, 16 | { year: '1993', value: 15900 }, 17 | { year: '1994', value: 17409 }, 18 | { year: '1995', value: 17000 }, 19 | { year: '1996', value: 21056 }, 20 | { year: '1997', value: 31982 }, 21 | { year: '1998', value: 32040 }, 22 | { year: '1999', value: 33233 }, 23 | ]; 24 | 25 | const scale = { 26 | value: { 27 | min: 10000, 28 | nice: true, 29 | }, 30 | year: { 31 | range: [0, 1], 32 | }, 33 | }; 34 | 35 | return ( 36 | 37 | 38 | 39 | ); 40 | } 41 | 42 | ReactDOM.render(, mountNode); 43 | 44 | ``` 45 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/堆叠面积图(BizCharts@4).md: -------------------------------------------------------------------------------- 1 | # 堆叠面积图(BizCharts@4) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/be2bb9c0-bc22-11ed-adb7-c3b290dea37c.png) 4 | 5 | ```js 6 | import React from 'react'; 7 | import { 8 | Chart, 9 | Area, 10 | Line, 11 | Tooltip, 12 | Axis, 13 | Coordinate 14 | } from 'bizcharts'; 15 | 16 | function Labelline () { 17 | 18 | const data = [ 19 | { a: '1', asd: 'Asia', year: '1750', value: 502 }, 20 | { a: '1', asd: 'Asia', year: '1800', value: 635 }, 21 | { a: '1', asd: 'Asia', year: '1850', value: 809 }, 22 | { a: '1', asd: 'Asia', year: '1900', value: 5268 }, 23 | { a: '1', asd: 'Asia', year: '1950', value: 4400 }, 24 | { a: '1', asd: 'Asia', year: '1999', value: 3634 }, 25 | { a: '1', asd: 'Asia', year: '2050', value: 947 }, 26 | ]; 27 | 28 | const scale = { 29 | value: { 30 | // nice: true, 31 | }, 32 | year: { 33 | type: 'linear', 34 | // tickInterval: 50, 35 | }, 36 | }; 37 | 38 | return ( 39 | 40 | 41 | 42 | ); 43 | } 44 | 45 | ReactDOM.render(, mountNode); 46 | 47 | ``` 48 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/多形状散点图(BizCharts@4).md: -------------------------------------------------------------------------------- 1 | # 多形状散点图(BizCharts@4) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/8195eab0-afa2-11ea-8765-9d54391a91b0.png) 4 | 5 | ```js 6 | import React, { useState, useEffect } from 'react'; 7 | import { 8 | Chart, 9 | Point, 10 | } from 'bizcharts'; 11 | 12 | 13 | function Demo() { 14 | const [data, setData] = useState(); 15 | useEffect(() => { 16 | fetch('https://alifd.alibabausercontent.com/materials/@bizcharts/point-scatter/0.2.8/mock.json') 17 | .then(res => res.json()) 18 | .then(data => { 19 | console.log(data) 20 | setData(data); 21 | }) 22 | }, []) 23 | 24 | return 30 | 37 | 38 | } 39 | 40 | ReactDOM.render(, mountNode); 41 | ``` 42 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/控制透明色.md: -------------------------------------------------------------------------------- 1 | # 控制透明色 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/1457b6b0-28e4-11ec-83ce-e72692133a50.png) 4 | 5 | ```js 6 | import { Chart, Interval ,Interaction} from 'bizcharts'; 7 | 8 | const data = [ 9 | { year: '1951 年', sales: 38 }, 10 | { year: '1952 年', sales: 52 }, 11 | { year: '1956 年', sales: 61 }, 12 | { year: '1957 年', sales: 45 }, 13 | { year: '1958 年', sales: 48 }, 14 | { year: '1959 年', sales: 38 }, 15 | { year: '1960 年', sales: 38 }, 16 | { year: '1962 年', sales: 38 }, 17 | ]; 18 | 19 | 20 | function Demo() { 21 | return 22 | { 24 | return { 25 | lineWidth: 1, 26 | strokeOpacity: 1, 27 | fillOpacity: 0.3, 28 | opacity: 0.65, 29 | // stroke: colorMap[val], 30 | }; 31 | }]}/> 32 | 33 | 34 | } 35 | 36 | ReactDOM.render(, mountNode); 37 | ``` 38 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/普通折线图(BizCharts@4).md: -------------------------------------------------------------------------------- 1 | # 普通折线图(BizCharts@4) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/cae41c20-c168-11ed-9ffc-9b1edf6ed16c.png) 4 | 5 | ```js 6 | import React from "react"; 7 | import ReactDOM from "react-dom"; 8 | import { Chart, Line, Point, Tooltip,getTheme } from "bizcharts"; 9 | 10 | console.log(getTheme()) 11 | 12 | // 数据源 13 | const data = [ 14 | { 15 | year: "1991", 16 | value: 3, 17 | }, 18 | { 19 | year: "1992", 20 | value: 4, 21 | }, 22 | { 23 | year: "1993", 24 | value: 3.5, 25 | }, 26 | { 27 | year: "1994", 28 | value: 5, 29 | }, 30 | { 31 | year: "1995", 32 | value: 4.9, 33 | }, 34 | { 35 | year: "1996", 36 | value: 6, 37 | }, 38 | { 39 | year: "1997", 40 | value: 7, 41 | }, 42 | { 43 | year: "1998", 44 | value: 9, 45 | }, 46 | { 47 | year: "1999", 48 | value: 13, 49 | }, 50 | ]; 51 | 52 | function Demo() { 53 | 54 | return ( 55 | <> 56 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | ); 71 | } 72 | 73 | ReactDOM.render(, mountNode); 74 | 75 | ``` 76 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/柱状图背景常亮.md: -------------------------------------------------------------------------------- 1 | # 柱状图背景常亮 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/2489aba0-3093-11eb-9199-e520dbc463c0.png) 4 | 5 | ```js 6 | import { Chart, Interval, Interaction, registerInteraction } from 'bizcharts'; 7 | 8 | const data = [ 9 | { year: '1951 年', sales: 38 }, 10 | { year: '1952 年', sales: 52 }, 11 | { year: '1956 年', sales: 61 }, 12 | { year: '1957 年', sales: 45 }, 13 | { year: '1958 年', sales: 48 }, 14 | { year: '1959 年', sales: 38 }, 15 | { year: '1960 年', sales: 38 }, 16 | { year: '1962 年', sales: 38 }, 17 | ]; 18 | 19 | // 鼠标单击选中,双击取消 20 | registerInteraction('click-active-region',{ 21 | start: [{ trigger: 'plot:click', action: 'active-region:show' }], 22 | end: [{ trigger: 'plot:dblclick', action: 'active-region:hide' }], 23 | }) 24 | 25 | 26 | function Demo() { 27 | return 28 | 29 | 30 | 31 | } 32 | 33 | ReactDOM.render(, mountNode); 34 | ``` 35 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/柱状图鼠标hover样式.md: -------------------------------------------------------------------------------- 1 | # 柱状图鼠标hover样式 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/b14984f0-fbb1-11ea-a381-f150021acaf9.png) 4 | 5 | ```js 6 | import { Chart, Interval, Tooltip, registerInteraction } from "bizcharts"; 7 | 8 | registerInteraction("element-cursor-pointer", { 9 | start: [ 10 | { 11 | trigger: "interval:mouseenter", 12 | action: (ctx) => { 13 | ctx.view.canvas.setCursor("pointer"); 14 | }, 15 | }, 16 | ], 17 | end: [ 18 | { 19 | trigger: "interval:mouseleave", 20 | action: (ctx) => { 21 | ctx.view.canvas.setCursor("default"); 22 | }, 23 | }, 24 | ], 25 | }); 26 | 27 | const data = [ 28 | { year: "1951 年", sales: 38 }, 29 | { year: "1952 年", sales: 52 }, 30 | { year: "1956 年", sales: 61 }, 31 | { year: "1957 年", sales: 45 }, 32 | { year: "1958 年", sales: 48 }, 33 | { year: "1959 年", sales: 38 }, 34 | { year: "1960 年", sales: 38 }, 35 | { year: "1962 年", sales: 38 }, 36 | ]; 37 | 38 | function Demo() { 39 | return ( 40 | 47 | 54 | 55 | 56 | ); 57 | } 58 | 59 | ReactDOM.render(, mountNode); 60 | 61 | ``` 62 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/渐变色折线图(BizCharts@4).md: -------------------------------------------------------------------------------- 1 | # 渐变色折线图(BizCharts@4) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/325f2160-aecf-11ea-b974-bdbc104e7053.png) 4 | 5 | ```js 6 | import React from 'react'; 7 | import ReactDOM from 'react-dom'; 8 | import { Chart, Line, Point } from 'bizcharts'; 9 | 10 | // 数据源 11 | const data = [ 12 | { month: "2015-01-01", acc: 84.0 }, 13 | { month: "2015-02-01", acc: 14.9 }, 14 | { month: "2015-03-01", acc: 17.0 }, 15 | { month: "2015-04-01", acc: 20.2 }, 16 | { month: "2015-05-01", acc: 55.6 }, 17 | { month: "2015-06-01", acc: 56.7 }, 18 | { month: "2015-07-01", acc: 30.6 }, 19 | { month: "2015-08-01", acc: 63.2 }, 20 | { month: "2015-09-01", acc: 24.6 }, 21 | { month: "2015-10-01", acc: 14.0 }, 22 | { month: "2015-11-01", acc: 9.4 }, 23 | { month: "2015-12-01", acc: 7.3 } 24 | ]; 25 | 26 | function Demo() { 27 | return 28 | 33 | 34 | } 35 | 36 | 37 | 38 | ReactDOM.render(, mountNode); 39 | 40 | 41 | 42 | ``` 43 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/环图 pieStyle 样式问题.md: -------------------------------------------------------------------------------- 1 | # 环图 pieStyle 样式问题 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/35db1d40-604e-11eb-b6ac-c11ccf54cc02.png) 4 | 5 | ```js 6 | import React from "react"; 7 | import ReactDOM from "react-dom"; 8 | import { DonutChart } from "bizcharts"; 9 | 10 | // 数据源 11 | const data = [ 12 | { 13 | type: "分类一", 14 | value: 27, 15 | }, 16 | { 17 | type: "分类二", 18 | value: 25, 19 | }, 20 | { 21 | type: "分类三", 22 | value: 18, 23 | }, 24 | { 25 | type: "分类四", 26 | value: 15, 27 | }, 28 | { 29 | type: "分类五", 30 | value: 10, 31 | }, 32 | { 33 | type: "其它", 34 | value: 5, 35 | }, 36 | ]; 37 | 38 | function Demo() { 39 | return ( 40 | 58 | ); 59 | } 60 | 61 | ReactDOM.render(, mountNode); 62 | 63 | ``` 64 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/禁止lable自动隐藏和旋转.md: -------------------------------------------------------------------------------- 1 | # 禁止lable自动隐藏和旋转 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/59e82530-0ad5-11eb-be8d-5d0fe3d00eda.png) 4 | 5 | ```js 6 | import { Chart, Interval, Axis } from 'bizcharts'; 7 | 8 | const data = [ 9 | { year: '1951 年sdasadsa', sales: 38 }, 10 | { year: '1952 年', sales: 52 }, 11 | { year: '1956 年', sales: 61 }, 12 | { year: '1957 年', sales: 45 }, 13 | { year: '1958 年', sales: 48 }, 14 | { year: '1959 年', sales: 38 }, 15 | { year: '1960 年', sales: 38 }, 16 | { year: '1962 年', sales: 38 }, 17 | ]; 18 | 19 | 20 | function Demo() { 21 | return 22 | 23 | 24 | 25 | } 26 | 27 | ReactDOM.render(, mountNode); 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/自定义active-region背景色.md: -------------------------------------------------------------------------------- 1 | # 自定义active-region背景色 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/dd3c82d0-ee1f-11ec-9d77-d97c57b5a660.png) 4 | 5 | ```js 6 | import { Chart, Interval, Tooltip, Interaction, registerInteraction } from 'bizcharts'; 7 | 8 | 9 | // 自定义背景框交互背景色 10 | registerInteraction('active-region1', { 11 | start: [{ trigger: 'plot:mousemove', action: 'active-region:show', arg: { style: { fill: 'rgba(0,0,0,0.1)' } } }], 12 | end: [{ trigger: 'plot:mouseleave', action: 'active-region:hide' }], 13 | }); 14 | 15 | const data = [ 16 | { year: '1951 年', sales: 0 }, 17 | { year: '1952 年', sales: 52 }, 18 | { year: '1956 年', sales: 61 }, 19 | { year: '1957 年', sales: 45 }, 20 | { year: '1958 年', sales: 48 }, 21 | { year: '1959 年', sales: 38 }, 22 | { year: '1960 年', sales: 38 }, 23 | { year: '1962 年', sales: 38 }, 24 | ]; 25 | 26 | 27 | function Demo() { 28 | return 29 | 30 | 31 | 32 | 33 | } 34 | 35 | ReactDOM.render(, mountNode); 36 | ``` 37 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/自定义主题(bizcharts@4.x).md: -------------------------------------------------------------------------------- 1 | # 自定义主题(bizcharts@4.x) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/83780700-9a3f-11ea-9070-eb4779ccbd10.png) 4 | 5 | ```js 6 | import { Chart, Interval,useTheme,registerTheme,getTheme } from 'bizcharts'; 7 | // 注册自己的主题 8 | registerTheme('my-theme',{ 9 | defaultColor:'#6DC8EC', 10 | geometries: { 11 | interval: { 12 | rect: { 13 | default: { style: { fill: '#6DC8EC', fillOpacity: 0.95 } }, 14 | active: { style: { stroke: '#5AD8A6', lineWidth: 1 } }, 15 | inactive: { style: { fillOpacity: 0.3, strokeOpacity: 0.3 } }, 16 | selected: {}, 17 | }}} 18 | }) 19 | 20 | const data = [ 21 | { year: '1951 年', sales: 38 }, 22 | { year: '1952 年', sales: 52 }, 23 | { year: '1956 年', sales: 61 }, 24 | { year: '1957 年', sales: 45 }, 25 | { year: '1958 年', sales: 48 }, 26 | { year: '1959 年', sales: 38 }, 27 | { year: '1960 年', sales: 38 }, 28 | { year: '1962 年', sales: 38 }, 29 | ]; 30 | 31 | 32 | function Demo() { 33 | const [theme,setTheme] = useTheme('my-theme'); 34 | // 不清楚主题属性有哪些,可以log出来看一下 35 | console.log(getTheme('default')); 36 | return 37 | 38 | 39 | } 40 | 41 | ReactDOM.render(, mountNode); 42 | ``` 43 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/自定义柱状图hover背景色.md: -------------------------------------------------------------------------------- 1 | # 自定义柱状图hover背景色 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/bbf58770-ee1f-11ec-ac99-4d7af411ab38.png) 4 | 5 | ```js 6 | import { Chart, Interval, Tooltip } from 'bizcharts'; 7 | 8 | const data = [ 9 | { year: '1951 年', sales: 0 }, 10 | { year: '1952 年', sales: 52 }, 11 | { year: '1956 年', sales: 61 }, 12 | { year: '1957 年', sales: 45 }, 13 | { year: '1958 年', sales: 48 }, 14 | { year: '1959 年', sales: 38 }, 15 | { year: '1960 年', sales: 38 }, 16 | { year: '1962 年', sales: 38 }, 17 | ]; 18 | 19 | 20 | function Demo() { 21 | return { 22 | chart.interaction('active-region', { 23 | start: [{ trigger: 'plot:mousemove', action: 'active-region:show', arg: { style: { fill: 'pink' } } }], 24 | }); 25 | }} > 26 | 27 | 28 | 29 | } 30 | 31 | ReactDOM.render(, mountNode); 32 | ``` 33 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/Demo/雷达图(Line组件).md: -------------------------------------------------------------------------------- 1 | # 雷达图(Line组件) 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/7a645280-fd0d-11ec-b1fe-a12eaefd567e.png) 4 | 5 | ```js 6 | import React, { useState, useEffect } from 'react'; 7 | import { 8 | Chart, 9 | Point, 10 | Line, 11 | Tooltip, 12 | Coordinate 13 | } from 'bizcharts'; 14 | import DataSet from '@antv/data-set'; 15 | 16 | const data = [ 17 | { item: 'Design', value: 70 }, 18 | { item: 'Development', value: 60 }, 19 | { item: 'Marketing', value: 50 }, 20 | { item: 'Users', value: 40 }, 21 | { item: 'Test', value: 60 }, 22 | { item: 'Language', value: 70 }, 23 | { item: 'Technology', value: 50 }, 24 | { item: 'Support', value: 30 }, 25 | { item: 'Sales', value: 60 }, 26 | { item: 'UX', value: 50 }, 27 | ]; 28 | 29 | function Demo() { 30 | return 42 | 43 | 47 | 48 | } 49 | 50 | ReactDOM.render(, mountNode); 51 | ``` 52 | -------------------------------------------------------------------------------- /docs/BizCharts@4.x/使用指南/基础教程/GComponent的使用介绍.md: -------------------------------------------------------------------------------- 1 | # GComponent的使用介绍 2 | 3 | G组件是一款易用、高效、强大的 2D 可视化渲染引擎,提供 Canvas、SVG 等多种渲染方式的实现。 4 | 5 | ## 特性 6 | 7 | - 强大、可扩展的渲染能力,并内置常用的基础图形。 8 | - 极致的渲染性能,支持大数据量的可视化场景。 9 | - 完整模拟浏览器 DOM 的事件,与原生事件的表现无差异。 10 | - 流畅的动画实现,以及丰富的配置接口。 11 | - 同时提供了基于 Canvas 和 SVG 两种渲染技术的实现: 12 | - [g-canvas](https://www.npmjs.com/package/@antv/g-canvas):Canvas 版本的实现,是性能最优的一个 2D 渲染版本。 13 | - [g-svg](https://www.npmjs.com/package/@antv/g-svg): SVG 版本的实现,提供一些 SVG 的特性。 14 | - 这两个版本除了各自支持的一些特性外,对外 API 均保持一致。两者在使用层面的差异性主要在于: 15 | - g-canvas: 16 | - 支持局部渲染/全局渲染的切换。 17 | - 支持自动渲染/手动渲染的切换。 18 | - g-svg: 19 | - 支持 CSS 20 | - 支持嵌入 HTML 21 | 22 | ## 使用方式 23 | 24 | 解构使用 25 | ```js 26 | import { GComponents } from 'bizcharts'; 27 | const { Canvas, Ellipse } = GComponents; 28 | ``` 29 | 也可按需使用 30 | ```js 31 | import Canvas from "bizcharts/g-components/Canvas"; 32 | import Ellipse from "bizcharts/g-components/Ellipse"; 33 | ``` 34 | 35 | 36 | 37 | ## 组件API 38 | [详细组件](/product/BizCharts4/category/62/page/166) -------------------------------------------------------------------------------- /docs/BizCharts@4.x/使用指南/开发者教程/自定义图形.md: -------------------------------------------------------------------------------- 1 | # 自定义图形 2 | 3 | 4 | 5 | > 自定义图形可以实现业务中的特定设计 6 | 7 | ## 使用示例 8 | ```js 9 | import { registerShape } from 'bizcharts'; 10 | 11 | // 往 interval 几何标记上注册名为 'line' 的 shape 12 | registerShape('interval', 'line', { 13 | // 定义 line 的关键点 14 | getPoints(shapePoint: ShapePoint) { 15 | return getLinePoints(shapePoint); 16 | }, 17 | // 图形具体的绘制代码 18 | draw(cfg: ShapeInfo, container: IGroup) { 19 | const style = getStyle(cfg, true, false, 'lineWidth'); 20 | const path = this.parsePath(getRectPath(cfg.points)); 21 | const shape = container.addShape('path', { 22 | attrs: { 23 | ...style, 24 | path, 25 | }, 26 | name: 'interval', 27 | }); 28 | 29 | return shape; 30 | }, 31 | // 定义图形的缩略图样式 32 | getMarker(markerCfg: ShapeMarkerCfg) { 33 | const { color } = markerCfg; 34 | return { 35 | symbol: (x: number, y: number, r: number) => { 36 | return [ 37 | ['M', x, y - r], 38 | ['L', x, y + r], 39 | ]; 40 | }, 41 | style: { 42 | r: 5, 43 | stroke: color, 44 | }, 45 | }; 46 | }, 47 | }); 48 | 49 | ``` 50 | 51 | ## 按需使用的引入方式 52 | 53 | ```js 54 | import { registerShape } from 'bizcharts/lib/core'; 55 | ``` -------------------------------------------------------------------------------- /docs/BizGoblin/API文档/Coord.md: -------------------------------------------------------------------------------- 1 | # Coord 2 | 3 | 4 | 5 | 6 | 7 | 两种位置标度结合在一起组成的坐标轴配置,将Coord抽离为一个单独的组件,并且包含两种类型坐标系极坐标系和笛卡尔坐标系。 8 | 9 | ## 使用说明 10 | ### 父组件 11 | - [``](47) 12 | 13 | ### 子组件 14 | - none 15 | 16 | ### 注意事项 17 | 18 | - 默认采用笛卡尔坐标系,若要改变坐标系可以通过 `type` 属性改变。 19 | - 极坐标默认的起始角度和结束角度如下图所示: 20 | 21 | 22 | 23 | ## API 24 | 25 | ### type 26 | * 类型:String 27 | * 描述:坐标系类型,不同类型的坐标系所支持的配置属性也不一样。可设置的值为 `rect` , `polar‘` 。默认 `rect` 直角坐标系。 28 | 29 | ### transposed 30 | * 类型:Boolean 31 | * 描述:坐标系是否发生转置,`true` 表示发生了转置。默认 `false`。 32 | 33 | ### radius 34 | * 类型:Number 35 | * 描述:极坐标的前提下,设置圆的半径,相对值,0 至 1 范围。 36 | 37 | ### innerRadius 38 | * 类型:Number 39 | * 描述:极坐标的前提下, 绘制环图时,设置内部空心半径,相对值,0 至 1 范围。 40 | 41 | ### startAngle 42 | * 类型:Number 43 | * 描述:极坐标的起始角度,弧度制。 44 | 45 | ### endAngle 46 | * 类型:Number 47 | * 描述:极坐标的结束角度,弧度制。 48 | -------------------------------------------------------------------------------- /docs/BizGoblin/Demo/bizgoblin玫瑰图.md: -------------------------------------------------------------------------------- 1 | # bizgoblin玫瑰图 2 | 3 | ![预览](http://bizcharts-resource.oss-cn-zhangjiakou.aliyuncs.com/images/096f2440-997a-11ea-9761-adf4e02ffa04.png) 4 | 5 | ```js 6 | // data-set 可以按需引入,除此之外不要引入别的包 7 | import React from 'react'; 8 | import { Chart, Coord, Legend, Geom } from 'bizgoblin'; 9 | 10 | // 下面的代码会被作为 cdn script 注入 注释勿删 11 | // CDN START 12 | const pixelRatio = window.devicePixelRatio * 2; 13 | 14 | const data = [{ 15 | year: '2001', 16 | population: 41.8, 17 | }, { 18 | year: '2002', 19 | population: 25.8, 20 | }, { 21 | year: '2003', 22 | population: 31.7, 23 | }, { 24 | year: '2004', 25 | population: 46, 26 | }, { 27 | year: '2005', 28 | population: 28, 29 | }]; 30 | 31 | class Demo extends React.Component { 32 | render() { 33 | return ( 34 | 35 | 36 | 37 | 38 | 39 | ); 40 | } 41 | } 42 | 43 | // CDN END 44 | ReactDOM.render(, mountNode) 45 | 46 | ``` 47 | -------------------------------------------------------------------------------- /docs/BizGoblin/使用指南/图表介绍.md: -------------------------------------------------------------------------------- 1 | # 图表介绍 2 | 3 | 4 | 5 | 6 | 7 | ## 组件构成 8 | 在 BizGoblin 中,图表是由各个组件组合而成的。 9 | 10 | 图表组件有: 11 | 16 | | 名称 | 说明 | 17 | | :--- | :-- | 18 | | [Chart](../../45/page/47) | 图表组件,所有的其他组件都必须由 `` 包裹。 | 19 | | [Coord](../../45/page/48) | 坐标系组件。用来描述 `` 组件的坐标系,比如笛卡尔坐标系、极坐标系等。 | 20 | | [Axis](../../45/page/49) | 坐标轴组件。通常包含两个坐标轴,在笛卡尔坐标系下,分别为 x 轴和 y 轴,在极坐标轴下,则分别由角度和半径 2 个维度构成。每个坐标轴由坐标轴线(line)、刻度线(tickLine)、刻度文本(label)以及网格线(grid)组成。| 21 | | [Geom](../../45/page/50) | 几何标记组件。即我们所说的点、线、面这些几何图形。| 22 | | [Guide](../../45/page/51) | 辅助标记组件。| 23 | | [Legend](../../45/page/52) | 图例组件 | 24 | | [Tooltip](../../45/page/53) | 提示框组件。| 25 | 26 | ## 控件构成 27 | 下图所示为常用图表的各组件的空间构成。 28 | 29 | ![](https://cdn.yuque.com/lark/0/2018/png/49761/1530017962762-1ef72d25-5f0e-4ed3-b96a-7db98175fec1.png) 30 | -------------------------------------------------------------------------------- /docs/BizGoblin/使用指南/常见问题.md: -------------------------------------------------------------------------------- 1 | # 常见问题 2 | 3 | 4 | 5 | 6 | ## 有问题怎么办 7 | 8 | - 建议将所有问题相关的教程、api文档及相关的 demo 都看一遍,如果还有问题,欢迎提 [issue](https://github.com/alibaba/BizGoblin/issues) 9 | - issue 中请务必提供可复现的链接,方便排查问题。链接可以在 Codepen 中 fork [Bizcharts codepen template](https://codepen.io/leslie2014/pen/xjJGER) 后生成。 10 | - 使用过程中如果遇到问题无法自行解决,可扫码加入钉钉群群求帮助 11 | 12 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-unused-expressions */ 2 | const gulp = require('gulp'); 3 | const gutil = require('gulp-util'); 4 | const webpack = require('webpack'); 5 | const webpackConfig = require('./webpack.config'); 6 | 7 | function buildUmd(cb) { 8 | const compiler = webpack(webpackConfig, (err, stats) => { 9 | if (err) { 10 | gutil.log(err); 11 | } 12 | gutil.log( 13 | stats.toString({ 14 | colors: true, 15 | chunks: false, 16 | }), 17 | ); 18 | }); 19 | compiler.plugin('done', stats => { 20 | console.log(stats); 21 | if (stats.hasErrors()) { 22 | console.log( 23 | stats.toString({ 24 | colors: true, 25 | }), 26 | ); 27 | } 28 | cb && cb(); 29 | }); 30 | } 31 | 32 | exports.default = gulp.series(buildUmd); 33 | -------------------------------------------------------------------------------- /src/adapter/Guide.tsx: -------------------------------------------------------------------------------- 1 | // 兼容, 4.2 后删除 2 | import warn from 'warning'; 3 | 4 | // annotation G2暂不支持自定义组件。 5 | import Arc from '../components/Annotation/arc'; 6 | import DataMarker from '../components/Annotation/dataMarker'; 7 | import DataRegion from '../components/Annotation/dataRegion'; 8 | // import Html from '../components/Annotation/html'; 9 | import Image from '../components/Annotation/image'; 10 | import Line from '../components/Annotation/line'; 11 | import Region from '../components/Annotation/region'; 12 | import Text from '../components/Annotation/text'; 13 | 14 | const Guide = (props) => { 15 | warn(false, 'Guide组件将在5.0后不再支持,请使用Annotation替代,请查看Annotation的使用文档'); 16 | return props.children; 17 | }; 18 | 19 | Guide.Arc = Arc; 20 | Guide.DataMarker = DataMarker; 21 | Guide.DataRegion = DataRegion; 22 | // Guide.Html = Html; 23 | Guide.Image = Image; 24 | Guide.Line = Line; 25 | Guide.Region = Region; 26 | Guide.Text = Text; 27 | 28 | export default Guide; 29 | -------------------------------------------------------------------------------- /src/adapter/paddingCheck.ts: -------------------------------------------------------------------------------- 1 | import _isArray from '@antv/util/lib/is-array'; 2 | import _isString from '@antv/util/lib/is-string'; 3 | import warn from 'warning'; 4 | 5 | export default padding => { 6 | if (_isArray(padding)) { 7 | padding.forEach(element => { 8 | if (_isString(element)) { 9 | // @ts-ignore 10 | warn(true, 'padding 不支持auto 混合使用。请直接设置padding 为auto。更详细内容请查看Chart padding属性文档。') 11 | } 12 | }); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/animations.ts: -------------------------------------------------------------------------------- 1 | 2 | // 注册需要的动画执行函数 3 | import { fadeIn, fadeOut } from '@antv/g2/lib/animate/animation/fade'; 4 | import { growInX, growInXY, growInY } from '@antv/g2/lib/animate/animation/grow-in'; 5 | import { pathIn } from '@antv/g2/lib/animate/animation/path-in'; 6 | import { positionUpdate } from '@antv/g2/lib/animate/animation/position-update'; 7 | import { scaleInX, scaleInY } from '@antv/g2/lib/animate/animation/scale-in'; 8 | import { sectorPathUpdate } from '@antv/g2/lib/animate/animation/sector-path-update'; 9 | import { waveIn } from '@antv/g2/lib/animate/animation/wave-in'; 10 | import { zoomIn, zoomOut } from '@antv/g2/lib/animate/animation/zoom'; 11 | import { registerAnimation } from '@antv/g2/lib/core'; 12 | 13 | registerAnimation('fade-in', fadeIn); 14 | registerAnimation('fade-out', fadeOut); 15 | registerAnimation('grow-in-x', growInX); 16 | registerAnimation('grow-in-xy', growInXY); 17 | registerAnimation('grow-in-y', growInY); 18 | registerAnimation('scale-in-x', scaleInX); 19 | registerAnimation('scale-in-y', scaleInY); 20 | registerAnimation('wave-in', waveIn); 21 | registerAnimation('zoom-in', zoomIn); 22 | registerAnimation('zoom-out', zoomOut); 23 | registerAnimation('position-update', positionUpdate); 24 | registerAnimation('sector-path-update', sectorPathUpdate); 25 | registerAnimation('path-in', pathIn); 26 | -------------------------------------------------------------------------------- /src/boundary/ErrorBoundary.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { ErrorBoundary } from 'react-error-boundary'; 3 | export interface ErrorBoundaryProps { 4 | onResetKeysChange?: (prevResetKeys: Array, resetKeys: Array) => void 5 | onReset?: () => void 6 | onError?: (error: Error, info: { componentStack: string }) => void 7 | resetKeys?: Array 8 | fallback?: React.ReactElement | null 9 | [key:string]:any 10 | } 11 | 12 | 13 | let DefaultErrorFallback = ({ error }) => { 14 | return ( 15 |
16 |

BizCharts something went wrong:

17 |
{error.message}
18 |
19 | ) 20 | }; 21 | 22 | export function ErrorFallback(args) { 23 | return DefaultErrorFallback(args); 24 | } 25 | 26 | export const setDefaultErrorFallback = (CustComponents) => { 27 | DefaultErrorFallback = CustComponents; 28 | } 29 | 30 | export default ErrorBoundary; 31 | -------------------------------------------------------------------------------- /src/boundary/withContainer.tsx: -------------------------------------------------------------------------------- 1 | import React, { useRef, useEffect, useState } from 'react'; 2 | 3 | export default function withContainer(Component, name: string = 'ChartContainer') { 4 | const Cls = React.forwardRef((props: Iprops, ref) => { 5 | const container = useRef(); 6 | const [inited, setInited] = useState(false); 7 | const { className = "bizcharts", containerStyle, ...options } = props as any; 8 | useEffect(() => { 9 | setInited(true); 10 | }, []) 11 | // @ts-ignore 12 | return
17 | {inited ? : <>} 18 |
19 | }); 20 | Cls.displayName = name || Component.name; 21 | return Cls; 22 | }; 23 | -------------------------------------------------------------------------------- /src/components/Annotation/arc.tsx: -------------------------------------------------------------------------------- 1 | import Base, { IAnnotationBaseProps } from './base'; 2 | import { AnnotationPosition } from '../../interface'; 3 | 4 | export interface AnnotationArcProps extends IAnnotationBaseProps { 5 | /** 起始位置 */ 6 | readonly start: AnnotationPosition; 7 | /** 结束位置 */ 8 | readonly end: AnnotationPosition; 9 | } 10 | 11 | export default class Arc extends Base{ 12 | public annotationType = 'arc'; 13 | }; 14 | -------------------------------------------------------------------------------- /src/components/Annotation/dataMarker.tsx: -------------------------------------------------------------------------------- 1 | import Base, { IAnnotationBaseProps } from './base'; 2 | import { DataMarkerOption } from '../../interface'; 3 | 4 | interface AnnotationDataMarkerProps extends DataMarkerOption, IAnnotationBaseProps {} 5 | 6 | export default class DataMarker extends Base{ 7 | public annotationType = 'dataMarker'; 8 | }; 9 | -------------------------------------------------------------------------------- /src/components/Annotation/dataRegion.tsx: -------------------------------------------------------------------------------- 1 | import Base, { IAnnotationBaseProps } from './base'; 2 | import { DataRegionOption } from '../../interface'; 3 | 4 | interface AnnotationDataRegionProps extends DataRegionOption, IAnnotationBaseProps {} 5 | 6 | export default class DataRegion extends Base{ 7 | public annotationType = 'dataRegion'; 8 | }; 9 | -------------------------------------------------------------------------------- /src/components/Annotation/html.tsx: -------------------------------------------------------------------------------- 1 | import Base, { IAnnotationBaseProps } from './base'; 2 | import { HtmlAnnotationOption } from '../../interface'; 3 | 4 | 5 | type BaseProps = Omit; 6 | 7 | interface HtmlAnnotationProps extends HtmlAnnotationOption, BaseProps {} 8 | 9 | export default class Html extends Base{ 10 | public annotationType = 'html'; 11 | }; 12 | -------------------------------------------------------------------------------- /src/components/Annotation/image.tsx: -------------------------------------------------------------------------------- 1 | import Base, { IAnnotationBaseProps } from './base'; 2 | import { ImageOption } from '../../interface'; 3 | 4 | interface AnnotationImageProps extends ImageOption, IAnnotationBaseProps {} 5 | 6 | export default class Image extends Base{ 7 | public annotationType = 'image'; 8 | }; 9 | -------------------------------------------------------------------------------- /src/components/Annotation/index.tsx: -------------------------------------------------------------------------------- 1 | 2 | // annotation G2暂不支持自定义组件。 3 | export { default as Base } from './base'; 4 | export { default as Arc } from './arc'; 5 | export { default as DataMarker } from './dataMarker'; 6 | export { default as DataRegion } from './dataRegion'; 7 | export { default as RegionFilter } from './regionFilter'; 8 | export { default as Html } from './html'; 9 | export { default as ReactElement } from './reactElement'; 10 | export { default as Image } from './image'; 11 | export { default as Line } from './line'; 12 | export { default as Region } from './region'; 13 | export { default as Text } from './text'; 14 | -------------------------------------------------------------------------------- /src/components/Annotation/line.tsx: -------------------------------------------------------------------------------- 1 | import Base, { IAnnotationBaseProps } from './base'; 2 | import { LineOption } from '../../interface'; 3 | 4 | interface AnnotationLineProps extends LineOption,IAnnotationBaseProps {} 5 | 6 | export default class Line extends Base{ 7 | public annotationType = 'line'; 8 | }; 9 | -------------------------------------------------------------------------------- /src/components/Annotation/reactElement/index.tsx: -------------------------------------------------------------------------------- 1 | import Base, { IAnnotationBaseProps } from '../base'; 2 | import { ReactElementAnnotationCfg } from './component'; 3 | 4 | 5 | type BaseProps = Omit; 6 | 7 | export interface HtmlAnnotationProps extends ReactElementAnnotationCfg, BaseProps {} 8 | 9 | export default class Html extends Base{ 10 | public annotationType = 'ReactElement'; 11 | }; 12 | -------------------------------------------------------------------------------- /src/components/Annotation/region.tsx: -------------------------------------------------------------------------------- 1 | import Base, { IAnnotationBaseProps } from './base'; 2 | import { RegionOption } from '../../interface'; 3 | 4 | export interface AnnotationRegionProps extends RegionOption, IAnnotationBaseProps {} 5 | 6 | export default class Region extends Base{ 7 | public annotationType = 'region'; 8 | }; 9 | -------------------------------------------------------------------------------- /src/components/Annotation/regionFilter.tsx: -------------------------------------------------------------------------------- 1 | import Base, { IAnnotationBaseProps } from './base'; 2 | import { RegionFilterOption } from '../../interface'; 3 | 4 | interface AnnotationRegionFilterProps extends RegionFilterOption, IAnnotationBaseProps {} 5 | 6 | export default class RegionFilter extends Base{ 7 | public annotationType = 'regionFilter'; 8 | }; 9 | -------------------------------------------------------------------------------- /src/components/Annotation/text.tsx: -------------------------------------------------------------------------------- 1 | import Base, { IAnnotationBaseProps } from './base'; 2 | import { TextOption } from '../../interface'; 3 | 4 | interface AnnotationTextProps extends TextOption, IAnnotationBaseProps {} 5 | 6 | export default class Text extends Base{ 7 | protected annotationType = 'text'; 8 | }; 9 | -------------------------------------------------------------------------------- /src/components/Coordinate/coord.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import warn from 'warning'; 3 | import Coordinate from './index'; 4 | 5 | export default function Coord(props) { 6 | warn(false, 'Coord (协调) 组件将重命名为更加语义化的组件名 Coordinate(坐标),请使用Coordinate替代,我们将在5.0后删除Coord组件'); 7 | return 8 | } 9 | -------------------------------------------------------------------------------- /src/components/Effects/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import _isFunction from '@antv/util/lib/is-function'; 3 | import useChart from '../../hooks/useChartInstance'; 4 | import warn from 'warning'; 5 | 6 | interface IEffectsProps extends React.PropsWithChildren {} 7 | 8 | export default function Effects(props: IEffectsProps) { 9 | const chart = useChart(); 10 | 11 | if (_isFunction(props.children)) { 12 | const res = props.children(chart); 13 | return React.isValidElement(res) ? res : null; 14 | } 15 | 16 | warn(false, 'Effects 的子组件应当是一个函数 (chart) => {}'); 17 | return null; 18 | } 19 | -------------------------------------------------------------------------------- /src/components/Interaction/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useLayoutEffect } from 'react'; 2 | // import _isFunction from '@antv/util/lib/is-function'; 3 | import { InteractionOption } from '@antv/g2/lib/interface'; 4 | import useChart from '../../hooks/useChartView'; 5 | 6 | export interface IInteractionProps extends InteractionOption { 7 | type: string; 8 | config?: object; 9 | } 10 | 11 | export default function Interaction(props: IInteractionProps) { 12 | const chart = useChart(); 13 | const { type, config } = props; 14 | 15 | // @ts-ignore 16 | useLayoutEffect(() => { 17 | chart.interaction(type, config); 18 | return () => { 19 | chart.removeInteraction(type); 20 | }; 21 | }); 22 | 23 | return null; 24 | } 25 | -------------------------------------------------------------------------------- /src/components/Slider/index.tsx: -------------------------------------------------------------------------------- 1 | 2 | import 'react'; 3 | import _Slider from '@antv/g2/lib/chart/controller/slider'; 4 | import { SliderCfg } from '@antv/g2/lib/interface'; 5 | import { registerComponentController } from '@antv/g2/lib/core'; 6 | import useChartView from '../../hooks/useChartView'; 7 | 8 | // 引入 slider 组件 9 | registerComponentController('slider', _Slider); 10 | 11 | interface TrendCfg { 12 | // 数据 13 | data: number[]; 14 | // 样式 15 | smooth?: boolean; 16 | isArea?: boolean; 17 | backgroundStyle?: object; 18 | lineStyle?: object; 19 | areaStyle?: object; 20 | } 21 | 22 | export interface ISliderProps extends SliderCfg { 23 | // 缩略轴高度 24 | height?: number; 25 | 26 | // 背景趋势的配置 27 | trendCfg?: TrendCfg; 28 | backgroundStyle?: any; 29 | foregroundStyle?: any; 30 | handlerStyle?: any; 31 | textStyle?: any; 32 | // 允许滑动位置 33 | minLimit?: number; 34 | maxLimit?: number; 35 | // 初始位置 36 | start?: number; 37 | end?: number; 38 | } 39 | 40 | function Slider(props: ISliderProps) { 41 | const view = useChartView(); 42 | view.option('slider', props); 43 | return null; 44 | } 45 | 46 | export default Slider 47 | -------------------------------------------------------------------------------- /src/components/Tooltip/index.scss: -------------------------------------------------------------------------------- 1 | .bizcharts-tooltip { 2 | position: absolute; 3 | } 4 | -------------------------------------------------------------------------------- /src/components/Tooltip/inner.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | class InnerContent extends React.Component { 4 | state = { content: ''} 5 | public refresh(content: React.ReactNode = '') { 6 | // 刷新钩子 7 | this.setState({ content }) 8 | } 9 | render() { 10 | return <> 11 | {this.state.content} 12 | ; 13 | } 14 | } 15 | 16 | export default InnerContent; 17 | -------------------------------------------------------------------------------- /src/components/View/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import RootChartContext from '../../context/root'; 3 | import ChartViewContext from '../../context/view'; 4 | import { IViewProps } from '../../interface'; 5 | import ViewHelper from './viewHelper'; 6 | 7 | export class View extends React.Component { 8 | name = 'view'; 9 | private viewHelper: ViewHelper; 10 | static defaultProps = { 11 | visible: true, 12 | preInteractions: [], 13 | filter: [], 14 | }; 15 | componentWillUnmount() { 16 | this.viewHelper.destroy(); 17 | this.viewHelper = null; 18 | } 19 | render() { 20 | if (!this.viewHelper) { 21 | // @ts-ignore 22 | this.viewHelper = new ViewHelper(this.context.chart); 23 | } 24 | this.viewHelper.update(this.props); 25 | return ( 26 | 27 | <>{this.props.children} 28 | 29 | ); 30 | } 31 | } 32 | 33 | View.contextType = RootChartContext; 34 | 35 | export default View; 36 | -------------------------------------------------------------------------------- /src/context/canvas.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | // canvas 实例透传 4 | 5 | const CanvasContext = React.createContext(null); 6 | CanvasContext.displayName = 'CanvasContext'; 7 | 8 | export function withCanvasContext(Component) { 9 | const Com = React.forwardRef((props: T, ref) => { 10 | return ( 11 | 12 | {ctx => } 13 | 14 | ); 15 | }) 16 | Com.displayName = Component.name; 17 | return Com; 18 | }; 19 | 20 | export default CanvasContext; 21 | -------------------------------------------------------------------------------- /src/context/group.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | // Group 实例透传 4 | 5 | const GroupContext = React.createContext(null); 6 | GroupContext.displayName = 'GroupContext'; 7 | 8 | export function withGroupContext(Component) { 9 | const Com = React.forwardRef((props: T, ref) => { 10 | return ( 11 | 12 | {ctx => } 13 | 14 | ); 15 | }) 16 | Com.displayName = Component.name; 17 | return Com; 18 | }; 19 | 20 | export default GroupContext; 21 | -------------------------------------------------------------------------------- /src/context/root.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | // 最顶层chart实例 theme, 局部配置 4 | 5 | const RootChartContext = React.createContext(null); 6 | RootChartContext.displayName = 'RootChartContext'; 7 | 8 | export function withChartInstance(Component) { 9 | const Com = React.forwardRef((props: T, ref) => { 10 | return ( 11 | 12 | {ctx => } 13 | 14 | ); 15 | }) 16 | Com.displayName = Component.name; 17 | return Com; 18 | }; 19 | 20 | export default RootChartContext; 21 | -------------------------------------------------------------------------------- /src/context/view.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | // 父级图层实例,chart 或者 view 4 | const ChartViewContext = React.createContext(null); 5 | ChartViewContext.displayName = 'ChartViewContext'; 6 | const { Consumer } = ChartViewContext; 7 | 8 | export function withView(Component) { 9 | return (props: T) => { 10 | return {ctx => }; 11 | }; 12 | } 13 | 14 | export default ChartViewContext; 15 | -------------------------------------------------------------------------------- /src/extend/scale/scale.ts: -------------------------------------------------------------------------------- 1 | import { Linear, registerTickMethod, registerScale, getScale } from '@antv/scale'; 2 | 3 | import linearTickMethod from './linear-tick'; 4 | 5 | registerTickMethod('linear-strict-tick-method', linearTickMethod); 6 | 7 | /** 8 | * 线性度量 9 | * @class 10 | */ 11 | class LinearStrict extends Linear { 12 | [x: string]: any; 13 | constructor(props) { 14 | super(props); 15 | this.type = 'linear-strict'; 16 | } 17 | initCfg() { 18 | super.initCfg(); 19 | this.tickMethod = 'linear-strict-tick-method'; 20 | } 21 | 22 | calculateTicks() { 23 | const preNice = this.nice; 24 | // 强制按照计算出来的ticks,需要设置nice为true,不然会根据最值进行过滤 25 | this.nice = true; 26 | const ticks = super.calculateTicks(); 27 | this.nice = preNice; 28 | // 根据ticks设置最值 29 | if (ticks.length) { 30 | this.min = ticks[0]; 31 | this.max = ticks[ticks.length - 1]; 32 | } 33 | return ticks; 34 | } 35 | } 36 | export default LinearStrict; 37 | 38 | if (!getScale('linear-strict')) { 39 | registerScale('linear-strict', LinearStrict); 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/g-components/Base/events.ts: -------------------------------------------------------------------------------- 1 | export const EVENTS = { 2 | onClick: 'click', 3 | onMousedown: 'mousedown', 4 | onMouseup: 'mouseup', 5 | onDblclick: 'dblclick', 6 | onMouseout: 'mouseout', 7 | onMouseover: 'mouseover', 8 | onMousemove: 'mousemove', 9 | onMouseleave: 'mouseleave', 10 | onMouseenter: 'mouseenter', 11 | onTouchstart: 'touchstart', 12 | onTouchmove: 'touchmove', 13 | onTouchend: 'touchend', 14 | onDragenter: 'dragenter', 15 | onDragover: 'dragover', 16 | onDragleave: 'dragleave', 17 | onDrop: 'drop', 18 | onContextmenu: 'contextmenu', 19 | }; 20 | -------------------------------------------------------------------------------- /src/g-components/Base/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Helper from './Helper'; 3 | 4 | export * from './Helper'; 5 | 6 | class Base extends React.Component { 7 | helper: Helper; 8 | componentWillUnmount() { 9 | this.helper.destroy(); 10 | } 11 | public getInstance() { 12 | return this.helper.instance; 13 | } 14 | render() { 15 | this.helper.update(this.props); 16 | return null; 17 | } 18 | } 19 | 20 | export default Base; 21 | -------------------------------------------------------------------------------- /src/g-components/Circle.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withGroupContext } from '../context/group'; 3 | import Helper from './Base/Helper'; 4 | import Base, { IBaseProps } from './Base'; 5 | 6 | export interface ICircleProps extends IBaseProps { 7 | // 支持绘图属性 8 | attrs: { 9 | x?: number; 10 | y?: number; 11 | r?: number; 12 | [key: string]: any; 13 | }; 14 | [key: string]: any; 15 | } 16 | 17 | class Circle extends Base { 18 | constructor(props) { 19 | super(props); 20 | this.helper = new Helper('circle'); 21 | } 22 | } 23 | 24 | export default withGroupContext(Circle); 25 | -------------------------------------------------------------------------------- /src/g-components/Ellipse.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withGroupContext } from '../context/group'; 3 | import Helper from './Base/Helper'; 4 | import Base, { IBaseProps } from './Base'; 5 | 6 | export interface IEllipseProps extends IBaseProps { 7 | // 支持绘图属性 8 | attrs: { 9 | x?: number; 10 | y?: number; 11 | rx?: number; 12 | ry?: number; 13 | [key: string]: any; 14 | }; 15 | [key: string]: any; 16 | } 17 | 18 | class Ellipse extends Base { 19 | constructor(props) { 20 | super(props); 21 | this.helper = new Helper('ellipse'); 22 | } 23 | } 24 | 25 | export default withGroupContext(Ellipse); 26 | -------------------------------------------------------------------------------- /src/g-components/Image.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withGroupContext } from '../context/group'; 3 | import Helper from './Base/Helper'; 4 | import Base, { IBaseProps } from './Base'; 5 | 6 | export interface IImageProps extends IBaseProps { 7 | // 支持绘图属性 8 | attrs: { 9 | x?: number; 10 | y?: number; 11 | width?: number; 12 | height?: number; 13 | [key: string]: any; 14 | }; 15 | [key: string]: any; 16 | } 17 | 18 | class Image extends Base { 19 | constructor(props) { 20 | super(props); 21 | this.helper = new Helper('image'); 22 | } 23 | } 24 | 25 | export default withGroupContext(Image); 26 | -------------------------------------------------------------------------------- /src/g-components/Line.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withGroupContext } from '../context/group'; 3 | import Helper from './Base/Helper'; 4 | import Base, { IBaseProps } from './Base'; 5 | 6 | export interface ILineProps extends IBaseProps { 7 | // 支持绘图属性 8 | attrs: { 9 | x1?: number; 10 | y1?: number; 11 | x2?: number; 12 | y2?: number; 13 | [key: string]: any; 14 | }; 15 | [key: string]: any; 16 | } 17 | 18 | class Line extends Base { 19 | constructor(props) { 20 | super(props); 21 | this.helper = new Helper('line'); 22 | } 23 | } 24 | 25 | export default withGroupContext(Line); 26 | -------------------------------------------------------------------------------- /src/g-components/Marker.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withGroupContext } from '../context/group'; 3 | import Helper from './Base/Helper'; 4 | import Base, { IBaseProps } from './Base'; 5 | 6 | export interface IMarkerProps extends IBaseProps { 7 | // 支持绘图属性 8 | attrs: { 9 | x?: number; 10 | y?: number; 11 | r?: number; 12 | symbol?: number; 13 | [key: string]: any; 14 | }; 15 | [key: string]: any; 16 | } 17 | 18 | class Marker extends Base { 19 | constructor(props) { 20 | super(props); 21 | this.helper = new Helper('marker'); 22 | } 23 | } 24 | 25 | export default withGroupContext(Marker); 26 | -------------------------------------------------------------------------------- /src/g-components/Path.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withGroupContext } from '../context/group'; 3 | import Helper from './Base/Helper'; 4 | import Base, { IBaseProps } from './Base'; 5 | 6 | export interface IImageProps extends IBaseProps { 7 | // 支持绘图属性 8 | attrs: { 9 | /** 10 | * @example 11 | * // 数组形式: [ [ 'M', 100, 100 ], [ 'L', 200, 200 ] ] 12 | * // 字符串形式: M 100,100 L 200,200 13 | * @type {(string | any[])} 14 | */ 15 | path?: string | any[]; 16 | [key: string]: any; 17 | }; 18 | [key: string]: any; 19 | } 20 | 21 | class Image extends Base { 22 | constructor(props) { 23 | super(props); 24 | this.helper = new Helper('path'); 25 | } 26 | } 27 | 28 | export default withGroupContext(Image); 29 | -------------------------------------------------------------------------------- /src/g-components/Polygon.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withGroupContext } from '../context/group'; 3 | import Helper from './Base/Helper'; 4 | import Base, { IBaseProps } from './Base'; 5 | 6 | export interface IPolygonProps extends IBaseProps { 7 | // 支持绘图属性 8 | attrs: { 9 | points?: [number, number][]; 10 | [key: string]: any; 11 | }; 12 | [key: string]: any; 13 | } 14 | 15 | class Polygon extends Base { 16 | constructor(props) { 17 | super(props); 18 | this.helper = new Helper('polygon'); 19 | } 20 | } 21 | 22 | export default withGroupContext(Polygon); 23 | -------------------------------------------------------------------------------- /src/g-components/Polyline.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withGroupContext } from '../context/group'; 3 | import Helper from './Base/Helper'; 4 | import Base, { IBaseProps } from './Base'; 5 | 6 | export interface IPolylineProps extends IBaseProps { 7 | // 支持绘图属性 8 | attrs: { 9 | points?: [number, number][]; 10 | [key: string]: any; 11 | }; 12 | [key: string]: any; 13 | } 14 | 15 | class Polyline extends Base { 16 | constructor(props) { 17 | super(props); 18 | this.helper = new Helper('polyline'); 19 | } 20 | } 21 | 22 | export default withGroupContext(Polyline); 23 | -------------------------------------------------------------------------------- /src/g-components/Rect.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withGroupContext } from '../context/group'; 3 | import Helper from './Base/Helper'; 4 | import Base, { IBaseProps } from './Base'; 5 | 6 | export interface IRectProps extends IBaseProps { 7 | // 支持绘图属性 8 | attrs: { 9 | x?: number; 10 | y?: number; 11 | width?: number; 12 | height?: number; 13 | radius?: number; 14 | [key: string]: any; 15 | }; 16 | [key: string]: any; 17 | } 18 | 19 | class Rect extends Base { 20 | constructor(props) { 21 | super(props); 22 | this.helper = new Helper('rect'); 23 | } 24 | } 25 | 26 | export default withGroupContext(Rect); 27 | -------------------------------------------------------------------------------- /src/g-components/Text.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withGroupContext } from '../context/group'; 3 | import Helper from './Base/Helper'; 4 | import Base, { IBaseProps } from './Base'; 5 | 6 | export interface ITextProps extends IBaseProps { 7 | // 支持绘图属性 8 | attrs: { 9 | x?: number; 10 | y?: number; 11 | text?: number; 12 | [key: string]: any; 13 | }; 14 | [key: string]: any; 15 | } 16 | 17 | class Text extends Base { 18 | constructor(props) { 19 | super(props); 20 | this.helper = new Helper('text'); 21 | } 22 | } 23 | 24 | export default withGroupContext(Text); 25 | -------------------------------------------------------------------------------- /src/g-components/index.ts: -------------------------------------------------------------------------------- 1 | import ReactG from './reconciler'; 2 | 3 | export { default as Canvas } from './Canvas'; 4 | export { default as Group } from './Group'; 5 | export { default as Circle } from './Circle'; 6 | export { default as Ellipse } from './Ellipse'; 7 | export { default as Image } from './Image'; 8 | export { default as Line } from './Line'; 9 | export { default as Marker } from './Marker'; 10 | export { default as Path } from './Path'; 11 | export { default as Polygon } from './Polygon'; 12 | export { default as Polyline } from './Polyline'; 13 | export { default as Rect } from './Rect'; 14 | export { default as Text } from './Text'; 15 | 16 | export const { render } = ReactG; 17 | -------------------------------------------------------------------------------- /src/g2-all.ts: -------------------------------------------------------------------------------- 1 | export * from '@antv/g2/lib'; 2 | -------------------------------------------------------------------------------- /src/geometry/Area.tsx: -------------------------------------------------------------------------------- 1 | import Area from '@antv/g2/lib/geometry/area'; 2 | import BaseGemo, { IBaseGemoProps } from './Base'; 3 | import { registerGeometry } from '../core'; 4 | 5 | import '@antv/g2/lib/geometry/shape/area'; 6 | 7 | registerGeometry('Area', Area); 8 | 9 | export interface IAreaGemoProps extends IBaseGemoProps {} 10 | 11 | export default class AreaGeom extends BaseGemo { 12 | GemoBaseClassName = 'area' 13 | } 14 | -------------------------------------------------------------------------------- /src/geometry/Edge.tsx: -------------------------------------------------------------------------------- 1 | import Edge from '@antv/g2/lib/geometry/edge'; 2 | import BaseGemo, { IBaseGemoProps } from './Base'; 3 | import { registerGeometry } from '../core'; 4 | import '@antv/g2/lib/geometry/shape/edge'; 5 | 6 | registerGeometry('Edge', Edge); 7 | 8 | 9 | export interface IEdgeGemoProps extends IBaseGemoProps {} 10 | 11 | export default class EdgeGeom extends BaseGemo { 12 | GemoBaseClassName = 'edge' 13 | } 14 | -------------------------------------------------------------------------------- /src/geometry/Heatmap.tsx: -------------------------------------------------------------------------------- 1 | import Heatmap from '@antv/g2/lib/geometry/heatmap'; 2 | import BaseGemo, { IBaseGemoProps } from './Base'; 3 | import { registerGeometry } from '../core'; 4 | 5 | registerGeometry('Heatmap', Heatmap); 6 | 7 | 8 | export interface IHeatmapGemoProps extends IBaseGemoProps {} 9 | 10 | export default class HeatmapGeom extends BaseGemo { 11 | GemoBaseClassName = 'heatmap' 12 | } 13 | -------------------------------------------------------------------------------- /src/geometry/Line.tsx: -------------------------------------------------------------------------------- 1 | import Line from '@antv/g2/lib/geometry/line'; 2 | import '@antv/g2/lib/geometry/shape/line/step'; 3 | import BaseGemo, { IBaseGemoProps } from './Base'; 4 | import { registerGeometry } from '../core'; 5 | import '@antv/g2/lib/geometry/shape/line/step'; 6 | 7 | registerGeometry('Line', Line); 8 | 9 | 10 | export interface ILineGemoProps extends IBaseGemoProps {} 11 | 12 | export default class LineGeom extends BaseGemo { 13 | GemoBaseClassName = 'line'; 14 | } 15 | -------------------------------------------------------------------------------- /src/geometry/Path.tsx: -------------------------------------------------------------------------------- 1 | import Path from '@antv/g2/lib/geometry/path'; 2 | import { pathIn } from '@antv/g2/lib/animate/animation/path-in'; 3 | import BaseGemo, { IBaseGemoProps } from './Base'; 4 | import { registerGeometry, registerAnimation } from '../core'; 5 | 6 | 7 | registerAnimation('path-in', pathIn); 8 | registerGeometry('Path', Path); 9 | 10 | export interface IPathGemoProps extends IBaseGemoProps {} 11 | 12 | export default class PathGeom extends BaseGemo { 13 | GemoBaseClassName = 'path' 14 | } 15 | -------------------------------------------------------------------------------- /src/geometry/Point.tsx: -------------------------------------------------------------------------------- 1 | import Point from '@antv/g2/lib/geometry/point'; 2 | import BaseGemo, { IBaseGemoProps } from './Base'; 3 | import { registerGeometry } from '../core'; 4 | 5 | // 注册图形 6 | import '@antv/g2/lib/geometry/shape/point/hollow'; 7 | import '@antv/g2/lib/geometry/shape/point/image'; 8 | import '@antv/g2/lib/geometry/shape/point/solid'; 9 | 10 | registerGeometry('Point', Point); 11 | 12 | export interface IPointGemoProps extends IBaseGemoProps {} 13 | 14 | export default class PointGeom extends BaseGemo { 15 | GemoBaseClassName = 'point'; 16 | } 17 | -------------------------------------------------------------------------------- /src/geometry/Polygon.tsx: -------------------------------------------------------------------------------- 1 | import Polygon from '@antv/g2/lib/geometry/polygon'; 2 | import BaseGemo, { IBaseGemoProps } from './Base'; 3 | import { registerGeometry } from '../core'; 4 | 5 | import '@antv/g2/lib/geometry/shape/polygon'; 6 | import '@antv/g2/lib/geometry/shape/polygon/square'; 7 | 8 | 9 | registerGeometry('Polygon', Polygon); 10 | 11 | export interface IPolygonGemoProps extends IBaseGemoProps {} 12 | 13 | export default class PolygonGeom extends BaseGemo { 14 | GemoBaseClassName = 'polygon' 15 | } 16 | -------------------------------------------------------------------------------- /src/geometry/Schema.tsx: -------------------------------------------------------------------------------- 1 | import Schema from '@antv/g2/lib/geometry/schema'; 2 | import BaseGemo, { IBaseGemoProps } from './Base'; 3 | import { registerGeometry } from '../core'; 4 | import '@antv/g2/lib/geometry/shape/schema'; 5 | import '@antv/g2/lib/geometry/shape/schema/candle'; 6 | import '@antv/g2/lib/geometry/shape/schema/box'; 7 | 8 | registerGeometry('Schema', Schema); 9 | 10 | export interface ISchemaGemoProps extends IBaseGemoProps {} 11 | 12 | export default class SchemaGeom extends BaseGemo { 13 | GemoBaseClassName = 'schema' 14 | } 15 | -------------------------------------------------------------------------------- /src/geometry/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Area from './Area'; 3 | import Edge from './Edge'; 4 | import Heatmap from './Heatmap'; 5 | import Interval from './Interval'; 6 | import Line from './Line'; 7 | import Point from './Point'; 8 | import Polygon from './Polygon'; 9 | import LineAdvance from './LineAdvance'; 10 | import warn from 'warning'; 11 | 12 | import { IBaseGemoProps } from './Base'; 13 | 14 | const GEOM_MAP = { 15 | area: Area, 16 | edge: Edge, 17 | heatmap: Heatmap, 18 | interval: Interval, 19 | line: Line, 20 | point: Point, 21 | polygon: Polygon, 22 | // bx 做了预设的图形 23 | 'line-advance': LineAdvance, 24 | } 25 | 26 | export interface IGemo extends IBaseGemoProps { 27 | /** 几何标记类型 */ 28 | type: 'area'|'edge'|'heatmap'|'interval'|'line'|'point'|'polygon'|'line-advance'; 29 | [key: string]: any; 30 | } 31 | 32 | export default function(props: IGemo) { 33 | const { type, ...cfg } = props; 34 | const Geom = GEOM_MAP[type]; 35 | if (Geom) return ; 36 | warn(false, 'Only support the below type: area|edge|heatmap|interval|line|point|polygon|line-advance'); 37 | return null; 38 | } 39 | -------------------------------------------------------------------------------- /src/global.d.ts: -------------------------------------------------------------------------------- 1 | import { ReactElement } from 'react'; 2 | 3 | declare namespace React { 4 | type Props = { 5 | children: ReactElement; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /src/hooks/useChartInstance.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import RootChartContext from '../context/root'; 3 | 4 | 5 | export default function useChartInstance() { 6 | return React.useContext(RootChartContext).chart; 7 | } 8 | export function useChartTheme() { 9 | // todo: 局部配置的theme 合并 chart自己的theme 10 | return React.useContext(RootChartContext).theme; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/hooks/useChartView.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Chart } from '@antv/g2/lib/chart'; 3 | import ChartViewContext from '../context/view'; 4 | 5 | export default function useView() { 6 | 7 | // @ts-ignore 8 | return React.useContext(ChartViewContext); 9 | } 10 | -------------------------------------------------------------------------------- /src/hooks/useTheme.ts: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import { getTheme } from '@antv/g2/lib/theme'; 3 | 4 | export default function useTheme(defaultThemeName = 'default') { 5 | const defaultTheme = getTheme(defaultThemeName); 6 | defaultTheme.name = defaultThemeName; 7 | const [theme, setG2Theme] = useState(defaultTheme); 8 | const setTheme = themeName => { 9 | const nextTheme = getTheme(themeName); 10 | nextTheme.name = themeName; 11 | setG2Theme(nextTheme); 12 | }; 13 | return [theme, setTheme]; 14 | } 15 | -------------------------------------------------------------------------------- /src/plots/AreaChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Area, AreaOptions as Options } from '@antv/g2plot/lib/plots/area'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | import { polyfillOptions, polyfillVisible, replaceApi } from './core/polyfill'; 5 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 6 | import { isNil } from '@antv/util'; 7 | 8 | interface AreaOptions extends Options, BasePlotOptions { 9 | legend?: LengendAPIOptions; 10 | tooltip?: TooltipAPIOptions; 11 | label?: LabelAPIOptions; 12 | /** 旧版api,即将废弃 请使用seriesField替代 */ 13 | stackField?: string; 14 | }; 15 | 16 | export const polyfill = (opt: AreaOptions): AreaOptions => { 17 | const options = polyfillOptions(opt); 18 | // line 19 | polyfillVisible(options, 'line'); 20 | // point 21 | polyfillVisible(options, 'point'); 22 | 23 | // 否则默认开启stack 24 | options.isStack = isNil(options.isStack) ? false : options.isStack; 25 | 26 | replaceApi([{ 27 | sourceKey: 'stackField', 28 | targetKey: 'seriesField', 29 | notice: 'stackField是旧版api,即将废弃 请使用seriesField替代', 30 | }], options); 31 | 32 | return options; 33 | } 34 | 35 | export { AreaOptions }; 36 | export default createPlot(Area, 'AreaChart', polyfill); 37 | -------------------------------------------------------------------------------- /src/plots/BarChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Bar, BarOptions as Options } from '@antv/g2plot/lib/plots/bar'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | import { polyfillOptions, replaceApi } from './core/polyfill'; 5 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 6 | import { isNil } from '@antv/util'; 7 | 8 | interface BarOptions extends Options, BasePlotOptions { 9 | /** 请使用seriesField替代 */ 10 | colorField?: any; 11 | /** 图例 */ 12 | legend?: LengendAPIOptions; 13 | /** 图表提示框 */ 14 | tooltip?: TooltipAPIOptions; 15 | /** 数据标注label */ 16 | label?: LabelAPIOptions; 17 | /** 条形的宽度,如设置该属性值,则宽度固定不自动调整 */ 18 | barSize?: number; 19 | /** 旧版api,即将废弃 请使用seriesField替代 */ 20 | stackField?: string; 21 | } 22 | 23 | export const polyfill = (opt: BarOptions): BarOptions => { 24 | const { barSize, ...options } = polyfillOptions(opt); 25 | 26 | replaceApi([{ 27 | sourceKey: 'stackField', 28 | targetKey: 'seriesField', 29 | notice: 'stackField是旧版API,即将废弃 请使用seriesField替代', 30 | }, { 31 | sourceKey: 'colorField', 32 | targetKey: 'seriesField', 33 | notice: 'colorField是旧版API,即将废弃 请使用seriesField替代', 34 | }], options); 35 | 36 | if (!isNil(barSize)) { 37 | options.minBarWidth = barSize; 38 | options.maxBarWidth = barSize; 39 | } 40 | return options; 41 | } 42 | 43 | export { BarOptions }; 44 | export default createPlot(Bar, 'BarChart', polyfill); 45 | -------------------------------------------------------------------------------- /src/plots/BubbleChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Scatter, ScatterOptions as Options } from '@antv/g2plot/lib/plots/scatter'; 3 | import warn from 'warning'; 4 | import get from '@antv/util/lib/get'; 5 | import set from '@antv/util/lib/set'; 6 | import isNil from '@antv/util/lib/is-nil'; 7 | import { polyfillOptions } from './core/polyfill'; 8 | import createPlot, { BasePlotOptions } from '../createPlot'; 9 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 10 | 11 | interface BubbleOptions extends Options, BasePlotOptions { 12 | /** 该属性已废弃,请使用size替代 */ 13 | pointSize?: any; 14 | /** 15 | * 该属性已废弃,请使用regressionLine替代, 16 | * 文档查看:https://g2plot.antv.vision/zh/examples/scatter/basic/#regressionLine 17 | */ 18 | trendLine?: any; 19 | legend?: LengendAPIOptions; 20 | tooltip?: TooltipAPIOptions; 21 | label?: LabelAPIOptions; 22 | }; 23 | 24 | export { BubbleOptions }; 25 | // 气泡图, 与散点图合并 26 | export default createPlot(Scatter, 'BubbleChart', (props) => { 27 | const options = polyfillOptions(props); 28 | if (!isNil(get(options, 'pointSize'))) { 29 | set(options, 'size', get(options, 'pointSize')); 30 | } 31 | warn(false, 'BubbleChart 图表类型命名已变更为Scatter,请修改为') 32 | return options; 33 | }); 34 | -------------------------------------------------------------------------------- /src/plots/ColumnChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Column, ColumnOptions as Options } from '@antv/g2plot/lib/plots/column'; 3 | import { polyfillOptions, replaceApi } from './core/polyfill'; 4 | import createPlot, { BasePlotOptions } from '../createPlot'; 5 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 6 | import { isNil } from '@antv/util'; 7 | 8 | interface ColumnOptions extends Options, BasePlotOptions { 9 | /** 请使用seriesField替代 */ 10 | colorField?: string; 11 | /** 图例 */ 12 | legend?: LengendAPIOptions; 13 | /** 图表提示框 */ 14 | tooltip?: TooltipAPIOptions; 15 | /** 数据标注label */ 16 | label?: LabelAPIOptions; 17 | /** 旧版api,即将废弃 请使用seriesField替代 */ 18 | stackField?: string; 19 | } 20 | 21 | export { ColumnOptions }; 22 | const REPLACEAPILIST = [{ 23 | sourceKey: 'colorField', 24 | targetKey: 'seriesField', 25 | notice: 'colorField 是 g2@1.0的属性,即将废弃,请使用seriesField替代', 26 | }, { 27 | sourceKey: 'stackField', 28 | targetKey: 'seriesField', 29 | notice: 'colorField是旧版API,即将废弃 请使用seriesField替代', 30 | }]; 31 | 32 | export const polyfill = (props) => { 33 | const { columnSize, ...options } = polyfillOptions(props); 34 | replaceApi(REPLACEAPILIST, options); 35 | if (!isNil(columnSize)) { 36 | options.minColumnWidth = columnSize; 37 | options.maxColumnWidth = columnSize; 38 | } 39 | return options; 40 | }; 41 | 42 | export default createPlot(Column, 'ColumnChart', polyfill); 43 | -------------------------------------------------------------------------------- /src/plots/DensityHeatmapChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Heatmap, HeatmapOptions } from '@antv/g2plot/lib/plots/heatmap'; 3 | import { polyfillOptions, replaceApi } from './core/polyfill'; 4 | import createPlot, { BasePlotOptions } from '../createPlot'; 5 | import { set } from '@antv/util'; 6 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 7 | 8 | interface DensityHeatmapOptions extends HeatmapOptions, BasePlotOptions { 9 | /** g2Plot@1.0的api,即将废弃,请使用 `sizeRatio` 替代 */ 10 | radius?: Record | number; 11 | /** 图例 */ 12 | legend?: LengendAPIOptions; 13 | /** 图表提示框 */ 14 | tooltip?: TooltipAPIOptions; 15 | /** 数据标注label */ 16 | label?: LabelAPIOptions; 17 | } 18 | 19 | export { DensityHeatmapOptions }; 20 | 21 | export default createPlot(Heatmap, 'DensityHeatmapChartChart', (props) => { 22 | const options = polyfillOptions(props); 23 | replaceApi([{ 24 | sourceKey: 'radius', 25 | targetKey: 'sizeRatio', 26 | notice: 'radius 请使用sizeRatio替代', 27 | }], options); 28 | set(options, 'type', 'density'); 29 | return options; 30 | }); 31 | -------------------------------------------------------------------------------- /src/plots/DonutChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | 3 | import { Pie, PieOptions as Options } from '@antv/g2plot/lib/plots/pie'; 4 | import createPlot, { BasePlotOptions } from '../createPlot'; 5 | import { polyfillOptions, polyfillVisible } from './core/polyfill'; 6 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 7 | 8 | 9 | interface DonutOptions extends Options, BasePlotOptions { 10 | /** 图例 */ 11 | legend?: LengendAPIOptions; 12 | /** 图表提示框 */ 13 | tooltip?: TooltipAPIOptions; 14 | /** 数据标注label */ 15 | label?: LabelAPIOptions; 16 | }; 17 | 18 | const polyfill = (opt: DonutOptions): DonutOptions => { 19 | const options = polyfillOptions(opt); 20 | 21 | polyfillVisible(options, 'statistic'); 22 | polyfillVisible(options, 'statistic.title'); 23 | polyfillVisible(options, 'statistic.content') 24 | 25 | // g2Plot@1 默认是 0.8 innerRadius 26 | return { innerRadius: 0.8, ...options }; 27 | } 28 | 29 | export { DonutOptions }; 30 | export default createPlot(Pie, 'DonutChart', polyfill); 31 | -------------------------------------------------------------------------------- /src/plots/DualAxesChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { DualAxes, DualAxes as Options } from '@antv/g2plot/lib/plots/dual-axes'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 5 | 6 | interface DualAxesOptions extends Options, BasePlotOptions { 7 | /** 图例 */ 8 | legend?: LengendAPIOptions; 9 | /** 图表提示框 */ 10 | tooltip?: TooltipAPIOptions; 11 | /** 数据标注label */ 12 | label?: LabelAPIOptions; 13 | } 14 | // 直方图 15 | export { DualAxesOptions }; 16 | export default createPlot(DualAxes, 'DualAxesChart'); 17 | -------------------------------------------------------------------------------- /src/plots/FunnelChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Funnel, FunnelOptions as Options } from '@antv/g2plot/lib/plots/funnel'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | import { polyfillOptions, replaceApi } from './core/polyfill'; 5 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 6 | 7 | 8 | interface FunnelOptions extends Options,BasePlotOptions { 9 | /** g2Plot@1.0的api,即将废弃,请使用isTransposed替代 */ 10 | transpose?: boolean; 11 | /** 图例 */ 12 | legend?: LengendAPIOptions; 13 | /** 图表提示框 */ 14 | tooltip?: TooltipAPIOptions; 15 | /** 数据标注label */ 16 | label?: LabelAPIOptions; 17 | } 18 | 19 | export { FunnelOptions }; 20 | export default createPlot(Funnel, 'FunnelChart', (props) => { 21 | const options = polyfillOptions(props); 22 | replaceApi([{ 23 | sourceKey: 'transpose', 24 | targetKey: 'isTransposed', 25 | notice: 'transpose 即将废弃 请使用isTransposed替代', 26 | }], options); 27 | return options; 28 | }); 29 | -------------------------------------------------------------------------------- /src/plots/GroupedBarChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Bar, BarOptions as Options } from '@antv/g2plot/lib/plots/bar'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | import { polyfillOptions, replaceApi } from './core/polyfill'; 5 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 6 | import { isNil } from '@antv/util'; 7 | import warn from 'warning'; 8 | import { deepMix } from '@antv/util'; 9 | 10 | interface GroupedBarOptions extends Options, BasePlotOptions { 11 | /** 图例 */ 12 | legend?: LengendAPIOptions; 13 | /** 图表提示框 */ 14 | tooltip?: TooltipAPIOptions; 15 | /** 数据标注label */ 16 | label?: LabelAPIOptions; 17 | /** 条形的宽度,如设置该属性值,则宽度固定不自动调整 */ 18 | barSize?: number; 19 | } 20 | const REPLACEAPILIST = [{ 21 | sourceKey: 'colorField', 22 | targetKey: 'seriesField', 23 | notice: 'colorField 是 g2@1.0的属性,即将废弃,请使用seriesField替代', 24 | }]; 25 | 26 | export { GroupedBarOptions }; 27 | export default createPlot(Bar, 'GroupedBarChart', (props) => { 28 | warn(false, ' 在5.0后即将被废弃,请使用 替代'); 29 | const { barSize, ...options } = polyfillOptions(props); 30 | replaceApi(REPLACEAPILIST, options); 31 | if (!isNil(barSize)) { 32 | options.minBarWidth = barSize; 33 | options.maxBarWidth = barSize; 34 | } 35 | deepMix(props, { 36 | isGroup: true, 37 | }); 38 | return options; 39 | }); 40 | -------------------------------------------------------------------------------- /src/plots/GroupedColumnChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Column, ColumnOptions } from '@antv/g2plot/lib/plots/column'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | import { polyfillOptions } from './core/polyfill'; 5 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 6 | import { isNil } from '@antv/util'; 7 | import warn from 'warning'; 8 | import { deepMix } from '@antv/util'; 9 | 10 | interface GroupedColumnOptions extends ColumnOptions, BasePlotOptions { 11 | /** 图例 */ 12 | legend?: LengendAPIOptions; 13 | /** 图表提示框 */ 14 | tooltip?: TooltipAPIOptions; 15 | /** 数据标注label */ 16 | label?: LabelAPIOptions; 17 | /** 柱子的宽度,如设置该属性值,则宽度固定不自动调整 */ 18 | columnSize?: number; 19 | } 20 | export { GroupedColumnOptions }; 21 | export default createPlot(Column, 'GroupedColumnChart', (props) => { 22 | warn(false, ' 在5.0后即将被废弃,请使用 替代'); 23 | const { columnSize, ...options } = polyfillOptions(props); 24 | if (!isNil(columnSize)) { 25 | options.minColumnWidth = columnSize; 26 | options.maxColumnWidth = columnSize; 27 | } 28 | deepMix(props, { 29 | isGroup: true, 30 | }); 31 | return options; 32 | }); 33 | -------------------------------------------------------------------------------- /src/plots/HeatmapChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Heatmap, HeatmapOptions as Options } from '@antv/g2plot/lib/plots/heatmap'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | import { polyfillOptions } from './core/polyfill'; 5 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 6 | import { warn } from 'warning'; 7 | 8 | interface HeatmapOptions extends Options,BasePlotOptions { 9 | /** 图例 */ 10 | legend?: LengendAPIOptions; 11 | /** 图表提示框 */ 12 | tooltip?: TooltipAPIOptions; 13 | /** 数据标注label */ 14 | label?: LabelAPIOptions; 15 | /** 该属性是g2plot@1.0的属性,即将废弃,请使用 `heatmapStyle` 替代 */ 16 | shapeType?: any; 17 | } 18 | 19 | export { HeatmapOptions }; 20 | export default createPlot(Heatmap, 'HeatmapChart', (props) => { 21 | const { shapeType, ...options } = polyfillOptions(props); 22 | if (shapeType) { 23 | options.heatmapStyle = shapeType; 24 | warn(false, 'shapeType是g2plot@1.0的属性,即将废弃,请使用 `heatmapStyle` 替代') 25 | } 26 | // shape 没有指定,但配置了sizeField 27 | if (!options.shape && options.sizeField) { 28 | options.shape = "square"; 29 | } 30 | 31 | return options; 32 | }); 33 | -------------------------------------------------------------------------------- /src/plots/HistogramChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Histogram, HistogramOptions as Options } from '@antv/g2plot/lib/plots/histogram'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 5 | 6 | interface HistogramOptions extends Options, BasePlotOptions { 7 | /** 图例 */ 8 | legend?: LengendAPIOptions; 9 | /** 图表提示框 */ 10 | tooltip?: TooltipAPIOptions; 11 | /** 数据标注label */ 12 | label?: LabelAPIOptions; 13 | } 14 | // 直方图 15 | export { HistogramOptions }; 16 | export default createPlot(Histogram, 'HistogramChart'); 17 | -------------------------------------------------------------------------------- /src/plots/LineChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Line, LineOptions as Options } from '@antv/g2plot/lib/plots/line'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | import { polyfillOptions, polyfillVisible } from './core/polyfill'; 5 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 6 | 7 | type Opt = Omit 8 | 9 | interface LineOptions extends Opt, BasePlotOptions { 10 | legend?: LengendAPIOptions; 11 | tooltip?: TooltipAPIOptions; 12 | label?: LabelAPIOptions; 13 | point?: Options['point'] | boolean; 14 | }; 15 | 16 | export const polyfill = (opt: LineOptions): LineOptions => { 17 | const options = polyfillOptions(opt); 18 | // point 19 | polyfillVisible(options, 'point'); 20 | // bizcharts 端支持 写法 21 | if (options.point === true) { 22 | options.point = {}; 23 | } 24 | return options; 25 | } 26 | 27 | export { LineOptions }; 28 | export default createPlot(Line, 'LineChart', polyfill); 29 | -------------------------------------------------------------------------------- /src/plots/PercentStackedAreaChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Area } from '@antv/g2plot/lib/plots/area'; 3 | import createPlot from '../createPlot'; 4 | import { polyfill, AreaOptions } from './AreaChart'; 5 | import warn from 'warning'; 6 | import { deepMix } from '@antv/util'; 7 | 8 | interface PercentStackedAreaOptions extends AreaOptions {} 9 | 10 | export { PercentStackedAreaOptions }; 11 | export default createPlot(Area, 'PercentStackedAreaChart', props => { 12 | warn(false, ' 即将在5.0后废弃,请使用 替代。'); 13 | deepMix(props, { 14 | isPercent: true 15 | }); 16 | return polyfill(props); 17 | }); 18 | -------------------------------------------------------------------------------- /src/plots/PercentStackedBarChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Bar } from '@antv/g2plot/lib/plots/bar'; 3 | import createPlot from '../createPlot'; 4 | import warn from 'warning'; 5 | import { deepMix } from '@antv/util'; 6 | import { BarOptions, polyfill } from './BarChart'; 7 | 8 | interface PercentStackedBarOptions extends BarOptions {}; 9 | 10 | export { PercentStackedBarOptions }; 11 | export default createPlot(Bar, 'PercentStackedBarChart', props => { 12 | warn(false, ' 即将在5.0后废弃,请使用替代。'); 13 | deepMix(props, { 14 | isPercent: true, 15 | isStack: true, 16 | }); 17 | return polyfill(props); 18 | }); 19 | -------------------------------------------------------------------------------- /src/plots/PercentStackedColumnChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | 3 | import { Column } from '@antv/g2plot/lib/plots/column'; 4 | import createPlot from '../createPlot'; 5 | import warn from 'warning'; 6 | import { deepMix } from '@antv/util'; 7 | import { ColumnOptions, polyfill } from './ColumnChart'; 8 | 9 | interface PercentStackedColumnOptions extends ColumnOptions {} 10 | export default createPlot(Column, 'PercentStackedColumnChart', props => { 11 | warn(false, ' 即将在5.0后废弃,请使用替代。'); 12 | deepMix(props, { 13 | isPercent: true, 14 | isStack: true, 15 | }); 16 | return polyfill(props); 17 | }); 18 | -------------------------------------------------------------------------------- /src/plots/PieChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Pie, PieOptions as Options } from '@antv/g2plot/lib/plots/pie'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | import { polyfillOptions } from './core/polyfill'; 5 | import { LengendAPIOptions, TooltipAPIOptions, LabelAPIOptions } from './core/interface'; 6 | 7 | interface PieOptions extends Options, BasePlotOptions { 8 | tooltip?: TooltipAPIOptions, 9 | label?: LabelAPIOptions, 10 | legend?: LengendAPIOptions, 11 | }; 12 | 13 | export { PieOptions }; 14 | export default createPlot(Pie, 'PieChart', polyfillOptions); 15 | -------------------------------------------------------------------------------- /src/plots/ProgressChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react' 2 | import { Progress, ProgressOptions as Options } from '@antv/g2plot/lib/plots/progress'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | 5 | interface ProgressOptions extends BasePlotOptions, Options {} 6 | 7 | export { ProgressOptions } 8 | 9 | export default createPlot(Progress, 'ProgressChart', (opt) => { 10 | // value 转为data,用于placeholder统一判断 11 | return { data: opt.percent, color: '#5B8FF9', ...opt }; 12 | }); 13 | 14 | -------------------------------------------------------------------------------- /src/plots/RangeBarChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Bar } from '@antv/g2plot/lib/plots/bar'; 3 | import createPlot from '../createPlot'; 4 | import { BarOptions, polyfill } from './BarChart'; 5 | import warn from 'warning'; 6 | import { deepMix } from '@antv/util'; 7 | 8 | interface RangeBarOptions extends BarOptions{} 9 | export { RangeBarOptions }; 10 | export default createPlot(Bar, 'RangeBarChart', props => { 11 | warn(false, ' 即将在5.0后废弃,请使用替代。'); 12 | deepMix(props, { 13 | isRange: true, 14 | }); 15 | return polyfill(props); 16 | }); 17 | -------------------------------------------------------------------------------- /src/plots/RangeColumnChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Column } from '@antv/g2plot/lib/plots/column'; 3 | import { ColumnOptions, polyfill } from './ColumnChart'; 4 | import createPlot from '../createPlot'; 5 | import warn from 'warning'; 6 | import { deepMix } from '@antv/util'; 7 | 8 | interface RangeColumnOptions extends ColumnOptions {}; 9 | 10 | export {RangeColumnOptions}; 11 | 12 | export default createPlot(Column, 'RangeColumnChart', props => { 13 | warn(false, ' 即将在5.0后废弃,请使用替代。'); 14 | deepMix(props, { 15 | isRange: true, 16 | }) 17 | return polyfill(props); 18 | }); 19 | -------------------------------------------------------------------------------- /src/plots/RingProgressChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react' 2 | import { RingProgress, RingProgressOptions as Options } from '@antv/g2plot/lib/plots/ring-progress'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | 5 | interface RingProgressOptions extends BasePlotOptions, Options {} 6 | 7 | export { RingProgressOptions } 8 | export default createPlot(RingProgress, 'RingProgressChart', (opt) => { 9 | // value 转为data,用于placeholder统一判断 10 | return { data: opt.percent, color: '#5B8FF9', ...opt }; 11 | }); 12 | 13 | -------------------------------------------------------------------------------- /src/plots/StackedAreaChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Area } from '@antv/g2plot/lib/plots/area'; 3 | import createPlot from '../createPlot'; 4 | import { polyfill, AreaOptions } from './AreaChart'; 5 | import warn from 'warning'; 6 | import { deepMix } from '@antv/util'; 7 | 8 | interface StackedAreaOptions extends AreaOptions {} 9 | 10 | export { StackedAreaOptions }; 11 | export default createPlot(Area, 'StackedAreaChart', props => { 12 | warn(false, ' 即将在5.0后废弃,请使用 替代。'); 13 | deepMix(props, { 14 | isStack: true, 15 | }); 16 | return polyfill(props); 17 | }); 18 | -------------------------------------------------------------------------------- /src/plots/StackedBarChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Bar } from '@antv/g2plot/lib/plots/bar'; 3 | import createPlot from '../createPlot'; 4 | import warn from 'warning'; 5 | import { deepMix } from '@antv/util'; 6 | import { BarOptions, polyfill } from './BarChart'; 7 | 8 | 9 | interface StackedBarOptions extends BarOptions {} 10 | 11 | export { StackedBarOptions }; 12 | export default createPlot(Bar, 'StackedBarChart', props => { 13 | warn(false, ' 即将在5.0后废弃,请使用替代,'); 14 | deepMix(props, { 15 | isStack: true, 16 | }); 17 | return polyfill(props); 18 | }); 19 | -------------------------------------------------------------------------------- /src/plots/StackedColumnChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | 3 | import { Column } from '@antv/g2plot/lib/plots/column'; 4 | import createPlot from '../createPlot'; 5 | import warn from 'warning'; 6 | import { deepMix } from '@antv/util'; 7 | import { ColumnOptions, polyfill } from './ColumnChart'; 8 | 9 | 10 | interface StackedColumnOptions extends ColumnOptions {}; 11 | 12 | export { StackedColumnOptions }; 13 | 14 | export default createPlot(Column, 'StackedColumnChart', props => { 15 | warn(false, '即将在5.0中废弃,请使用替代。'); 16 | deepMix(props, { 17 | isStack: true, 18 | }); 19 | return polyfill(props); 20 | }); 21 | -------------------------------------------------------------------------------- /src/plots/StepLineChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import { Line } from '@antv/g2plot/lib/plots/line'; 3 | import createPlot from '../createPlot'; 4 | import { LineOptions, polyfill } from './LineChart'; 5 | import warn from 'warning'; 6 | 7 | interface StepLineOptions extends LineOptions { 8 | step?: 'hv' | 'vh' | 'vhv' | 'hvh'; 9 | }; 10 | 11 | export { StepLineOptions }; 12 | export default createPlot(Line, 'StepLineChart', props => { 13 | warn(false, '即将在5.0后废弃,请使用替代。'); 14 | props.stepType = props.stepType || props.step || 'hv'; 15 | return polyfill(props); 16 | }); 17 | 18 | -------------------------------------------------------------------------------- /src/plots/TinyAreaChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react' 2 | import { TinyArea, TinyAreaOptions as Options } from '@antv/g2plot/lib/plots/tiny-area'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | import { polyfillOptions } from './core/polyfill'; 5 | 6 | type Opt = Omit; 7 | 8 | export interface TinyAreaOptions extends Opt, BasePlotOptions { 9 | data: number[] | Record[], 10 | /** yField旧版g2Plot api,即将废弃请查看最新文档 */ 11 | yField?: string, 12 | /** xField旧版g2Plot api,即将废弃请查看最新文档 */ 13 | xField?: string, 14 | } 15 | 16 | export default createPlot(TinyArea, 'TinyAreaChart', (props) => { 17 | const { xField, yField, data, ...options} = polyfillOptions(props); 18 | if (xField && yField && data) { 19 | options.data = data.map(it => it[yField]); 20 | } 21 | return {...options}; 22 | }); 23 | -------------------------------------------------------------------------------- /src/plots/TinyColumnChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react' 2 | import { TinyColumn, TinyColumnOptions as Options } from '@antv/g2plot/lib/plots/tiny-column'; 3 | import set from '@antv/util/lib/set'; 4 | import createPlot, { BasePlotOptions } from '../createPlot'; 5 | import { polyfillOptions } from './core/polyfill'; 6 | import { isNil } from '@antv/util'; 7 | 8 | type Opt = Omit; 9 | 10 | interface TinyColumnOptions extends Opt, BasePlotOptions { 11 | /** colorField 旧版g2Plot api,即将废弃请查看最新文档 */ 12 | colorField?: string, 13 | 14 | data: number[] | Record[], 15 | 16 | /** xField 旧版g2Plot api,即将废弃请查看最新文档 */ 17 | xField?: string, 18 | 19 | /** yField 旧版g2Plot api,即将废弃请查看最新文档 */ 20 | yField?: string, 21 | 22 | /** guideLine 旧版g2Plot api,即将废弃请查看最新文档 */ 23 | guideLine?: Array 24 | } 25 | 26 | const polyfill = (opt: TinyColumnOptions): TinyColumnOptions => { 27 | const options = polyfillOptions(opt); 28 | 29 | if (!isNil(options.yField)) { // yField不是null/undefined 30 | let list = options.data 31 | .map(item => item[options.yField]) 32 | .filter(val => !isNil(val)) 33 | list && list.length && set(options, 'data', list) 34 | } 35 | 36 | set(options, 'tooltip', false) 37 | 38 | return options; 39 | } 40 | 41 | export { TinyColumnOptions }; 42 | 43 | export default createPlot(TinyColumn, 'TinyColumnChart', polyfill); 44 | -------------------------------------------------------------------------------- /src/plots/WaterfallChart.tsx: -------------------------------------------------------------------------------- 1 | import 'react'; 2 | import {Waterfall, WaterfallOptions as Options } from '@antv/g2plot/lib/plots/waterfall'; 3 | import createPlot, { BasePlotOptions } from '../createPlot'; 4 | 5 | interface WaterfallOptions extends Options, BasePlotOptions { 6 | 7 | } 8 | 9 | export default createPlot(Waterfall, 'WaterfallChart'); 10 | -------------------------------------------------------------------------------- /src/plots/index.tsx: -------------------------------------------------------------------------------- 1 | export * from './sparkline'; 2 | export * from './plots'; 3 | export { default as PlotAdapter } from './PlotAdapter'; 4 | 5 | -------------------------------------------------------------------------------- /src/plots/sparkline.tsx: -------------------------------------------------------------------------------- 1 | 2 | export { default as ProgressChart } from './ProgressChart'; 3 | export { default as RingProgressChart } from './RingProgressChart'; 4 | export { default as TinyColumnChart } from './TinyColumnChart'; 5 | export { default as TinyAreaChart } from './TinyAreaChart'; 6 | export { default as TinyLineChart } from './TinyLineChart'; 7 | -------------------------------------------------------------------------------- /src/theme/index.tsx: -------------------------------------------------------------------------------- 1 | // 注册主题 2 | import { antvDark } from '@antv/g2/lib/theme/style-sheet/dark'; 3 | import { antvLight } from '@antv/g2/lib/theme/style-sheet/light'; 4 | import { createThemeByStyleSheet } from '@antv/g2/lib/theme/util/create-by-style-sheet'; 5 | import { registerTheme } from '@antv/g2/lib/theme'; 6 | 7 | export { createThemeByStyleSheet, antvLight, antvDark }; 8 | 9 | registerTheme('dark', createThemeByStyleSheet(antvDark)); 10 | registerTheme('default', createThemeByStyleSheet(antvLight)); 11 | registerTheme('light', createThemeByStyleSheet(antvLight)); 12 | -------------------------------------------------------------------------------- /src/utils/cloneDeep.ts: -------------------------------------------------------------------------------- 1 | import isArray from '@antv/util/lib/is-array'; 2 | import forIn from '@antv/util/lib/for-in'; 3 | 4 | const cloneDeep = (deepObject) => { 5 | const map = []; 6 | const clone = (obj) => { 7 | map.push(obj); 8 | if (map.includes(obj)) { 9 | return obj; 10 | } 11 | if (typeof obj !== 'object' || obj === null) { 12 | return obj; 13 | } 14 | let rst; 15 | if (isArray(obj)) { 16 | rst = []; 17 | for (let i = 0, l = obj.length; i < l; i++) { 18 | if (typeof obj[i] === 'object' && obj[i] != null) { 19 | rst[i] = clone(obj[i]); 20 | } 21 | else { 22 | rst[i] = obj[i]; 23 | } 24 | } 25 | } 26 | else { 27 | rst = {}; 28 | forIn(obj, (value, k) => { 29 | if (typeof value === 'object' && value != null) { 30 | rst[k] = clone(value); 31 | } 32 | else { 33 | rst[k] = value; 34 | } 35 | }) 36 | } 37 | return rst; 38 | }; 39 | return clone(deepObject); 40 | } 41 | 42 | export default cloneDeep; 43 | -------------------------------------------------------------------------------- /src/utils/compareProps.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 对比不一致则执行回调 3 | */ 4 | import _each from '@antv/util/lib/each'; 5 | import _isArray from '@antv/util/lib/is-array'; 6 | import _shallowEqual from './shallowEqual'; 7 | 8 | export default (preProps: any, nextProps: any | null, keys: string[], callback: Function) => { 9 | // preProps 为null 即初始化。 10 | if (preProps === null) { 11 | _each(keys, (key) => { 12 | let value = nextProps[key]; 13 | if (value !== undefined) { 14 | if (!_isArray(value)) { 15 | value = [value]; 16 | } 17 | callback(value, key); 18 | } 19 | }); 20 | return; 21 | } 22 | 23 | let value; 24 | let nextValue; 25 | _each(keys, (key) => { 26 | value = preProps[key]; 27 | nextValue = nextProps[key]; 28 | if (!_shallowEqual(nextValue, value)) { 29 | if (!_isArray(nextValue)) { 30 | nextValue = [nextValue]; 31 | } 32 | callback(nextValue, key); 33 | } 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /src/utils/constant.ts: -------------------------------------------------------------------------------- 1 | export const REACT_PIVATE_PROPS = ['children', 'hooks', 'ref']; 2 | 3 | export default {}; 4 | -------------------------------------------------------------------------------- /src/utils/data-transform/fold.ts: -------------------------------------------------------------------------------- 1 | // 只列举常用的函数,复杂的推荐使用第三方类库。 2 | 3 | /** 4 | * 折叠数据 5 | * @param data 数据源 6 | * @param fields 被折叠的字段数组 7 | * @param foldCate 折叠的分类字段名 8 | * @param foldValue 折叠后的值字段名 9 | */ 10 | export default (data: any[], fields: string[], foldCate: string, foldValue: string) => { 11 | const resultRows = []; 12 | data.forEach((row) => { 13 | fields.forEach((field) => { 14 | resultRows.push({ 15 | ...row, 16 | [foldCate]: field, 17 | [foldValue]: row[field], 18 | }); 19 | }); 20 | }); 21 | return resultRows; 22 | } 23 | -------------------------------------------------------------------------------- /src/utils/data-transform/minifyNum.ts: -------------------------------------------------------------------------------- 1 | export default (num, decimal = 2) => { 2 | const wan = 10000; 3 | const yi = 100000000; 4 | if (num >= yi) { 5 | return `${(num / yi).toFixed(decimal).replace(/\.?0*$/, '')}\u4EBF`; 6 | } 7 | if (num >= wan) { 8 | return `${(num / wan).toFixed(decimal).replace(/\.?0*$/, '')}\u4E07`; 9 | } 10 | return num.toFixed(decimal).replace(/\.?0*$/, ''); 11 | } 12 | -------------------------------------------------------------------------------- /src/utils/data-transform/percentage.ts: -------------------------------------------------------------------------------- 1 | // 只列举常用的函数,复杂的推荐使用第三方类库。 2 | import _forIn from '@antv/util/lib/for-in'; 3 | import sum from './sum'; 4 | import warn from 'warning'; 5 | 6 | import partition from './partition'; 7 | 8 | 9 | /** 10 | * 百分比计算, 不支持重复数据统计 11 | * @param data object[] 数据源 12 | * @param field string 被统计的值 13 | * @param as string 生成的百分比字段名 14 | * @param groupBy : string | string[] 将数据分组后再计算百分比 15 | */ 16 | export default (data: object[], field: string, as: string, groupBy?: string | string[]) => { 17 | const result: any[] = []; 18 | const groups = groupBy? partition(data, groupBy) : { _data: data }; 19 | _forIn(groups, (group) => { 20 | const totalSum = sum(group.map((row: any) => row[field])); 21 | warn(totalSum !== 0, `Invalid data: total sum of field ${field} is 0!`); 22 | _forIn(group, (item) => { 23 | const resultRow = {...item}; 24 | if (totalSum === 0) { 25 | resultRow[as] = 0; 26 | } else { 27 | resultRow[as] = item[field] / totalSum; 28 | } 29 | result.push(resultRow); 30 | }); 31 | }); 32 | return result; 33 | } 34 | -------------------------------------------------------------------------------- /src/utils/data-transform/simple-sort-by.ts: -------------------------------------------------------------------------------- 1 | // from g2-dataSte 2 | import isArray from '@antv/util/lib/is-array'; 3 | import isFunction from '@antv/util/lib/is-function'; 4 | import isString from '@antv/util/lib/is-string'; 5 | 6 | export type SortTarget = string | string[] | ((a: any, b: any) => number); 7 | 8 | export default function sortBy(arr: any[], keys: SortTarget = []): any[] { 9 | let comparer: ((a: any, b: any) => number) | undefined; 10 | if (isFunction(keys)) { 11 | comparer = keys; 12 | } else if (isArray(keys)) { 13 | comparer = (a, b) => { 14 | for (let i = 0; i < keys.length; i++) { 15 | const key = keys[i]; 16 | if (a[key] < b[key]) { 17 | return -1; 18 | } 19 | if (a[key] > b[key]) { 20 | return 1; 21 | } 22 | } 23 | return 0; 24 | }; 25 | } else if (isString(keys)) { 26 | comparer = (a, b) => { 27 | if (a[keys] < b[keys]) { 28 | return -1; 29 | } 30 | if (a[keys] > b[keys]) { 31 | return 1; 32 | } 33 | return 0; 34 | }; 35 | } 36 | return arr.sort(comparer); 37 | } 38 | -------------------------------------------------------------------------------- /src/utils/data-transform/splitBySeparator.ts: -------------------------------------------------------------------------------- 1 | export default (num, separator=',') => { 2 | if (typeof num === 'number') { 3 | return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, separator); 4 | } 5 | return num; 6 | } 7 | -------------------------------------------------------------------------------- /src/utils/getElementSize.ts: -------------------------------------------------------------------------------- 1 | import { isNumber } from "@antv/util"; 2 | 3 | 4 | export default function getElementSize(ele, ctlSize: Record = {}) { 5 | return { 6 | width: isNumber(ctlSize.width) ? ctlSize.width : ele.clientWidth, 7 | height: isNumber(ctlSize.height) ? ctlSize.height : ele.clientHeight, 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | // 数据处理 2 | export { default as fold } from './data-transform/fold'; 3 | export { default as percentage } from './data-transform/percentage'; 4 | export { default as minifyNum } from './data-transform/minifyNum'; 5 | export { default as splitBySeparator } from './data-transform/splitBySeparator'; 6 | 7 | // 配置项处理 8 | export { visibleHelper } from './plotTools'; 9 | 10 | // 函数工具 11 | export { default as cloneDeep } from './cloneDeep'; 12 | export { default as shallowEqual } from './shallowEqual'; 13 | -------------------------------------------------------------------------------- /src/utils/isEqual.ts: -------------------------------------------------------------------------------- 1 | 2 | import { isObject, isArray } from '@antv/util'; 3 | 4 | const isEqual = (value: any, other: any): boolean => { 5 | if (isObject(value) && isObject(other)) { 6 | const valueKeys = Object.keys(value); 7 | const otherKeys = Object.keys(other); 8 | if (valueKeys.length !== otherKeys.length) { 9 | return false; 10 | } 11 | let rst = true; 12 | for (let i = 0; i < valueKeys.length; i++) { 13 | rst = isEqual(value[valueKeys[i]], other[valueKeys[i]]); 14 | if (!rst) { 15 | break; 16 | } 17 | } 18 | return rst; 19 | } 20 | if (isArray(value) && isArray(other)) { 21 | if (value.length !== other.length) { 22 | return false; 23 | } 24 | let rst = true; 25 | for (let i = 0; i < value.length; i++) { 26 | rst = isEqual(value[i], other[i]); 27 | if (!rst) { 28 | break; 29 | } 30 | } 31 | return rst; 32 | } 33 | if (value === other) { 34 | return true; 35 | } 36 | if (!value || !other) { 37 | return false; 38 | } 39 | return false; 40 | }; 41 | 42 | export default isEqual; 43 | -------------------------------------------------------------------------------- /src/utils/pickWithout.ts: -------------------------------------------------------------------------------- 1 | import _each from '@antv/util/lib/each'; 2 | import _isString from '@antv/util/lib/is-string'; 3 | 4 | // 支持正则匹配 5 | const pickWithout = (obj: Record, keys: (string | RegExp)[]) => { 6 | const ret: { [key: string]: any } = {}; 7 | _each(obj, (v: any, k: string) => { 8 | let match = false; 9 | keys.forEach(itKey => { 10 | if (_isString(itKey) && itKey === k) { 11 | match = true; 12 | } else if (itKey instanceof RegExp && k.match(itKey)) { 13 | match = true; 14 | } 15 | }) 16 | if (!match) { 17 | ret[k] = v; 18 | } 19 | }); 20 | return ret; 21 | } 22 | 23 | export default pickWithout; 24 | -------------------------------------------------------------------------------- /src/utils/plotTools.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import _isString from '@antv/util/lib/is-string'; 3 | import _isBoolean from '@antv/util/lib/is-boolean'; 4 | import _isObject from '@antv/util/lib/is-object'; 5 | 6 | // plot visible 写法的快速转换 7 | export const visibleHelper = (cfg, defaultVisible: boolean = true) => { 8 | if (_isString(cfg) || React.isValidElement(cfg)) { 9 | return { 10 | visible: true, 11 | text: cfg, 12 | }; 13 | } 14 | if (_isBoolean(cfg)) { 15 | return { 16 | visible: cfg, 17 | }; 18 | } 19 | if (_isObject(cfg)) { 20 | return { 21 | visible: true, 22 | ...cfg, 23 | }; 24 | } 25 | return { 26 | visible: defaultVisible, 27 | }; 28 | }; 29 | 30 | export const visibleHelperInvert = cfg => { 31 | // @ts-ignore 32 | if (_isObject(cfg) && cfg.visible !== false) { 33 | // @ts-ignore 34 | return cfg.text; 35 | } 36 | return cfg; 37 | }; 38 | -------------------------------------------------------------------------------- /src/utils/shallowEqual.ts: -------------------------------------------------------------------------------- 1 | import _each from '@antv/util/lib/each'; 2 | import _isArray from '@antv/util/lib/is-array'; 3 | import _isObject from '@antv/util/lib/is-object'; 4 | 5 | function is(x, y) { 6 | if (x === y) { 7 | return x !== 0 || y !== 0 || 1 / x === 1 / y; 8 | } 9 | return x !== x && y !== y; // NaN == NaN 10 | } 11 | 12 | function length(obj) { 13 | if (_isArray(obj)) { 14 | return obj.length; 15 | } 16 | if (_isObject(obj)) { 17 | return Object.keys(obj).length; 18 | } 19 | return 0; 20 | } 21 | 22 | export default function(objA, objB) { 23 | if (is(objA, objB)) { 24 | return true; 25 | } 26 | 27 | if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { 28 | return false; 29 | } 30 | 31 | if (_isArray(objA) !== _isArray(objB)) { 32 | return false; 33 | } 34 | 35 | if (length(objA) !== length(objB)) { 36 | return false; 37 | } 38 | 39 | let ret = true; 40 | 41 | _each(objA, (v, k) => { 42 | if (!is(v, objB[k])) { 43 | ret = false; 44 | return ret; 45 | } 46 | return true; 47 | }); 48 | 49 | return ret; 50 | } 51 | -------------------------------------------------------------------------------- /src/utils/tranPropsToArray.ts: -------------------------------------------------------------------------------- 1 | import _isArray from '@antv/util/lib/is-array'; 2 | 3 | export default function (prop) { 4 | if (_isArray(prop)) { 5 | return prop; 6 | } 7 | return [prop]; 8 | } 9 | -------------------------------------------------------------------------------- /src/utils/transBooleanCfg.ts: -------------------------------------------------------------------------------- 1 | import _clone from '@antv/util/lib/clone'; 2 | 3 | // g2 的配置项为 xxCfg | null 4 | export default (cfg: Object, keys: string[]) => { 5 | const opt = _clone(cfg); 6 | keys.forEach(key => { 7 | if (opt[key] === true) { 8 | opt[key] = {}; 9 | } else if (opt[key] === false) { 10 | opt[key] = null; 11 | } 12 | }); 13 | return opt; 14 | } 15 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "noImplicitAny": false, 5 | "declaration": true, 6 | "allowSyntheticDefaultImports": true, 7 | "experimentalDecorators": true, 8 | "esModuleInterop": true, 9 | "skipLibCheck": true, 10 | "target": "ES2015", 11 | "jsx": "react", 12 | "baseUrl": "./", 13 | "moduleResolution": "node", 14 | "resolveJsonModule": true, 15 | "paths": { 16 | "bizcharts": [ 17 | "./src/index" 18 | ], 19 | "bizcharts/*": [ 20 | "./src/*" 21 | ], 22 | } 23 | }, 24 | "include": [ 25 | "./src/*" 26 | ], 27 | "exclude": [ 28 | "node_modules", 29 | "**/*.spec.ts", 30 | "umd" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /uitest/create.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = (name, source, main, config = {}) => ({ 4 | name, 5 | source: path.join(__dirname, '..', 'demos', source), 6 | main, 7 | "cases": [ 8 | { 9 | id: name, // 此 id 一旦创建不可修改 10 | config, 11 | }, 12 | ] 13 | }); 14 | -------------------------------------------------------------------------------- /uitest/index.js: -------------------------------------------------------------------------------- 1 | const create = require('./create'); 2 | 3 | module.exports = [ 4 | create('geometry-line 测试', 'geom', 'line.jsx'), 5 | create('geometry-interval 测试', 'geom', 'interval.jsx'), 6 | create('feature-pure 测试', 'features', 'pure.jsx'), 7 | create('area-areaWithNull 测试', 'area', 'areaWithNull.jsx'), 8 | create('area-stackingArea 测试', 'area', 'stackingArea.jsx'), 9 | create('line-gradientPolyline 测试', 'line', 'gradientPolyline.jsx'), 10 | create('line-stepPolyline 测试', 'line', 'stepPolyline.jsx'), 11 | create('interval-basicBar 测试', 'interval', 'basicBar.jsx'), 12 | create('interval-basicColumn 测试', 'interval', 'basicColumn.jsx'), 13 | create('interval-histogram 测试', 'interval', 'histogram.jsx'), 14 | create('interval-bubble 测试', 'point', 'bubble.jsx'), 15 | create('interval-basicPoint 测试', 'point', 'basicPoint.jsx'), 16 | create('funnel-basicFunnel 测试', 'funnel', 'basicFunnel.jsx'), 17 | create('pie-basicPie 测试', 'pie', 'basicPie.jsx'), 18 | create('pie-nestedPie 测试', 'pie', 'nestedPie.jsx'), 19 | create('pie-nightingaleRoseIllustration 测试', 'pie', 'nightingaleRoseIllustration.jsx'), 20 | create('plot-bar', 'bugs', 'plot-bar.jsx'), 21 | ] 22 | -------------------------------------------------------------------------------- /unittest/event-spec.tsx: -------------------------------------------------------------------------------- 1 | import { pickEventName } from '../src/components/Chart/events'; 2 | 3 | describe('todos reducer', () => { 4 | const noop = () => {}; 5 | it('should pickout g2 event name', () => { 6 | const res: any[] = pickEventName({ 7 | onClick: noop, 8 | onLineClick: noop, 9 | onAxisMouseleave: noop, 10 | onLegendTitleMouseleave: noop, 11 | onTooltipShow: noop, 12 | onAfterrender: noop, 13 | }).map(d => d[1]); 14 | expect(res.includes('click')).toEqual(true); 15 | expect(res.includes('line:click')).toEqual(true); 16 | expect(res.includes('axis:mouseleave')).toEqual(true); 17 | expect(res.includes('legend-title:mouseleave')).toEqual(true); 18 | expect(res.includes('tooltip:show')).toEqual(true); 19 | expect(res.includes('afterrender')).toEqual(true); 20 | }); 21 | }) 22 | 23 | -------------------------------------------------------------------------------- /unittest/exports/theme-spec.tsx: -------------------------------------------------------------------------------- 1 | import { registerShape, registerTheme, getTheme } from '../../src/core'; 2 | // import { registerPlotTheme } from '../../src'; 3 | 4 | 5 | describe('export function', () => { 6 | it('should export registerShape', () => { 7 | expect(registerShape).toBeDefined(); 8 | }); 9 | it('should export registerTheme', () => { 10 | expect(registerTheme).toBeDefined(); 11 | }); 12 | it('should export getTheme', () => { 13 | expect(getTheme).toBeDefined(); 14 | }); 15 | // it('should export registerPlotTheme', () => { 16 | // expect(registerPlotTheme).toBeDefined(); 17 | // }); 18 | }) 19 | 20 | -------------------------------------------------------------------------------- /unittest/pickWithout-spec.tsx: -------------------------------------------------------------------------------- 1 | import pickWithout from '../src/utils/pickWithout'; 2 | 3 | describe('pickWithout', () => { 4 | it('should pickWithout a from array', () => { 5 | const res = pickWithout({ a: 1, b: 2 }, ['a']); 6 | expect(res.a).toEqual(undefined); 7 | expect(res.b).toEqual(2); 8 | }); 9 | }) 10 | 11 | -------------------------------------------------------------------------------- /unittest/plots-base/__snapshots__/BasePlot-spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`基础功能-以AreaChart为demo placeholder 1`] = ` 4 |
5 |
8 |
11 | 暂无数据 12 |
13 |
14 |
15 | `; 16 | 17 | exports[`基础功能-以AreaChart为demo title、 description 高度计算和dom渲染 1`] = `
`; 18 | 19 | exports[`基础功能-以AreaChart为demo 自定义 placeholder 1`] = ` 20 |
21 |
24 | 自定义 placeholder 25 |
26 |
27 | `; 28 | -------------------------------------------------------------------------------- /unittest/plots/BarChart-spec.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import BarChart from '../../src/plots/BarChart'; 3 | import { render, cleanup } from '@testing-library/react'; 4 | 5 | const MOCK_DATA = [ 6 | { type: '家具家电', sales: 38 }, 7 | { type: '粮油副食', sales: 52 }, 8 | { type: '生鲜水果', sales: 61 }, 9 | { type: '美容洗护', sales: 145 }, 10 | { type: '母婴用品', sales: 48 }, 11 | { type: '进口食品', sales: 38 }, 12 | { type: '食品饮料', sales: 38 }, 13 | { type: '家庭清洁', sales: 38 }, 14 | ]; 15 | 16 | describe('Plots-BarChart', () => { 17 | test('基础条形图', () => { 18 | let chart = null; 19 | render( chart = c 26 | } 27 | />) 28 | expect(chart.options).toMatchSnapshot(); 29 | }) 30 | test('colorField --> seriesField', () => { 31 | let chart = null; 32 | render( chart = c 39 | } 40 | />) 41 | expect(chart.options.seriesField).toBe('type'); 42 | cleanup(); 43 | }); 44 | }) 45 | -------------------------------------------------------------------------------- /unittest/plots/BubbleChart-spec.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import BubbleChart from '../../src/plots/BubbleChart'; 3 | import { render, cleanup } from '@testing-library/react'; 4 | 5 | const MOCK_DATA = [ 6 | { type: '家具家电', sales: 38 }, 7 | { type: '粮油副食', sales: 52 }, 8 | { type: '生鲜水果', sales: 61 }, 9 | { type: '美容洗护', sales: 145 }, 10 | { type: '母婴用品', sales: 48 }, 11 | { type: '进口食品', sales: 38 }, 12 | { type: '食品饮料', sales: 38 }, 13 | { type: '家庭清洁', sales: 38 }, 14 | ]; 15 | 16 | describe('Plots-BubbleChart', () => { 17 | test('pointSize --> size', () => { 18 | let chart = null; 19 | render( chart = c 27 | } 28 | />) 29 | expect(chart.options.size).toEqual([10,50]); 30 | cleanup(); 31 | }); 32 | }) 33 | -------------------------------------------------------------------------------- /unittest/plots/ColumnChart-spec.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ColumnChart from '../../src/plots/ColumnChart'; 3 | import { render, cleanup } from '@testing-library/react'; 4 | 5 | 6 | const MOCK_DATA = [ 7 | { type: '家具家电', sales: 38 }, 8 | { type: '粮油副食', sales: 52 }, 9 | { type: '生鲜水果', sales: 61 }, 10 | { type: '美容洗护', sales: 145 }, 11 | { type: '母婴用品', sales: 48 }, 12 | { type: '进口食品', sales: 38 }, 13 | { type: '食品饮料', sales: 38 }, 14 | { type: '家庭清洁', sales: 38 }, 15 | ]; 16 | 17 | 18 | describe('Plots-ColumnChart', () => { 19 | test('基础柱状图', () => { 20 | let chart = null; 21 | render( chart = c 28 | } 29 | />) 30 | expect(chart.options).toMatchSnapshot(); 31 | cleanup(); 32 | }) 33 | test('colorField --> seriesField', () => { 34 | let chart = null; 35 | render( chart = c 42 | } 43 | />) 44 | expect(chart.options.seriesField).toBe('type'); 45 | cleanup(); 46 | }); 47 | }) 48 | -------------------------------------------------------------------------------- /unittest/plots/LiquidChart-spec.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import LiquidChart from '../../src/plots/LiquidChart'; 3 | import { render, cleanup } from '@testing-library/react'; 4 | 5 | describe('Plots-LiquidChart', () => { 6 | test('兼容旧版LiquidChart', () => { 7 | let chart = null; 8 | render( chart = c 18 | } 19 | />); 20 | expect(chart.options.percent).toBe(5639 / 10000); 21 | expect(chart.options).toMatchSnapshot(); 22 | cleanup() 23 | }) 24 | test('新版使用', () => { 25 | let chart = null; 26 | render( chart = c 41 | } 42 | />); 43 | expect(chart.options).toMatchSnapshot(); 44 | // cleanup() 45 | }) 46 | }) 47 | -------------------------------------------------------------------------------- /unittest/plots/ProgressChart-spec.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ProgressChart from '../../src/plots/ProgressChart'; 3 | import { render, cleanup } from '@testing-library/react'; 4 | 5 | 6 | describe('Plots-ProgressChart', () => { 7 | test('进度条', () => { 8 | let chart = null; 9 | render( chart = c 17 | } 18 | />) 19 | expect(chart.options).toMatchSnapshot(); 20 | cleanup(); 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /unittest/plots/RangeBarChart-spec.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import RangeBarChart from '../../src/plots/RangeBarChart'; 3 | import { render, cleanup } from '@testing-library/react'; 4 | 5 | const MOCK_DATA = [ 6 | { type: '分类一', values: [76, 100] }, 7 | { type: '分类二', values: [56, 108] }, 8 | { type: '分类三', values: [38, 129] }, 9 | { type: '分类四', values: [58, 155] }, 10 | { type: '分类五', values: [45, 120] }, 11 | { type: '分类六', values: [23, 99] }, 12 | { type: '分类七', values: [18, 56] }, 13 | { type: '分类八', values: [18, 34] }, 14 | ]; 15 | 16 | describe('Plots-RangeBarChart', () => { 17 | test('区间条形图-旧版', () => { 18 | let chart = null; 19 | render( chart = c 36 | } 37 | />) 38 | expect(chart.options).toMatchSnapshot(); 39 | cleanup(); 40 | }) 41 | }) 42 | -------------------------------------------------------------------------------- /unittest/plots/RangeColumnChart-spec.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import RangeColumnChart from '../../src/plots/RangeColumnChart'; 3 | import { render, cleanup } from '@testing-library/react'; 4 | 5 | const MOCK_DATA = [ 6 | { type: '分类一', values: [76, 100] }, 7 | { type: '分类二', values: [56, 108] }, 8 | { type: '分类三', values: [38, 129] }, 9 | { type: '分类四', values: [58, 155] }, 10 | { type: '分类五', values: [45, 120] }, 11 | { type: '分类六', values: [23, 99] }, 12 | { type: '分类七', values: [18, 56] }, 13 | { type: '分类八', values: [18, 34] }, 14 | ]; 15 | 16 | describe('Plots-RangeColumnChart', () => { 17 | test('区间条形图-旧版', () => { 18 | let chart = null; 19 | render( chart = c 36 | } 37 | />) 38 | expect(chart.options).toMatchSnapshot(); 39 | cleanup(); 40 | }) 41 | }) 42 | -------------------------------------------------------------------------------- /unittest/plots/RingProgressChart-spec.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import RingProgressChart from '../../src/plots/RingProgressChart'; 3 | import { render, cleanup } from '@testing-library/react'; 4 | 5 | 6 | describe('Plots-RingProgressChart', () => { 7 | test('环形进度条', () => { 8 | let chart = null; 9 | render( chart = c 16 | } 17 | />) 18 | expect(chart.options).toMatchSnapshot(); 19 | // cleanup(); 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /unittest/plots/TinyAreaChart-spec.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import TinyAreaChart from '../../src/plots/TinyAreaChart'; 3 | import { render, cleanup } from '@testing-library/react'; 4 | 5 | const MOCK_DATA = [ 6 | { year: '1991', value: 3 }, 7 | { year: '1992', value: 4 }, 8 | { year: '1993', value: 6 }, 9 | { year: '1994', value: 6 }, 10 | { year: '1995', value: 8 }, 11 | { year: '1996', value: 9 }, 12 | { year: '1997', value: 7 }, 13 | { year: '1998', value: 9 }, 14 | { year: '1999', value: 13 }, 15 | ]; 16 | 17 | describe('Plots-TinyAreaChart', () => { 18 | test('迷你面积图-旧版', () => { 19 | let chart = null; 20 | render( chart = c 26 | } 27 | />) 28 | expect(chart.options).toMatchSnapshot(); 29 | cleanup(); 30 | }) 31 | }) 32 | -------------------------------------------------------------------------------- /unittest/plots/WaterfallChart-spec.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import WaterfallChart from '../../src/plots/WaterfallChart'; 3 | import { render, cleanup } from '@testing-library/react'; 4 | 5 | // 数据源 6 | const data = [ 7 | { type: '日用品', money: 120 }, 8 | { type: '伙食费', money: 900 }, 9 | { type: '交通费', money: 200 }, 10 | { type: '水电费', money: 300 }, 11 | { type: '房租', money: 1200 }, 12 | { type: '商场消费', money: 1000 }, 13 | { type: '应酬红包', money: -2000 }, 14 | ]; 15 | 16 | describe('Plots-WaterfallChart', () => { 17 | test('基础WaterfallChart', () => { 18 | let chart = null; 19 | render( 20 | { 39 | chart = c; 40 | }} 41 | />, 42 | ); 43 | cleanup(); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /unittest/plots/__snapshots__/ProgressChart-spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Plots-ProgressChart 进度条 1`] = ` 4 | Object { 5 | "animation": Object {}, 6 | "appendPadding": Array [ 7 | 10, 8 | 5, 9 | 10, 10 | 10, 11 | ], 12 | "autoFit": true, 13 | "color": Array [ 14 | "#5B8FF9", 15 | "#E8EDF3", 16 | ], 17 | "data": 0.71, 18 | "height": 70, 19 | "padding": 10, 20 | "percent": 0.71, 21 | "width": 200, 22 | } 23 | `; 24 | -------------------------------------------------------------------------------- /unittest/plots/__snapshots__/RingProgressChart-spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Plots-RingProgressChart 环形进度条 1`] = ` 4 | Object { 5 | "animation": Object {}, 6 | "appendPadding": Array [ 7 | 10, 8 | 5, 9 | 10, 10 | 10, 11 | ], 12 | "autoFit": true, 13 | "color": Array [ 14 | "#5B8FF9", 15 | "#E8EDF3", 16 | ], 17 | "data": 0.8, 18 | "height": 100, 19 | "innerRadius": 0.8, 20 | "percent": 0.8, 21 | "radius": 0.98, 22 | "statistic": Object { 23 | "content": Object { 24 | "style": Object { 25 | "fill": "#4D4D4D", 26 | "fontSize": "14px", 27 | "fontWeight": 300, 28 | "textAlign": "center", 29 | "textBaseline": "middle", 30 | }, 31 | }, 32 | "title": false, 33 | }, 34 | "width": 100, 35 | } 36 | `; 37 | -------------------------------------------------------------------------------- /unittest/plots/__snapshots__/TinyAreaChart-spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Plots-TinyAreaChart 迷你面积图-旧版 1`] = ` 4 | Object { 5 | "animation": Object {}, 6 | "appendPadding": Array [ 7 | 10, 8 | 5, 9 | 10, 10 | 10, 11 | ], 12 | "areaStyle": Object { 13 | "fillOpacity": 0.6, 14 | }, 15 | "autoFit": true, 16 | "color": "l(90) 0:#E5EDFE 1:#ffffff", 17 | "data": Array [ 18 | 3, 19 | 4, 20 | 6, 21 | 6, 22 | 8, 23 | 9, 24 | 7, 25 | 9, 26 | 13, 27 | ], 28 | "line": Object { 29 | "color": "#5B8FF9", 30 | "size": 1, 31 | }, 32 | "tooltip": Object { 33 | "containerTpl": "
", 34 | "crosshairs": Object { 35 | "type": "x", 36 | }, 37 | "customContent": [Function], 38 | "domStyles": Object { 39 | "g2-tooltip": Object { 40 | "fontSize": "10px", 41 | "padding": "2px 4px", 42 | }, 43 | }, 44 | "itemTpl": "{value}", 45 | "shared": true, 46 | "showCrosshairs": true, 47 | "showMarkers": false, 48 | "showTitle": false, 49 | }, 50 | } 51 | `; 52 | -------------------------------------------------------------------------------- /unittest/plots/_update-option-spec.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import BarChart from '../../src/plots/BarChart'; 3 | import { render, cleanup } from '@testing-library/react'; 4 | 5 | const MOCK_DATA = [ 6 | { type: '家具家电', sales: 38 }, 7 | { type: '粮油副食', sales: 52 }, 8 | { type: '生鲜水果', sales: 61 }, 9 | { type: '美容洗护', sales: 145 }, 10 | { type: '母婴用品', sales: 48 }, 11 | { type: '进口食品', sales: 38 }, 12 | { type: '食品饮料', sales: 38 }, 13 | { type: '家庭清洁', sales: 38 }, 14 | ]; 15 | 16 | const opt = { 17 | data: MOCK_DATA, 18 | yField: "type", 19 | xField: "sales", 20 | seriesField: "type", 21 | }; 22 | 23 | const Demo = () => { 24 | const [option, setState] = useState(opt); 25 | return <> 26 |
{ 27 | setState({...opt}); 28 | console.log('change') 29 | }}>click me change option seriesField
30 |
{ 31 | setState({...opt, seriesField: undefined }); 32 | console.log('change') 33 | }}>click me change option seriesField
34 |
{ 35 | setState({...opt, data: [] }); 36 | console.log('change') 37 | }}>click me change option seriesField
38 | 39 | 42 | 43 | }; 44 | 45 | describe('Plots-basic', () => { 46 | test('update options', () => { 47 | let chart = null; 48 | render() 49 | // cleanup(); 50 | }); 51 | }) 52 | -------------------------------------------------------------------------------- /unittest/setup.js: -------------------------------------------------------------------------------- 1 | require('whatwg-fetch'); 2 | -------------------------------------------------------------------------------- /unittest/shallowEqual-spec.tsx: -------------------------------------------------------------------------------- 1 | import shallowEqual from '../src/utils/shallowEqual'; 2 | 3 | describe('shallowEqual', () => { 4 | it('should ref data shallowEqual true', () => { 5 | const data = [{x:1,y:1}]; 6 | expect( 7 | shallowEqual({ data: data }, { data: data }) 8 | ).toEqual(true) 9 | }); 10 | it('should defined data shallowEqual false', () => { 11 | expect( 12 | shallowEqual({ data: [{x:1,y:1}] }, { data:[{x:1,y:1}] }) 13 | ).toEqual(false) 14 | }); 15 | it('should some obj shallowEqual false', () => { 16 | const obj = { data: [{x:1,y:1}] }; 17 | expect( 18 | shallowEqual(obj, obj) 19 | ).toEqual(true) 20 | }); 21 | it('should data shallowEqual', () => { 22 | expect( 23 | shallowEqual({ title: 'title' }, { title: 'title' }) 24 | ).toEqual(true) 25 | }); 26 | it('should data shallowEqual', () => { 27 | expect( 28 | shallowEqual({ title: undefined }, { title: undefined }) 29 | ).toEqual(true) 30 | }) 31 | }) 32 | -------------------------------------------------------------------------------- /unittest/tools/simulate.ts: -------------------------------------------------------------------------------- 1 | 2 | export function simulateMouseEvent(dom, type, cfg) { 3 | const event = new MouseEvent(type, cfg); 4 | dom.dispatchEvent(event); 5 | } 6 | 7 | export function getClientPoint(canvas, x: number, y: number) { 8 | const point = canvas.getClientByPoint(x, y); 9 | return { 10 | clientX: point.x, 11 | clientY: point.y, 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /unittest/tools/sleep.ts: -------------------------------------------------------------------------------- 1 | export function sleep(ms) { 2 | return new Promise((resolve) => setTimeout(resolve, ms)); 3 | } 4 | -------------------------------------------------------------------------------- /unittest/utils/transBooleanCfg-spec.tsx: -------------------------------------------------------------------------------- 1 | import transBooleanCfg from '../../src/utils/transBooleanCfg'; 2 | 3 | describe('pickWithout', () => { 4 | it('should pickWithout a from array', () => { 5 | const res = transBooleanCfg({ 6 | title: false, 7 | grid: true, 8 | line: null, 9 | }, ['title', 'grid', 'line']); 10 | expect(res.title).toEqual(null); 11 | expect(res.grid).toEqual({}); 12 | expect(res.line).toEqual(null); 13 | }); 14 | }) 15 | 16 | -------------------------------------------------------------------------------- /unittest/version-spec.tsx: -------------------------------------------------------------------------------- 1 | import { VERSION } from '../src/core'; 2 | import packageJson from '../package.json'; 3 | 4 | // 全局变量中的版本号是否和 package.json 中的一致 5 | describe('version', () => { 6 | it('should equal package.json', () => { 7 | expect( 8 | packageJson.version 9 | ).toEqual(VERSION) 10 | }); 11 | }) 12 | --------------------------------------------------------------------------------