mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-03 01:10:10 +00:00
migrating widgets to nvd3
This commit is contained in:
parent
ac8bd534ea
commit
747980cf45
13 changed files with 268 additions and 187 deletions
53
httpdocs/js/widgets/templates/pie-chart-template.js
Normal file
53
httpdocs/js/widgets/templates/pie-chart-template.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { ChartTemplate } from './default-template.js';
|
||||
|
||||
export default class PieChartTemplate extends ChartTemplate {
|
||||
|
||||
constructor(params) {
|
||||
super(params);
|
||||
this._isDonut = false;
|
||||
this._intervalId = 0;
|
||||
}
|
||||
|
||||
_addGraph(container) {
|
||||
|
||||
const self = this;
|
||||
|
||||
nv.addGraph(function() {
|
||||
|
||||
const pieChart = nv.models.pieChart();
|
||||
pieChart.x(d => d.label);
|
||||
pieChart.y(d => d.value);
|
||||
pieChart.height(self._height);
|
||||
pieChart.width(self._width);
|
||||
pieChart.showTooltipPercent(true);
|
||||
pieChart.donut(self._isDonut);
|
||||
|
||||
d3.select(container.getAttribute('id'))
|
||||
.datum(self._data)
|
||||
.transition().duration(1200)
|
||||
.attr('width', self._width)
|
||||
.attr('height', self._height)
|
||||
.call(pieChart);
|
||||
|
||||
if (self._defaultOptions.intervalTime) {
|
||||
self._intervalId = setInterval(function() {
|
||||
// TODO: set interval callback
|
||||
pieChart.update();
|
||||
}, self._defaultOptions.intervalTime);
|
||||
}
|
||||
|
||||
self._chart = pieChart;
|
||||
|
||||
return pieChart;
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
const container = super.render();
|
||||
super._addGraph(container);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue