baseddata.io/static/js/bitcoin-price.js

59 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-08-01 14:06:16 +01:00
let dataArr = [];
const myChart = echarts.init(document.getElementById("chart"));
$.get("https://api.bitlab21.com/price", {}, (response) => {
dataArr = response;
console.log(dataArr);
initEchart();
});
function initEchart() {
const option = {
backgroundColor: backgroundColor,
tooltip: {
backgroundColor: tooltipBgColor,
order: "seriesDesc",
textStyle: textStyleMain,
trigger: "axis",
},
toolbox: toolboxParams,
xAxis: {
data: dataArr.map((row) => row.date),
axisTick: axisTick,
axisLabel: axisLabel,
axisLine: axisLine,
},
grid: grid,
dataZoom: dataZoom(),
yAxis: [
{
type: "value",
name: "Price (USD)",
nameLocation: "middle",
nameTextStyle: {
fontSize: 12 * fontScale,
padding: [0, 0, 40, 0],
color: "#eff1d6",
},
position: "left",
alignTicks: true,
axisTick: axisTick,
axisLine: axisLine,
splitLine: {
show: false,
},
axisLabel: axisLabel,
},
],
series: [
{
type: "line",
name: "Price (USD)",
data: dataArr.map((row) => row.price),
},
],
};
myChart.setOption(option);
}