|
57 | 57 | _this.currentCursor = null; |
58 | 58 | } |
59 | 59 |
|
60 | | - _this.renderCharts(); |
| 60 | + // Remove leftover eventhandlers and uPlot instances |
| 61 | + _this.plots.forEach((plot, element) => { |
| 62 | + plot.destroy(); |
| 63 | + }); |
| 64 | + // Then, reset the existing plots map for the new rendering |
| 65 | + _this.plots = new Map(); |
| 66 | + |
| 67 | + // Get the elements we going to render the charts in |
| 68 | + const lineCharts = document.querySelectorAll(CHART_CLASS); |
| 69 | + |
| 70 | + // Check if the elements exist, just to be safe |
| 71 | + if (lineCharts.length < 1) { |
| 72 | + return; |
| 73 | + } |
| 74 | + |
| 75 | + _this.renderCharts(lineCharts); |
61 | 76 | } |
62 | 77 |
|
63 | 78 | /** |
|
198 | 213 | /** |
199 | 214 | * renderCharts creates the canvas objects given the provided datasets. |
200 | 215 | */ |
201 | | - renderCharts() |
| 216 | + renderCharts(lineCharts) |
202 | 217 | { |
203 | 218 | // Get the colors from these sneaky little HTML elements |
204 | 219 | const axesColor = $('div.axes-color').css('background-color'); |
|
208 | 223 | // These are the shared options for all charts |
209 | 224 | const baseOpts = this.getChartBaseOptions(); |
210 | 225 |
|
211 | | - // Remove leftover eventhandlers and uPlot instances |
212 | | - this.plots.forEach((plot, element) => { |
213 | | - plot.destroy(); |
214 | | - }); |
215 | | - // Then, reset the existing plots map for the new rendering |
216 | | - this.plots = new Map(); |
217 | | - |
218 | | - // Get the elements we going to render the charts in |
219 | | - const lineCharts = document.querySelectorAll(CHART_CLASS); |
220 | | - |
221 | | - // Check if the elements exist, just to be safe |
222 | | - if (lineCharts.length < 1) { |
223 | | - return; |
224 | | - } |
225 | | - |
226 | 226 | this.icinga.logger.debug('perfdatagraphs', 'start renderCharts'); |
227 | 227 |
|
228 | 228 | for (let elem of lineCharts) { |
| 229 | + this.icinga.logger.debug('perfdatagraphs', 'rendering for', elem); |
| 230 | + |
229 | 231 | const dataset = JSON.parse(elem.getAttribute('data-perfdata')); |
230 | 232 |
|
231 | 233 | // The size can vary from chart to chart for example when |
|
0 commit comments