|
@@ -19,7 +19,10 @@ let MIN_CARD_SIZE = 1,
|
|
|
Y_AXIS_TICK_PADDING = 5,
|
|
Y_AXIS_TICK_PADDING = 5,
|
|
|
MIN_SELECTION_WIDTH = 2;
|
|
MIN_SELECTION_WIDTH = 2;
|
|
|
|
|
|
|
|
-export default class Link {
|
|
|
|
|
|
|
+export default function rendering(scope, elem, attrs, ctrl) {
|
|
|
|
|
+ return new Link(scope, elem, attrs, ctrl);
|
|
|
|
|
+}
|
|
|
|
|
+export class Link {
|
|
|
width: number;
|
|
width: number;
|
|
|
height: number;
|
|
height: number;
|
|
|
yScale: any;
|
|
yScale: any;
|
|
@@ -50,7 +53,7 @@ export default class Link {
|
|
|
dataRangeWidingFactor: number;
|
|
dataRangeWidingFactor: number;
|
|
|
constructor(private scope, private elem, attrs, private ctrl) {
|
|
constructor(private scope, private elem, attrs, private ctrl) {
|
|
|
// $heatmap is JQuery object, but heatmap is D3
|
|
// $heatmap is JQuery object, but heatmap is D3
|
|
|
- this.$heatmap = elem.find('.heatmap-panel');
|
|
|
|
|
|
|
+ this.$heatmap = this.elem.find('.heatmap-panel');
|
|
|
this.tooltip = new HeatmapTooltip(this.$heatmap, this.scope);
|
|
this.tooltip = new HeatmapTooltip(this.$heatmap, this.scope);
|
|
|
|
|
|
|
|
this.selection = {
|
|
this.selection = {
|
|
@@ -65,7 +68,7 @@ export default class Link {
|
|
|
|
|
|
|
|
this.ctrl.events.on('render', this.onRender.bind(this));
|
|
this.ctrl.events.on('render', this.onRender.bind(this));
|
|
|
|
|
|
|
|
- this.ctrl.tickValueFormatter = this.tickValueFormatter;
|
|
|
|
|
|
|
+ this.ctrl.tickValueFormatter = this.tickValueFormatter.bind(this);
|
|
|
/////////////////////////////
|
|
/////////////////////////////
|
|
|
// Selection and crosshair //
|
|
// Selection and crosshair //
|
|
|
/////////////////////////////
|
|
/////////////////////////////
|
|
@@ -151,7 +154,7 @@ export default class Link {
|
|
|
} else {
|
|
} else {
|
|
|
timeFormat = d3.timeFormat(grafanaTimeFormatter);
|
|
timeFormat = d3.timeFormat(grafanaTimeFormatter);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ console.log(ticks);
|
|
|
let xAxis = d3
|
|
let xAxis = d3
|
|
|
.axisBottom(this.xScale)
|
|
.axisBottom(this.xScale)
|
|
|
.ticks(ticks)
|
|
.ticks(ticks)
|
|
@@ -345,11 +348,12 @@ export default class Link {
|
|
|
const decimals = this.panel.yAxis.decimals === null ? decimalsAuto : this.panel.yAxis.decimals;
|
|
const decimals = this.panel.yAxis.decimals === null ? decimalsAuto : this.panel.yAxis.decimals;
|
|
|
this.ctrl.decimals = decimals;
|
|
this.ctrl.decimals = decimals;
|
|
|
|
|
|
|
|
|
|
+ let tickValueFormatter = this.tickValueFormatter.bind(this);
|
|
|
function tickFormatter(valIndex) {
|
|
function tickFormatter(valIndex) {
|
|
|
let valueFormatted = tsBuckets[valIndex];
|
|
let valueFormatted = tsBuckets[valIndex];
|
|
|
if (!_.isNaN(_.toNumber(valueFormatted)) && valueFormatted !== '') {
|
|
if (!_.isNaN(_.toNumber(valueFormatted)) && valueFormatted !== '') {
|
|
|
// Try to format numeric tick labels
|
|
// Try to format numeric tick labels
|
|
|
- valueFormatted = this.tickValueFormatter(decimals)(_.toNumber(valueFormatted));
|
|
|
|
|
|
|
+ valueFormatted = tickValueFormatter(decimals)(_.toNumber(valueFormatted));
|
|
|
}
|
|
}
|
|
|
return valueFormatted;
|
|
return valueFormatted;
|
|
|
}
|
|
}
|
|
@@ -533,17 +537,17 @@ export default class Link {
|
|
|
cards = cards
|
|
cards = cards
|
|
|
.enter()
|
|
.enter()
|
|
|
.append('rect')
|
|
.append('rect')
|
|
|
- .attr('x', this.getCardX)
|
|
|
|
|
- .attr('width', this.getCardWidth)
|
|
|
|
|
- .attr('y', this.getCardY)
|
|
|
|
|
- .attr('height', this.getCardHeight)
|
|
|
|
|
|
|
+ .attr('x', this.getCardX.bind(this))
|
|
|
|
|
+ .attr('width', this.getCardWidth.bind(this))
|
|
|
|
|
+ .attr('y', this.getCardY.bind(this))
|
|
|
|
|
+ .attr('height', this.getCardHeight.bind(this))
|
|
|
.attr('rx', this.cardRound)
|
|
.attr('rx', this.cardRound)
|
|
|
.attr('ry', this.cardRound)
|
|
.attr('ry', this.cardRound)
|
|
|
.attr('class', 'bordered heatmap-card')
|
|
.attr('class', 'bordered heatmap-card')
|
|
|
- .style('fill', this.getCardColor)
|
|
|
|
|
- .style('stroke', this.getCardColor)
|
|
|
|
|
|
|
+ .style('fill', this.getCardColor.bind(this))
|
|
|
|
|
+ .style('stroke', this.getCardColor.bind(this))
|
|
|
.style('stroke-width', 0)
|
|
.style('stroke-width', 0)
|
|
|
- .style('opacity', this.getCardOpacity);
|
|
|
|
|
|
|
+ .style('opacity', this.getCardOpacity.bind(this));
|
|
|
|
|
|
|
|
let $cards = this.$heatmap.find('.heatmap-card');
|
|
let $cards = this.$heatmap.find('.heatmap-card');
|
|
|
$cards
|
|
$cards
|
|
@@ -683,11 +687,11 @@ export default class Link {
|
|
|
this.onMouseUp();
|
|
this.onMouseUp();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- $(document).one('mouseup', this.mouseUpHandler);
|
|
|
|
|
|
|
+ $(document).one('mouseup', this.mouseUpHandler.bind(this));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onMouseUp() {
|
|
onMouseUp() {
|
|
|
- $(document).unbind('mouseup', this.mouseUpHandler);
|
|
|
|
|
|
|
+ $(document).unbind('mouseup', this.mouseUpHandler.bind(this));
|
|
|
this.mouseUpHandler = null;
|
|
this.mouseUpHandler = null;
|
|
|
this.selection.active = false;
|
|
this.selection.active = false;
|
|
|
|
|
|