I want to use lightweight-charts package in Nuxt project. I couldn't find any examples included in the Nuxt project. I did it with some methods but I don't know what is the best method. What is the correct way to run it on nuxt?
The use of the package on the site is as follows.
import { createChart } from 'lightweight-charts';
const chart = createChart(document.body, { width: 400, height: 300 });
const lineSeries = chart.addLineSeries();
lineSeries.setData([
{ time: '2019-04-11', value: 80.01 },
{ time: '2019-04-12', value: 96.63 },
{ time: '2019-04-13', value: 76.64 },
{ time: '2019-04-14', value: 81.89 },
{ time: '2019-04-15', value: 74.43 },
{ time: '2019-04-16', value: 80.01 },
{ time: '2019-04-17', value: 96.63 },
{ time: '2019-04-18', value: 76.64 },
{ time: '2019-04-19', value: 81.89 },
{ time: '2019-04-20', value: 74.43 },
]);
There is no example on this one because this is not related to Nuxt anyhow, neither really to Vue but more of a generic JS vanilla question.
Few points:
mounted()
, it depends on what you're doing there of course$refs
rather than document.body
since we're in a state-based framework herelineSeries.setData
could maybe be moved to data
and injected afterwards