reactjs - 如何在 React js 中渲染多个“vis-react”组件
问题描述
我想vis-react
使用 react js 的组件渲染多个拓扑。
任何建议如何进行?我正在使用 ES6
解决方案
如果你有一个数组,你想用它的项目填充图表数据,你可以这样做
render() {
let counter = 0;
const items= this.props.data.map(item => {
return (
<XYPlot
width={300}
height={300}>
<HorizontalGridLines />
<LineSeries data={[item.data]}/>
<XAxis />
<YAxis />
</XYPlot>
)
})
return (
<div>
{items}
</div>
)
}
如果您有其他来源,则必须像这样手动设置:
render() {
return (
<XYPlot key='1'
width={300}
height={300}>
<HorizontalGridLines />
<LineSeries
data={[
{x: 1, y: 10},
{x: 2, y: 5},
{x: 3, y: 15}
]}/>
<XAxis />
<YAxis />
</XYPlot>
<XYPlot key = '2'
width={300}
height={300}>
<HorizontalGridLines />
<LineSeries
data={[
{x: 1, y: 10},
{x: 2, y: 5},
{x: 3, y: 15}
]}/>
<XAxis />
<YAxis />
</XYPlot>
)
}
推荐阅读
- javascript - 在浏览器中导入 RxJS 6?
- debian - 如何防止 Beaglebone 外设引脚被劫持
- c# - 无法让 NLog 目标处理通过 ILMerge 生成的程序集
- php - MySQL 查询(WHERE 元键和值)
- loops - 在 JavaFX 中使用 for 循环设置时间轴
- linux - 是否可以仅在特定目录中提供命令?
- javascript - CKEditor - 可编辑内容 CSS 干扰编辑器工具栏样式
- neo4j - Neo4j 慢匹配和遍历,即使有索引
- tensorflow - 机器学习文本比较模型
- angular - 无法从 Angular5 模板中的 firebase 获取 $key