我需要显示这个图表:
var chart = LightweightCharts.createChart(document.body, {
width: 600,
height: 300
});
chart.applyOptions({
timezone: "Europe/Paris",
timeScale: {
timeVisible: true,
secondsVisible: true,
},
localization: {
locale: 'it',
},
});
var areaSeries = chart.addAreaSeries({
topColor: 'rgba(21, 146, 230, 0.4)',
bottomColor: 'rgba(21, 146, 230, 0)',
lineColor: 'rgba(21, 146, 230, 1)',
lineStyle: 0,
lineWidth: 3,
crosshairMarkerVisible: false,
crosshairMarkerRadius: 3,
});
areaSeries.setData([{
"time": 905299200,
"value": 0.25
}, {
"time": 918781200,
"value": 0.0
}, {
"time": 935952000,
}, {
"time": 965952000,
"value": 0.25
}, {
"time": 983408400,
"value": 0.15
}, {
"time": 985050000,
"value": 0.0
}, {
"time": 1152835200,
"value": 0.25
}, {
"time": 1172019600,
"value": 0.5
}, {
"time": 1225414800,
"value": 0.3
}, {
"time": 1229648400,
"value": 0.1
}, {
"time": 1286236800,
"value": 0.1
}, {
"time": 1454029200,
"value": -0.1
}, {
"time": 1454288400,
"value": 0.0
}]);
但是,如果您查看 2000-2006 和 2006-2008 的时间轴,使用的空间或多或少相同,因此图表看起来很奇怪,如何在不更改 json 的情况下解决此问题?
我找到了一个解决方案,添加一些没有像这样的值字段的点:{“时间”:valueBetweenTwoPoints},但这可能会导致一些错误。