Я не знаю, насколько это адекватно, но у меня это сработало
function createConfig(snapshot) {
let profitInUSDT = snapshot.profitInUSDT,
profitInBTC = snapshot.profitInBTC,
xAxisDate = snapshot.date;
profitInUSDT = profitInUSDT.map((val, i) => [xAxisDate[i], val])
profitInBTC = profitInBTC.map((val, i) => [xAxisDate[i], val])
return {
title: {
useHTML: true,
text: '<a href="/tracker/' + snapshot.name + '"> ' + snapshot.name + ' </a>'
},
navigator: {
enabled: false
},
rangeSelector: {
selected: 6,
enabled: false,
},
scrollbar: {
enabled: false
},
yAxis: {
opposite:false,
labels: {
formatter: function () {
return (this.value > 0 ? ' + ' : '') + this.value + '%';
},
},
plotLines: [{
value: 0,
width: 2,
color: 'silver'
}]
},
legend: {
enabled: true,
},
tooltip: {
pointFormat: '{series.name} <b>{point.y}%</b>',
valueDecimals: 2,
split: true
},
series: [{
name: 'profit in USDT',
data: profitInUSDT,
color: '#21a27c',
tooltip: {
valueDecimals: 2
}
},
{
name: 'profit in BTC',
data: profitInBTC,
color: '#f79413',
tooltip: {
valueDecimals: 2
}
}
]
};
}
window.onload = function() {
var cont = document.querySelector('.container');
[{"name":"test","description":"test","date":[1577203210000,1577206808000,1577210408000],"profitInBTC":[0.0,-0.79,0.87],"profitInUSDT":[0.0,-0.51,0.36]},{"name":"puz","description":"futures","date":[1582665302212,1582668005727,1582671603990],"profitInBTC":[0.0,-0.5,14.72],"profitInUSDT":[15.4,15.41,15.41]}].forEach(function(snapshot) {
var container = document.createElement('div');
container.className = 'chart-container';
cont.append(container);
document.body.append(cont);
var config = createConfig(snapshot);
Highcharts.stockChart(container, config);
});
};
.chart-container {
width: 80%;
margin-left: 40px;
margin-right: 40px;
margin-bottom: 40px;
}
.container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
}
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<div class="container">
</div>