fix: not a good refactor there

This commit is contained in:
Jeremy Wall 2024-04-04 16:12:31 -04:00
parent 471d159af7
commit 03820d2941
2 changed files with 28 additions and 11 deletions

View File

@ -5,7 +5,7 @@
query_type: Range # The type of graph. Range for timeseries and Scalar for point in time
d3_tickformat: "~s" # Default tick format for the graph y axis
legend_orientation: h
yaxes:
yaxes: # The yaxes definitions to feed to plotly.
- anchor: "y"
# overlaying: "y"
side: left

View File

@ -195,7 +195,7 @@ export class GraphPlot extends HTMLElement {
self.stopInterval()
self.fetchData().then((data) => {
if (!updateOnly) {
self.getLabelsForData(data.Metrics || data.Logs.Lines);
self.getLabelsForData(data.Metrics || data.Logs.lines);
self.buildFilterMenu();
}
self.updateGraph(data).then(() => {
@ -365,6 +365,32 @@ export class GraphPlot extends HTMLElement {
* @param {QueryData|LogLineList} graph
*/
getLabelsForData(graph) {
if (/** @type {QueryData} */(graph).plots) {
this.getLabelsForQueryData(/** @type {QueryData} */(graph));
} else {
this.getLabelsForLogLines(/** @type {LogLineList} */(graph));
}
}
/**
* @param {LogLineList} graph
*/
getLabelsForLogLines(graph) {
if (graph.Stream) {
for (const pair of graph.Stream) {
const labels = pair[0];
this.populateFilterData(labels);
}
}
if (graph.StreamInstant) {
// TODO(zaphar): Handle this?
}
}
/**
* @param {QueryData} graph
*/
getLabelsForQueryData(graph) {
const data = graph.plots;
for (var subplot of data) {
if (subplot.Series) {
@ -379,15 +405,6 @@ export class GraphPlot extends HTMLElement {
this.populateFilterData(labels);
}
}
if (subplot.Stream) {
for (const pair of subplot.Stream) {
const labels = pair[0];
this.populateFilterData(labels);
}
}
if (subplot.StreamInstant) {
// TODO(zaphar): Handle this?
}
}
}