mirror of
https://github.com/zaphar/Heracles.git
synced 2025-07-24 13:09:47 -04:00
feat: Allow you to name the axis for each subplot
You can force them to share axis with this.
This commit is contained in:
parent
4674a821d8
commit
0cf2c537ae
@ -120,6 +120,7 @@ pub struct PlotMeta {
|
||||
name_prefix: Option<String>,
|
||||
name_suffix: Option<String>,
|
||||
name_label: Option<String>,
|
||||
named_axis: Option<String>,
|
||||
d3_tick_format: Option<String>,
|
||||
}
|
||||
|
||||
|
@ -137,12 +137,14 @@ class TimeseriesGraph extends HTMLElement {
|
||||
for (var subplot_idx in data) {
|
||||
const subplot = data[subplot_idx];
|
||||
const subplotCount = Number(subplot_idx) + 1;
|
||||
const yaxis = "y" + subplotCount
|
||||
const default_yaxis = "y" + subplotCount
|
||||
if (subplot.Series) {
|
||||
// https://plotly.com/javascript/reference/scatter/
|
||||
for (const triple of subplot.Series) {
|
||||
const labels = triple[0];
|
||||
const meta = triple[1];
|
||||
const yaxis = meta["named_axis"] || default_yaxis;
|
||||
// https://plotly.com/javascript/reference/layout/yaxis/
|
||||
layout["yaxis" + subplotCount] = {
|
||||
anchor: yaxis,
|
||||
tickformat: meta["d3_tick_format"] || this.#d3TickFormat
|
||||
@ -153,6 +155,8 @@ class TimeseriesGraph extends HTMLElement {
|
||||
mode: "lines+text",
|
||||
x: [],
|
||||
y: [],
|
||||
// We always share the x axis for timeseries graphs.
|
||||
xaxis: "x",
|
||||
yaxis: yaxis,
|
||||
yhoverformat: meta["d3_tick_format"],
|
||||
};
|
||||
@ -201,7 +205,6 @@ class TimeseriesGraph extends HTMLElement {
|
||||
}
|
||||
}
|
||||
}
|
||||
console.debug("traces: ", traces);
|
||||
// https://plotly.com/javascript/plotlyjs-function-reference/#plotlyreact
|
||||
Plotly.react(this.getTargetNode(), traces, layout, config);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user