fix charts scales
Gitea Actions Demo / build_and_push (push) Successful in 1m11s Details

This commit is contained in:
artem 2025-02-15 11:28:35 +03:00
parent 976a0b8276
commit 613df1271c
3 changed files with 29 additions and 12 deletions

View File

@ -51,16 +51,16 @@ export const GetWorkout = (url: string) => {
mapCenter = [coords[0][0], coords[0][1]];
let datasets = [];
if (speed.length > 0) {
datasets.push({yAxisID: 'linear-y-axis', radius: 0, label: 'Скорость', borderColor: '#00aa00', backgroundColor: '#00aa00', data: speed });
datasets.push({yAxisID: 'linearYSpeed', radius: 0, label: 'Скорость', borderColor: '#00aa00', backgroundColor: '#00aa00', data: speed });
}
if (heart_rate.length > 0) {
datasets.push({yAxisID: 'linear-y-axis', radius: 0, label: 'Пульс', borderColor: '#990000', backgroundColor: '#990000', data: heart_rate, });
datasets.push({yAxisID: 'linearAxis', radius: 0, label: 'Пульс', borderColor: '#990000', backgroundColor: '#990000', data: heart_rate, });
}
if (power.length > 0) {
datasets.push({yAxisID: 'log-y-axis', radius: 0, label: 'Мощность', borderColor: '#cccccc', backgroundColor: '#cccccc', data: power, });
datasets.push({yAxisID: 'logAxis', radius: 0, label: 'Мощность', borderColor: '#cccccc', backgroundColor: '#cccccc', data: power, });
}
if (elevation.length > 0) {
datasets.push( {yAxisID: 'linear-y-ground', radius: 0, label: 'Подъем', borderColor: '#000', backgroundColor: '#000', data: elevation, });
datasets.push( {yAxisID: 'yGroung', radius: 0, label: 'Подъем', borderColor: '#000', backgroundColor: '#000', data: elevation, });
}
data = {
labels: times,

View File

@ -34,8 +34,8 @@ class LineWithLineController extends LineController {
public override draw() {
super.draw()
const ctx = this.chart.ctx;
const topY = this.chart.scales.y.top;
const bottomY = this.chart.scales.y.bottom;
const topY = this.chart.scales.linearAxis.top;
const bottomY = this.chart.scales.linearAxis.bottom;
// @ts-ignore
let zoom = (this.chart.chartArea.right - this.chart.chartArea.left) / this.chart.config.data.labels.length;
const xVertical = this.getMapX();

View File

@ -213,21 +213,37 @@ const chartPlugins = [
}
];
const chartOptions = {
animation: {
duration: 0
},
responsive: true,
scales: {
y: {
linearAxis: {
id: 'linearAxis',
type: 'linear',
display: false,
position: 'left',
id: 'linear-y-axis',
animation:true,
},
linearYSpeed: {
id: 'linearYSpeed',
type: 'linear',
display: false,
position: 'right',
suggestedMin: 0,
suggestedMax: 80,
animation:true,
scaleOverride:true,
},
yGroung: {
id: 'yGroung',
type: 'linear',
display: false,
display: true,
position: 'left',
id: 'linear-y-ground',
animation:false,
},
yAxes: {
logAxis: {
id: 'logAxis',
display: false,
type: 'logarithmic',
position: 'right',
@ -238,9 +254,10 @@ const chartOptions = {
gridLines: {
display: true
},
id: 'log-y-axis',
animation:false,
},
x: {
animation:false,
type: 'time',
time: {
displayFormats: { hour: 'HH:mm' }