mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
parent
c40f854283
commit
4e31f600f6
118 changed files with 34006 additions and 10177 deletions
|
|
@ -9,7 +9,7 @@ const FILL_COLORS = [
|
|||
'rgb(144, 238, 144)',
|
||||
'rgb(25, 135, 84)',
|
||||
'rgb(255, 193, 7)',
|
||||
'rgb(220, 53, 69)',
|
||||
'rgb(220, 53, 69)'
|
||||
];
|
||||
|
||||
/* *********************************************** */
|
||||
|
|
@ -25,17 +25,17 @@ function darkenColor(colorStr) {
|
|||
/* *********************************************** */
|
||||
|
||||
function getColor(current_value, max_value, default_color) {
|
||||
if (!max_value || !current_value) {
|
||||
if(!max_value || !current_value) {
|
||||
return darkenColor(default_color);
|
||||
}
|
||||
/* Security check */
|
||||
if (current_value > max_value) {
|
||||
if(current_value > max_value) {
|
||||
current_value = max_value;
|
||||
}
|
||||
|
||||
const colors_module = max_value / FILL_COLORS.length;
|
||||
for (let i = 1; i < FILL_COLORS.length + 1; i++) {
|
||||
if (current_value <= colors_module * i) {
|
||||
for(let i = 1; i < FILL_COLORS.length + 1; i++) {
|
||||
if(current_value <= colors_module * i) {
|
||||
return FILL_COLORS[i - 1];
|
||||
}
|
||||
}
|
||||
|
|
@ -48,9 +48,9 @@ function barChartPlotter(e) {
|
|||
const ctx = e.drawingContext;
|
||||
const points = e.points;
|
||||
const y_bottom = e.dygraph.toDomYCoord(0);
|
||||
const max_value = e.dygraph.user_attrs_.valueRange[1];
|
||||
const max_value = e.dygraph.user_attrs_.valueRange[1]
|
||||
const default_color = e.color;
|
||||
|
||||
|
||||
/* Find the minimum separation between x-values.
|
||||
* This determines the bar width.
|
||||
*/
|
||||
|
|
@ -60,32 +60,32 @@ function barChartPlotter(e) {
|
|||
if (sep < min_sep && sep > 0) min_sep = sep;
|
||||
}
|
||||
|
||||
if (min_sep > MAX_BAR_WIDTH) {
|
||||
min_sep = MAX_BAR_WIDTH;
|
||||
if(min_sep > MAX_BAR_WIDTH) {
|
||||
min_sep = MAX_BAR_WIDTH
|
||||
}
|
||||
|
||||
/* Keep just a little distance between the bars */
|
||||
const bar_width = Math.floor(0.9 * min_sep);
|
||||
|
||||
/* Do the actual plotting */
|
||||
for (let i = 0; i < points.length; i++) {
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
const p = points[i];
|
||||
const center_x = p.canvasx;
|
||||
const current_value = p.yval;
|
||||
ctx.fillStyle = getColor(Math.abs(current_value), Math.abs(max_value), default_color);
|
||||
ctx.fillRect(center_x - bar_width / 2, p.canvasy,
|
||||
bar_width, y_bottom - p.canvasy);
|
||||
bar_width, y_bottom - p.canvasy);
|
||||
ctx.strokeRect(center_x - bar_width / 2, p.canvasy,
|
||||
bar_width, y_bottom - p.canvasy);
|
||||
bar_width, y_bottom - p.canvasy);
|
||||
}
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
const dygraphPlotters = function() {
|
||||
const dygraphPlotters = function () {
|
||||
return {
|
||||
barChartPlotter,
|
||||
};
|
||||
}();
|
||||
|
||||
export default dygraphPlotters;
|
||||
export default dygraphPlotters;
|
||||
Loading…
Add table
Add a link
Reference in a new issue