# Can not change the x-as of line chart chart-image

**URL:** <https://discourse.nodered.org/t/can-not-change-the-x-as-of-line-chart-chart-image/86806>\
**Category:** General\
**Tags:** chart\
**Created:** [27 March 2024 13:29 UTC](https://discourse.nodered.org/t/can-not-change-the-x-as-of-line-chart-chart-image/86806 "2024-03-27T13:29:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![robbe.haerens](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@robbe.haerens](https://discourse.nodered.org/u/robbe.haerens)\
**Post date:** [27 March 2024 13:29 UTC](https://discourse.nodered.org/t/can-not-change-the-x-as-of-line-chart-chart-image/86806/1 "2024-03-27T13:29:52Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e3f5940bbc6da77562a2d73680fbe1021ea52974.png)  
righ now i am trying to make a line chart from a csv with a value on every row. this works at the moment all the values are nicely included in the linechart. but when i want to put the x-axis with values from 00 to 23, i only get the first 24 values in the line chart so than it's not a line chart from the full file but only from the first 24 rows. The meaning is that i have a line chart that uses all the values in the csv and the x-axis is hardcoded from 00 - 23. this is the code i am using right now.

// Haal de gegevens op uit msg.payload  
let csvData = msg.payload.trim(); // Trim whitespace om eventuele lege regels te verwijderen  
let lines = csvData.split("\n"); // Split de gegevens op elke nieuwe regel

// Maak een array om de gegevens in te bewaren  
let data = ;

// Loop door elke regel en converteer naar een getal  
lines.forEach(line =\> {  
// Vervang commas door periods voor decimalen  
line = line.replace(',', '.');  
let value = parseFloat(line.trim()); // Trim whitespace om eventuele extra spaties te verwijderen  
if (!isNaN(value)) {  
data.push(value); // Voeg het getal toe aan de dataset als het een geldig getal is  
}  
});

// Bereid de x-aslabels voor (van 00 tot 24)  
let labels = Array.from({ length: data.length }, (\_, i) =\> ('00' + i).slice(-2));

// Maak een nieuw object voor de grafiek  
let chartData = {  
type: 'line',  
data: {  
labels: labels, // Labels van 00 tot 24  
datasets: [{  
label: "Evolutie",  
borderColor: 'red',  
pointRadius: 0,  
fill: false,  
data: data // Gegevens voor de enkele lijn  
}]  
},  
options: {  
title: {  
display: true,  
text: 'Evolutie over tijd'  
},  
legend: {  
display: false  
},  
scales: {  
x: {  
display: false, // Verberg de x-as  
},  
y: {  
display: false // Zorg ervoor dat de y-as niet wordt weergegeven  
}  
},  
chartArea: {  
backgroundColor: 'white'  
},  
plugins: {  
datalabels: {  
display: false // Geen datalabels  
}  
}  
}  
};

// Stel de gegevens in voor de uitvoer  
msg.payload = chartData;

// Stuur het bericht terug  
return msg;

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 June 2024 13:30 UTC](https://discourse.nodered.org/t/can-not-change-the-x-as-of-line-chart-chart-image/86806/2 "2024-06-25T13:30:30Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
