Chartjs-ChartJS stock price line chart config with autoscale

0👍

Got it to work

    var historicalprices = await yahooFinance.historical("AAPL", { period1: '2019-01-01', interval: '1mo' })
    var prices = historicalprices.map(historicalprice => ({ [historicalprice.date.toLocaleDateString('en-us', { year: "numeric", month: "short" })]: Math.round(historicalprice.adjClose) }))
const data = {
    labels: prices.map(x => Object.keys(x)).flat(),
    datasets: [{
        data: prices.map(x => Object.values(x)).flat(),
        fill: false,
        borderColor: 'rgb(75, 192, 192)',
        tension: 0.1
    }]
}

Leave a comment