mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
vmui: correct calc axes limits (#2058)
* fix: correct calc axes limits * app/vmselect/vmui: `make vmui-update` Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
This commit is contained in:
parent
ca11def2a5
commit
8e3f9c1fbb
7 changed files with 14 additions and 8 deletions
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"files": {
|
||||
"main.css": "./static/css/main.79ff1ad2.css",
|
||||
"main.js": "./static/js/main.2473acb3.js",
|
||||
"main.js": "./static/js/main.b46d35b9.js",
|
||||
"static/js/27.cc1b69f7.chunk.js": "./static/js/27.cc1b69f7.chunk.js",
|
||||
"index.html": "./index.html"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/css/main.79ff1ad2.css",
|
||||
"static/js/main.2473acb3.js"
|
||||
"static/js/main.b46d35b9.js"
|
||||
]
|
||||
}
|
|
@ -1 +1 @@
|
|||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="VM-UI is a metric explorer for Victoria Metrics"/><link rel="apple-touch-icon" href="./apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="./favicon-32x32.png"><link rel="manifest" href="./manifest.json"/><title>VM UI</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><script defer="defer" src="./static/js/main.2473acb3.js"></script><link href="./static/css/main.79ff1ad2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="VM-UI is a metric explorer for Victoria Metrics"/><link rel="apple-touch-icon" href="./apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="./favicon-32x32.png"><link rel="manifest" href="./manifest.json"/><title>VM UI</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><script defer="defer" src="./static/js/main.b46d35b9.js"></script><link href="./static/css/main.79ff1ad2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
File diff suppressed because one or more lines are too long
2
app/vmselect/vmui/static/js/main.b46d35b9.js
Normal file
2
app/vmselect/vmui/static/js/main.b46d35b9.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@ import uPlot, {AlignedData as uPlotData, Options as uPlotOptions, Series as uPlo
|
|||
import {useGraphState} from "../../state/graph/GraphStateContext";
|
||||
import {defaultOptions} from "../../utils/uplot/helpers";
|
||||
import {dragChart} from "../../utils/uplot/events";
|
||||
import {getAxes} from "../../utils/uplot/axes";
|
||||
import {getAxes, getMinMaxBuffer} from "../../utils/uplot/axes";
|
||||
import {setTooltip} from "../../utils/uplot/tooltip";
|
||||
import {MetricResult} from "../../api/types";
|
||||
import {limitsDurations} from "../../utils/time";
|
||||
|
@ -87,7 +87,7 @@ const LineChart: FC<LineChartProps> = ({data, series, metrics = []}) => {
|
|||
const getRangeX = (): Range.MinMax => [xRange.min, xRange.max];
|
||||
const getRangeY = (u: uPlot, min = 0, max = 1, axis: string): Range.MinMax => {
|
||||
if (yaxis.limits.enable) return yaxis.limits.range[axis];
|
||||
return min && max ? [min - (min * 0.25), max + (max * 0.25)] : [-1, 1];
|
||||
return getMinMaxBuffer(min, max);
|
||||
};
|
||||
|
||||
const getScales = (): Scales => {
|
||||
|
|
|
@ -19,13 +19,19 @@ export const getTimeSeries = (times: number[], defaultStep: number, period: Time
|
|||
return new Array(length*2).fill(startTime).map((d, i) => roundTimeSeconds(d + (defaultStep * i)));
|
||||
};
|
||||
|
||||
export const getMinMaxBuffer = (min: number, max: number): [number, number] => {
|
||||
const minCorrect = min || -1;
|
||||
const maxCorrect = max || 1;
|
||||
return [minCorrect - (Math.abs(minCorrect) * 0.25), maxCorrect + (Math.abs(maxCorrect) * 0.25)];
|
||||
};
|
||||
|
||||
export const getLimitsYAxis = (values: { [key: string]: number[] }): AxisRange => {
|
||||
const result: AxisRange = {};
|
||||
for (const key in values) {
|
||||
const numbers = values[key];
|
||||
const min = getMinFromArray(numbers);
|
||||
const max = getMaxFromArray(numbers);
|
||||
result[key] = min && max ? [min - (min * 0.25), max + (max * 0.25)] : [-1, 1];
|
||||
result[key] = getMinMaxBuffer(min, max);
|
||||
}
|
||||
return result;
|
||||
};
|
Loading…
Reference in a new issue