mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
heatmap: refactor, build cards before rendering
This commit is contained in:
parent
55b24be115
commit
c79a68dcd1
@ -7,7 +7,7 @@ import TimeSeries from 'app/core/time_series';
|
||||
import {axesEditor} from './axes_editor';
|
||||
import {heatmapDisplayEditor} from './display_editor';
|
||||
import rendering from './rendering';
|
||||
import { convertToHeatMap, elasticHistogramToHeatmap, calculateBucketSize, getMinLog} from './heatmap_data_converter';
|
||||
import {convertToHeatMap, convertToCards, elasticHistogramToHeatmap, calculateBucketSize, getMinLog} from './heatmap_data_converter';
|
||||
|
||||
let X_BUCKET_NUMBER_DEFAULT = 30;
|
||||
let Y_BUCKET_NUMBER_DEFAULT = 10;
|
||||
@ -188,11 +188,21 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
|
||||
yBucketSize = 1;
|
||||
}
|
||||
|
||||
let cardsData = convertToCards(bucketsData);
|
||||
let maxCardsValue = _.max(_.map(cardsData, 'count'));
|
||||
let minCardsValue = _.min(_.map(cardsData, 'count'));
|
||||
let cardStats = {
|
||||
max: maxCardsValue,
|
||||
min: minCardsValue
|
||||
};
|
||||
|
||||
this.data = {
|
||||
buckets: bucketsData,
|
||||
heatmapStats: heatmapStats,
|
||||
xBucketSize: xBucketSize,
|
||||
yBucketSize: yBucketSize
|
||||
yBucketSize: yBucketSize,
|
||||
cards: cardsData,
|
||||
cardStats: cardStats
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import {appEvents, contextSrv} from 'app/core/core';
|
||||
import {tickStep, getScaledDecimals, getFlotTickSize} from 'app/core/utils/ticks';
|
||||
import d3 from 'd3';
|
||||
import {HeatmapTooltip} from './heatmap_tooltip';
|
||||
import {convertToCards, mergeZeroBuckets} from './heatmap_data_converter';
|
||||
import {mergeZeroBuckets} from './heatmap_data_converter';
|
||||
|
||||
let MIN_CARD_SIZE = 1,
|
||||
CARD_PADDING = 1,
|
||||
@ -384,8 +384,8 @@ export default function link(scope, elem, attrs, ctrl) {
|
||||
data.buckets = mergeZeroBuckets(data.buckets, _.min(tick_values));
|
||||
}
|
||||
|
||||
let cardsData = convertToCards(data.buckets);
|
||||
let maxValueAuto = d3.max(cardsData, card => card.count);
|
||||
let cardsData = data.cards;
|
||||
let maxValueAuto = data.cardStats.max;
|
||||
let maxValue = panel.color.max || maxValueAuto;
|
||||
let minValue = panel.color.min || 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user