Open superjai opened 2 months ago
Plotly class idea (subject to change):
class Plot {
constructor(params) {
//init all params
this.actions = {
plot1: this.doAction1,
plot2: this.doAction2,
plot3: this.doAction3,
};
}
doAction1() {
....
console.log("plot1 plotted");
}
doAction2() {
....
console.log("plot2 plotted");
}
doAction3() {
....
console.log("plot3 plotted");
}
execute(action) {
// Use the mapping to call the function dynamically
if (this.actions[action]) {
this.actions[action].call(this); // `call(this)` ensures correct `this` context
} else {
console.log("Invalid action");
}
}
}
// Usage example
const myClassInstance = new Plot(params); //where params are function arguments for plot
myClassInstance.execute('plot1'); // plot1 plotted
myClassInstance.execute('plot2'); // plot2 plotted
where the parameter is pulled directly from WP backend
Plotly workflow:
Backend:
Frontend:
So, let's get started thinking about how we might implement plotly for interactive figures.
Here, you'll find a zipped html and json file. If you extract those two in the same folder and then open the html file via localhost, you should see the plot of the json file.
This is the simplest possible plot we could see - time series data in plotly. I haven't changed many of the defaults, so this plot could look way better.
The question to start thinking about is: how could this be implemented within the wordpress site?