mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-03 01:10:10 +00:00
fix for multibar widget
This commit is contained in:
parent
bf047da111
commit
ab0c7ae440
6 changed files with 34 additions and 31 deletions
49
httpdocs/js/widgets/templates/multibar-chart-template.js
Normal file
49
httpdocs/js/widgets/templates/multibar-chart-template.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { ChartTemplate } from './default-template.js';
|
||||
|
||||
export default class MultiBarChartTemplate extends ChartTemplate {
|
||||
|
||||
constructor(params) { super(params); console.log(this); }
|
||||
|
||||
_addGraph() {
|
||||
|
||||
const self = this;
|
||||
nv.addGraph(function() {
|
||||
|
||||
const multibarChart = nv.models.multiBarChart();
|
||||
multibarChart.height(self._height);
|
||||
multibarChart.width(self._width);
|
||||
multibarChart.stacked(true);
|
||||
|
||||
d3.select(`#${self._defaultOptions.domId}`)
|
||||
.append('svg')
|
||||
.datum(self._data)
|
||||
.transition()
|
||||
.duration(1000)
|
||||
.call(multibarChart);
|
||||
|
||||
if (self._defaultOptions.widget.intervalTime) {
|
||||
self._intervalId = setInterval(async function() {
|
||||
const newData = await self._updateData();
|
||||
self._data = newData.data;
|
||||
multibarChart.update();
|
||||
}, self._defaultOptions.widget.intervalTime);
|
||||
}
|
||||
|
||||
self._chart = multibarChart;
|
||||
|
||||
return multibarChart;
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
const container = super.render();
|
||||
/* if I have data to show then add the graph! */
|
||||
if (this._data.length != 0) {
|
||||
container.setAttribute('style', `width:${this._width}px;height:${this._width}px`);
|
||||
this._addGraph();
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue