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]]; mapCenter = [coords[0][0], coords[0][1]];
let datasets = []; let datasets = [];
if (speed.length > 0) { 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) { 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) { 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) { 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 = { data = {
labels: times, labels: times,

View File

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

View File

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