javascript - 如何使用 react-chartjs 创建具有动态宽度的折线图?

标签 javascript charts reactjs

我正在尝试创建一个具有动态宽度的折线图,但只获取第一个值。

<LineChart data = {this.state.dataLine} options = {{}} width={this.state.widthChart} height = "250" />

最佳答案

我不确定如何在 react-chartjs 中实现这一点,但在 react-vis 中非常简单,这很相似。

import React from 'react';

import {
  XAxis,
  YAxis,
  FlexibleWidthXYPlot,
  HorizontalGridLines,
  LineSeries
} from 'react-vis';

export default class Example extends React.Component {
  render() {
    return (
      <FlexibleWidthXYPlot
        height={300}>
        <HorizontalGridLines />
        <YAxis />
        <XAxis />
        <LineSeries data={myData}/>
      </FlexibleWidthXYPlot>
    );
  }
}

更多信息请点击这里http://uber.github.io/react-vis/#/documentation/api-reference/flexible-plots

关于javascript - 如何使用 react-chartjs 创建具有动态宽度的折线图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37166372/

相关文章:

javascript - 带有时间的谷歌图表来自 php json

javascript - meteor 中带有 chart.js 的 react 图表

javascript - 从按钮单击事件渲染 React 组件

javascript - 一个简单的 Angular JS $http 对象响应有问题吗?

javascript - Mongoose:find() - 匹配两个值并仅返回匹配的文档

javascript - Node JS Express 和控制台输出到命令行与浏览器

javascript - 在 typescript 中访问 Nodejs 流的 highWaterMark 属性给出 : "Property ' _readableState' does not exist"error

charts - 绘制具有多个缺失值的谷歌折线图

javascript - 在 React 应用程序中使用环境变量

javascript - 如何使用正则表达式来约束 ReactJS 路由