react 创建饼状图
来源:互联网 发布:js原型链继承面试题 编辑:程序博客网 时间:2024/06/07 22:29
- npm install react-highcharts –save
- 引入页面中 import Highcharts from ‘react-highcharts’
在render中调用
代码如下(这是一个饼状图的示例):
注:config中为绘制图必须的属性等内容,可参考highcharts官网示例及api文档。地址为:https://www.hcharts.cn/demo/highcharts
import React from 'react';import Highcharts from 'react-highcharts'import './taskMain.less';class DoughnutChart extends React.Component{ constructor(props){ super(props); } componentWillMount() { this.state = { config: { chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, spacing:[10,0,40,0], }, title: { text: "运行成功率", style:{ "color":"#fff", "fontSize":"16px", }, verticalAlign:'middle', }, //这是鼠标悬浮时的提示框 tooltip: { //point为series中data的数据 pointFormat: ' <p style="font-size: 14px">{point.name}:<b>{point.percentage:.1f}%</b></p>', headerFormat:'<span style="font-size: 14px">{series.name}</span><br/>', hideDelay:200 }, credits: { enabled: false // 隐藏highcharts版权 }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', //标注 dataLabels: { enabled: true, format: '<span>{point.name} : {point.percentage:.1f}%</span>', distance:12, style: { color: '#108eef', fontWeight: "lighter", fontSize:'1em', } }, }, }, series: [{ type:'pie', name: this.props.name, colorByPoint: true, data: [{ name:"成功", color:"#66CDAA", y:80% },{ name:"失败", color:"#E9967A", y:20% }], }] }, } } render(){ return <div className="chart"> <Highcharts config={this.state.config}></Highcharts> </div> }}export default DoughnutChart;
效果图:
阅读全文
0 0
- react 创建饼状图
- UILabel创建(React Native)
- React 创建自定义控件
- react-native创建searchbar
- react native demo创建
- 创建React Native项目
- react native项目创建
- 创建react-native项目
- react组件创建方式
- react-项目创建
- React创建table
- Jhipster创建React项目
- React 创建对话框组件
- 创建react项目
- 创建react项目
- react创建webpack服务器
- react 入门-创建元素
- react-native 简单的react-redux创建
- 学习韩顺平校内网项目时遇到的问题及解决方法
- VIM之高亮光标所在的行列
- 使用jQuery开发Todos实录
- 使用Ajax提交数据,进行前后台数据交互
- get&post
- react 创建饼状图
- html学习笔记
- ZooKeeper连接KeeperErrorCode = ConnectionLoss for /eclipse问题,暂无解决办法
- git 命令常用总结
- 单元测试编写
- 修改centos源为阿里云源
- 安卓逆向DDMS不显示待附加进程解决思路
- LeetCode(7) Given a 32-bit signed integer, reverse digits of an integer解题报告
- android图片裁剪拼接实现(一):Matrix基本使用