# Manipulate Vector for Dashboard Chart node

**URL:** <https://discourse.nodered.org/t/manipulate-vector-for-dashboard-chart-node/25298>\
**Category:** Core Development\
**Created:** [22 April 2020 11:41 UTC](https://discourse.nodered.org/t/manipulate-vector-for-dashboard-chart-node/25298 "2020-04-22T11:41:47Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [22 April 2020 13:25 UTC](https://discourse.nodered.org/t/manipulate-vector-for-dashboard-chart-node/25298/3 "2020-04-22T13:25:04Z")

</div>

Hi.

As you have provided no example data its impossible to demonstrate changing your data into the correct format.

All I can do is offer some advice in the form of an annotated screenshot and sample code...

FOREWORD - it looks far more complicated than it actually is. Also, the code is longhand to show you what is happening

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/1/b10110f953162623103fea60d93bb7375f38b24e.png)

```auto
//1. lets create a variable to hold the finished article...
let chartData = []; //See #1 - create an empty array

//2. lets create a variable to hold the everything...
let element1 = {}; //create element1 as an empty object {}

//3, now add the .property "series" to the element1 {object}
element1.series = []; // add a .property called series of type [array]
element1.series.push("A"); //add 1st array element "A"
element1.series.push("B"); //add another array element "B"
element1.series.push("C"); //add another array element "C"

//4. now add the .property "data" to the element1 {object}
element1.data = []; // add a .property called data of type [array]

/ ***********NEXT - ADDING DATA***************************
  NORMALLY, ADDING DATA WOULD BE DYNAMIC 
  PERHAPS LOOPING THROUGH AN ARRAY
  THIS EXAMPLE SHOWS ADDING HARD CODED VALUES
************************************************************ /
//4b. now we add 3 arrays to the data [array]
var dataElement1 = [];
var dataElement2 = [];
var dataElement3 = [];

//4c. now add the 3 {objects} inside each of the dataElements
dataElement1.push( { "x": 1504029632890, "y": 5 }); //add hard coded x & y values
dataElement1.push( { "x": 1504029636001, "y": 4 }); //add hard coded x & y values
dataElement1.push( { "x": 1504029638656, "y": 2 }); //add hard coded x & y values

dataElement2.push( { "x": 1504029633514, "y": 6 }); //add hard coded x & y values
dataElement2.push( { "x": 1504029636622, "y": 7 }); //add hard coded x & y values
dataElement2.push( { "x": 1504029639539, "y": 6 }); //add hard coded x & y values

dataElement3.push( { "x": 1504029634400, "y": 7 }); //add hard coded x & y values
dataElement3.push( { "x": 1504029637959, "y": 7 }); //add hard coded x & y values
dataElement3.push( { "x": 1504029640317, "y": 7 }); //add hard coded x & y values

//now we need to push the dataelements into the data [array]
element1.data.push(dataElement1);
element1.data.push(dataElement2);
element1.data.push(dataElement3);

/ ******************************************* /

//5. now add a labels [array] to element1
element1.labels = []; // add a .property called labels of type [array]
element1.labels.push(""); //add an empty string to the "labels" [array]

//Now add the element1 [array] into the chartData [array]
chartData.push(element1)

//Lastly, return the chartData as the payload 
msg.payload = chartData;
return msg;

```

Here you can see it in action...  
https://repl.it/@StephenMcLaughl/node-red-chart-data?lite=true

---

_[View the full topic](https://discourse.nodered.org/t/manipulate-vector-for-dashboard-chart-node/25298)._
