Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix chart zoom + retrieve rubber
Browse files Browse the repository at this point in the history
  • Loading branch information
kduret committed May 31, 2017
1 parent 1f760f8 commit 65da850
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
26 changes: 16 additions & 10 deletions www/include/views/graphs/javascript/centreon-c3.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,42 @@
var d3 = $$.d3;

if ($$.config.zoom_select.enabled) {
var brushing = false;

/* Initialize brush */
$$.zoom_select_brush = d3.svg.brush()
.x($$.x)
.on('brushstart', function () {
brushing = true;
})
.on('brushend', function () {
if (typeof $$.config.zoom_select.onzoom === 'function') {
if (!$$.zoom_select_brush.empty()) {
$$.config.zoom_select.onzoom($$.zoom_select_brush.extent());
$$.zoom_select_brush.clear();
d3.selectAll('.' + $$.CLASS.brush)
$$.svg.selectAll('.' + $$.CLASS.brush)
.call($$.zoom_select_brush);

}
}
brushing = false;
});

/* Attach brush to main chart */
$$.svg.append('g')
$$.svg.selectAll('.c3-chart').append('g')
.attr('class', $$.CLASS.brush)
.style('display', 'none')
.call($$.zoom_select_brush)
.selectAll('rect')
.attr('y', -6)
.attr('height', $$.height);

/* Attach events for on click activate brush */
$$.svg.select('g').on('mousedown', function () {
$$.svg.selectAll('.' + $$.CLASS.brush).style('display', 'block');
$$.svg.selectAll('.c3-chart').on('mousedown', function () {
$$.svg.select('.' + $$.CLASS.brush).style('display', 'block');
});
$$.svg.select('g').on('mouseup', function () {
$$.svg.selectAll('.' + $$.CLASS.brush).style('display', 'none');
$$.svg.selectAll('.c3-chart').on('mouseup', function () {
if (brushing) {
$$.svg.select('.' + $$.CLASS.brush).style('display', 'none');
}
});
}
};
Expand Down
9 changes: 8 additions & 1 deletion www/include/views/graphs/javascript/centreon-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,13 @@
},
zoom_select: self.settings.zoom,
point: {
show: false
show: true,
r: 0,
focus: {
expand: {
r: 4
}
}
},
regions: self.buildRegions(data),
legend: {
Expand Down Expand Up @@ -869,6 +875,7 @@
timeFormat: null,
threshold: true,
extraLegend: true,
buttonToggleCurves: true,
url: './api/internal.php?object=centreon_metric'
};
})(jQuery);

0 comments on commit 65da850

Please sign in to comment.