mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* graph: initial histogram support #600 * graph histogram mode: add Bars number option * graph histogram mode: fix X axis ticks calculation * graph histogram mode: change bar style (align and width) * refactor(graph): move histogram functions into separate module * graph histogram mode: rename series to "count" * graph histogram mode: fix errors if no data * refactor(graph and heatmap): move shared code into app/core * graph: add tests for histogram mode
This commit is contained in:
committed by
Torkel Ödegaard
parent
e6cc5df9d9
commit
7e14797b10
@@ -5,6 +5,7 @@ import $ from 'jquery';
|
||||
import moment from 'moment';
|
||||
import kbn from 'app/core/utils/kbn';
|
||||
import {appEvents, contextSrv} from 'app/core/core';
|
||||
import {tickStep} from 'app/core/utils/ticks';
|
||||
import d3 from 'd3';
|
||||
import {HeatmapTooltip} from './heatmap_tooltip';
|
||||
import {convertToCards, mergeZeroBuckets, removeZeroBuckets} from './heatmap_data_converter';
|
||||
@@ -836,29 +837,6 @@ function grafanaTimeFormat(ticks, min, max) {
|
||||
return "%H:%M";
|
||||
}
|
||||
|
||||
// Calculate tick step.
|
||||
// Implementation from d3-array (ticks.js)
|
||||
// https://github.com/d3/d3-array/blob/master/src/ticks.js
|
||||
function tickStep(start, stop, count) {
|
||||
var e10 = Math.sqrt(50),
|
||||
e5 = Math.sqrt(10),
|
||||
e2 = Math.sqrt(2);
|
||||
|
||||
var step0 = Math.abs(stop - start) / Math.max(0, count),
|
||||
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
|
||||
error = step0 / step1;
|
||||
|
||||
if (error >= e10) {
|
||||
step1 *= 10;
|
||||
} else if (error >= e5) {
|
||||
step1 *= 5;
|
||||
} else if (error >= e2) {
|
||||
step1 *= 2;
|
||||
}
|
||||
|
||||
return stop < start ? -step1 : step1;
|
||||
}
|
||||
|
||||
function logp(value, base) {
|
||||
return Math.log(value) / Math.log(base);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user