Autoscale histogram views
This commit is contained in:
parent
721376e02c
commit
4760ff97e0
@ -40,11 +40,12 @@ pub struct HeatmapRect {
|
|||||||
density: f64,
|
density: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct HistogramWindow {
|
pub struct HistogramWindow {
|
||||||
pub heatmap: Vec<HeatmapRect>,
|
pub heatmap: Vec<HeatmapRect>,
|
||||||
pub min_density: f64,
|
pub min_density: f64,
|
||||||
pub max_density: f64,
|
pub max_density: f64,
|
||||||
|
pub y_axis: RangeInclusive<f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
@ -62,12 +63,15 @@ impl UnsummarisedHistogramWindow {
|
|||||||
|
|
||||||
let mut min_density = f64::INFINITY;
|
let mut min_density = f64::INFINITY;
|
||||||
let mut max_density = f64::NEG_INFINITY;
|
let mut max_density = f64::NEG_INFINITY;
|
||||||
|
let mut min_val = f64::INFINITY;
|
||||||
|
let mut max_val = f64::NEG_INFINITY;
|
||||||
|
|
||||||
for (xa, xb, hist) in self.map.iter() {
|
for (xa, xb, hist) in self.map.iter() {
|
||||||
let min_val = hist.min();
|
let min_this_slice = hist.min();
|
||||||
let max_val = hist.max();
|
min_val = min_val.min(min_this_slice as f64);
|
||||||
|
max_val = max_val.max(hist.max() as f64);
|
||||||
|
|
||||||
let mut prev = min_val;
|
let mut prev = min_this_slice;
|
||||||
for q in (1..=10).map(|i| i as f64 * 0.1) {
|
for q in (1..=10).map(|i| i as f64 * 0.1) {
|
||||||
// TODO improve this. It's going to be a bit off because of the way that
|
// TODO improve this. It's going to be a bit off because of the way that
|
||||||
// numbers can be 'equivalent' etc ...
|
// numbers can be 'equivalent' etc ...
|
||||||
@ -95,17 +99,21 @@ impl UnsummarisedHistogramWindow {
|
|||||||
//debug!("hist min {:?} max {:?}", hist.min(), hist.max());
|
//debug!("hist min {:?} max {:?}", hist.min(), hist.max());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let y_axis = min_val..=max_val;
|
||||||
|
debug!("yaxis {:?}", y_axis);
|
||||||
HistogramWindow {
|
HistogramWindow {
|
||||||
heatmap,
|
heatmap,
|
||||||
min_density,
|
min_density,
|
||||||
max_density,
|
max_density,
|
||||||
|
y_axis,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ScalarWindow {
|
pub struct ScalarWindow {
|
||||||
points: Vec<(UnixTimestampMilliseconds, f64)>,
|
pub points: Vec<(UnixTimestampMilliseconds, f64)>,
|
||||||
|
pub y_axis: RangeInclusive<f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MetricsLogReadingRequester {
|
pub struct MetricsLogReadingRequester {
|
||||||
@ -392,12 +400,22 @@ impl<R: Read + Seek> MetricsLogReaderManager<R> {
|
|||||||
histograms.insert(*metric_id, Default::default());
|
histograms.insert(*metric_id, Default::default());
|
||||||
}
|
}
|
||||||
MetricKind::Gauge => {
|
MetricKind::Gauge => {
|
||||||
metrics_window.gauges.insert(*metric_id, Default::default());
|
metrics_window.gauges.insert(
|
||||||
|
*metric_id,
|
||||||
|
ScalarWindow {
|
||||||
|
points: vec![],
|
||||||
|
y_axis: 0.0..=0.0,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
MetricKind::Counter => {
|
MetricKind::Counter => {
|
||||||
metrics_window
|
metrics_window.counters.insert(
|
||||||
.counters
|
*metric_id,
|
||||||
.insert(*metric_id, Default::default());
|
ScalarWindow {
|
||||||
|
points: vec![],
|
||||||
|
y_axis: 0.0..=0.0,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -707,7 +725,18 @@ impl Graph {
|
|||||||
|
|
||||||
// This range is reversed because screen coordinates go down, but we'd like them to go
|
// This range is reversed because screen coordinates go down, but we'd like them to go
|
||||||
// up since this is more of a mathematical graph.
|
// up since this is more of a mathematical graph.
|
||||||
let y_axis = 300.0..=0.0;
|
let y_axis = if let Some(histogram) = current_window.histograms.get(&metric_id) {
|
||||||
|
histogram.y_axis.clone().into_inner()
|
||||||
|
} else if let Some(scalar) = current_window
|
||||||
|
.counters
|
||||||
|
.get(&metric_id)
|
||||||
|
.or_else(|| current_window.gauges.get(&metric_id))
|
||||||
|
{
|
||||||
|
scalar.y_axis.clone().into_inner()
|
||||||
|
} else {
|
||||||
|
(0.0, 10.0)
|
||||||
|
};
|
||||||
|
let y_axis = (y_axis.1)..=(y_axis.0);
|
||||||
|
|
||||||
// let display_transform =
|
// let display_transform =
|
||||||
// emath::RectTransform::from_to(Rect::from_x_y_ranges(x_axis, y_axis), display_rect);
|
// emath::RectTransform::from_to(Rect::from_x_y_ranges(x_axis, y_axis), display_rect);
|
||||||
|
Loading…
Reference in New Issue
Block a user