https://github.com/antvis/g2-react/blob/master/src/index.js
来源:互联网 发布:软件行业能力资质 编辑:程序博客网 时间:2024/06/09 23:00
react antv G2 样例 地址:https://github.com/antvis/g2-react/blob/master/src/index.js
import G2 from 'g2';import React from 'react';import PropTypes from 'prop-types';let uniqueId = 0;function generateUniqueId() { return `rc-g2-${uniqueId++}`;}export default function createG2(__operation) { class Component extends React.Component { static propTypes = { data: PropTypes.arrayOf(PropTypes.object).isRequired, width: PropTypes.number.isRequired, height: PropTypes.number.isRequired, plotCfg: PropTypes.object, forceFit: PropTypes.bool, configs: PropTypes.object, }; constructor(props, context) { super(props, context); this.chart = null; this.chartId = generateUniqueId(); } componentDidMount() { this.initChart(this.props); } componentWillReceiveProps(newProps) { const { data: newData, width: newWidth, height: newHeight, plotCfg: newPlotCfg } = newProps; const { data: oldData, width: oldWidth, height: oldHeight, plotCfg: oldPlotCfg } = this.props; if (newPlotCfg !== oldPlotCfg) { console.warn('plotCfg 不支持修改'); } if (newData !== oldData) { this.chart.changeData(newData); } if (newWidth !== oldWidth || newHeight !== oldHeight) { this.chart.changeSize(newWidth, newHeight); } } shouldComponentUpdate() { return false; } componentWillUnmount() { this.chart.destroy(); this.chart = null; this.chartId = null; } initChart(props) { const { width, height, data, plotCfg, forceFit, configs } = props; const chart = new G2.Chart({ id: this.chartId, width, height, plotCfg, forceFit, }); chart.source(data); __operation(chart, configs); this.chart = chart; } render() { return (<div id={this.chartId} />); } } return Component;}
阅读全文
0 0
- https://github.com/antvis/g2-react/blob/master/src/index.js
- agario服务端源码https://github.com/huytd/agar.io-clone/blob/master/src/server/server.js
- 翻译--https://github.com/ruanyf/react-demos/blob/master/README.md
- 前置变换后置变换OpenCV源代码 转自https://github.com/kipr/opencv/blob/master/modules/legacy/src/lines.cpp
- gRPC三分钟入门(c++)https://github.com/grpc/grpc/blob/master/INSTALL
- https://github.com/react-webpack-generators/generator-react-webpack-alt
- iOS 开发 UI 搭建心得(一)—— 驾驭 StoryBoard 代码示例:https://github.com/johnlui/Swift-On-iOS/blob/master/Differen
- [!] Pod::Executable clone 'https://github.com/CocoaPods/Specs.git' master
- 官网https://github.com/reactjs/react-router-tutorial学习
- [!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress Cloning into 'master
- https://github.com/havlenapetr/android_frameworks_base/blob/froyo-sgs/native/video/jni/surface.cpp
- https://github.com/search
- https://github.com/mogutt
- Node.JS之妙用初探 https://github.com/rvagg/learnyounode
- Trigger script exited with code: 1 From https://github.com/CocoaPods/Specs 9967bbf..de7b3da master -
- [!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master Cloning
- Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master-1
- rk3288 audio 驱动分析 (https://github.com/54shady/kernel_drivers_examples/tree/master/debug/codec)
- spring boot logback
- unity 学习笔记,自用截屏
- 数据结构与算法专题之线性表——栈及其应用
- RecyclerView 悬浮/粘性头部——StickyHeaderDecoration
- 深入理解HTTP Session
- https://github.com/antvis/g2-react/blob/master/src/index.js
- Spring 4.0 学习日记(7) ---动态代理
- 51nod 1393 0和1相等串 (思维+前缀和)
- underscore.js 964 --- 1103行
- Tree Cutting 树形dp
- java-mooc浙江大学第三周编程题
- STFT原理及MATLAB代码
- Easy File Sharing Web Server 7.2
- C. Read Time----二分答案