SP-DIT / 2122s1-CA1

0 stars 0 forks source link

How do we make/call the panel graph from a separate file? #4

Open DanielLohSuErn opened 3 years ago

DanielLohSuErn commented 3 years ago

How do we make/call the panel graph from a separate file? How do we link the graph from the separate file into charts.mjs?

jeremiah-ang commented 3 years ago

To understand you correctly, you created another graph in another file.

If your graph follows the requirement of our standard chart (e.g. it has the 4 function, create, getData, processData, draw)

You can export the chart from that new file, import it inside chart.mjs and add it as a new entry inside the charts variable.

e.g.

// my-new-chart.js
export default const myNewChart = {
    create: ....,
    draw: ....,
    ....
}

// charts.mjs
const myNewChart = require('./my-new-chart.js');
...
export const charts = {
    "error-chart": { ... },
    "my-new-chart": myNewChart,
}
jeremiah-ang commented 3 years ago

If your chart doesn't have the 4 functions, then you can't do that, you have to create your own mechanism to draw the chart every few seconds.