Fix chart data issues: 24-hour format, Y-axis bounds, rounding modes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,6 +58,7 @@ export function setLineChartData(baseData, xMax, xMin, isPercent, yMax, yMin) {
|
||||
* @returns {number} The extrapolated and clamped Y minimum value.
|
||||
*/
|
||||
function calculateYMin(baseData, isPercent, yMin, yMax) {
|
||||
if (baseData.length < 2) return yMin;
|
||||
let a = 0;
|
||||
let c = 1;
|
||||
let d = baseData[0].y;
|
||||
@@ -77,6 +78,7 @@ function calculateYMin(baseData, isPercent, yMin, yMax) {
|
||||
* @returns {number} The extrapolated and clamped Y maximum value.
|
||||
*/
|
||||
function calculateYMax(baseData, isPercent, yMin, yMax) {
|
||||
if (baseData.length < 10) return yMax;
|
||||
let ma = 9;
|
||||
let mb = baseData[8].y;
|
||||
let mc = 10;
|
||||
@@ -119,12 +121,12 @@ function clampValue(value, isPercent, min, max) {
|
||||
* @param {Array<{x: string, y: number}>} baseData - The data points from
|
||||
* the backend with ISO timestamp x values.
|
||||
* @returns {Array<{x: string, y: number}>} Data with x values formatted
|
||||
* as "YYYY/M/D hh:mm:ss".
|
||||
* as "YYYY/M/D HH:mm:ss".
|
||||
*/
|
||||
export function setBarChartData(baseData) {
|
||||
let data = baseData.map((i) => {
|
||||
return {
|
||||
x: getMoment(i.x).format("YYYY/M/D hh:mm:ss"),
|
||||
x: getMoment(i.x).format("YYYY/M/D HH:mm:ss"),
|
||||
y: i.y,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user