图表 beginAtZero: true, min:0 和 title:“分钟”不起作用
我希望我的反应图表中的 Y 轴从 0 开始,我一直在尝试很多解决方案,例如 beginAtZero: true 和 min:0 但不起作用。
import React, { Component } from 'react';
// Documentation https://www.npmjs.com/package/react-charts
import { Chart } from 'react-charts';
我还想向 X 轴添加标题标题:分钟也不起作用,这是代码:
MyChart = () => {
this.componentRef = React.createRef();
if (this.state.selectedDocumentContent !== undefined) {
const content = this.state.selectedDocumentContent;
const firstTimeStamp = this.toTimestampSeconds(content.time);
const metricKeys = Object.keys(content.metrics);
var data = [];
for (var i = 1; i < metricKeys.length-1; i++) {
const entries = content.metrics[metricKeys[i]];
var metricData = [];
for (var j = 0; j < entries.length; j++) {
let entry = entries[j];
let timestamp = this.toTimestampSeconds(entry.time);
metricData.push([timestamp - firstTimeStamp, entry.value]);
}
data.push({ label: metricKeys[i], data: metricData })
}
const axes = [
{ primary: true, type: 'linear', position: 'bottom', title: 'minutes' }, //x
{ type: 'linear', position: 'left', options: {
scales: {
yAxes: [{
display: true,
ticks: {
beginAtZero: true,
min:0
}
}]
}} //y
}
];
const lineChart = (
// A react-chart hyper-responsively and continuously fills the available
// space of its parent element automatically
<div
style={{
margin: '30px',
width: '600px',
height: '400px'
}}
>
<Chart data={data} axes={axes} tooltip/>
</div>
)
return lineChart;
}
}
我正在使用此图表: https://www.npmjs.com/package/react-charts “反应图表”:“^2.0.0-beta.7”。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
固定的!我几乎对此感到疯狂,我用 base:0 解决了它。
仍然没有解决标题问题......继续调查......
有人知道如何设置最大值吗? (最大:X,不起作用)
Fixed! I almost got crazy about this, I solved it with base:0.
Still did not fix the issue with the title... continuing the investigation....
Does anybody knows about how to set a maximum value? (max: X, does not work)