본문 바로가기
컴퓨터|인터넷/라즈베리파이

Node-red: Chart in dashboard

by 즐거운 지니 2024. 10. 3.
반응형

이 예제는 https://github.com/node-red/node-red-dashboard/blob/master/Charts.md 에서 제공합니다.

각 차트에 넘겨지는 데이터의 포멧을 function노드를 통해 확인할 수 있습니다.

Time Line 1 이 제공하는 함수

var chart = [{
    "series":["A","B","C"],
    "data":[[{"x":1504029632890,"y":5},{"x":1504029636001,"y":4},{"x":1504029638656,"y":2}],[{"x":1504029633514,"y":6},{"x":1504029636622,"y":7},{"x":1504029639539,"y":6}],[{"x":1504029634400,"y":7},{"x":1504029637959,"y":9},{"x":1504029640317,"y":7}]],
    "labels":[""]
}];
msg.payload = chart;

return msg;

Time Line 2 가 제공하는 함수

var chart = [{
    "series":["A","B","C"],
        "data":[[{"x":1,"y":5},{"x":2,"y":4},{"x":3,"y":2}],[{"x":4,"y":6},{"x":5,"y":7},{"x":6,"y":6}],[{"x":7,"y":7},{"x":8,"y":9},{"x":9,"y":7}]],
    "labels":[""]
}];
msg.payload = chart;

return msg;

Time Line 3 이 제공하는 함수

 

var chart = [{
    "series":["A","B","C"],
        "data":[[{"x":1000000,"y":5},{"x":2000000,"y":4},{"x":3000000,"y":2}],[{"x":4000000,"y":6},{"x":5000000,"y":7},{"x":6000000,"y":6}],[{"x":7000000,"y":7},{"x":8000000,"y":9},{"x":9000000,"y":7}]],
    "labels":[""]
}];
msg.payload = chart;

return msg;

Time Line 4 가 제공하는 함수

var chart = [{
    "series":["A","B","C"],
        "data":[[{"x":1000000000,"y":5},{"x":2000000000,"y":4},{"x":3000000000,"y":2}],[{"x":4000000000,"y":6},{"x":5000000000,"y":7},{"x":6000000000,"y":6}],[{"x":7000000000,"y":7},{"x":8000000000,"y":9},{"x":9000000000,"y":7}]],
    "labels":[""]
}];
msg.payload = chart;

return msg;

ARRAY 가 제공하는 함수

var m={};
m.labels = ["January", "February", "March", "April", "May", "June", "July"];
m.series = ['Series A', 'Series B', 'Series C'];
m.data = [
    [65, 59, 80, 81, 56, 55, 40],
    [28, 48, 40, 19, 86, 27, 90],
    [38, 28, 20, 49, 45, 60, 20]
  ];
return {payload:[m]};

ARRAY2 가 제공하는 함수

var m={};
m.labels = [10,20,30,40,50,60,70];
m.series = ['Series A', 'Series B', 'Series C', 'Series D'];
m.data = [
    [65, 59, 80, 81, 56, 55, 40],
    [28, 48, 40, 19, 86, 27, 90],
    [38, 28, 20, 49, 45, 60, 20],
    [58, 18, 40, 29, 15, 30, 60]
  ];
return {payload:[m]};

ARRAY3A가 제공하는 함수

var m={
    "series":["X","Y","Z"],
    "data":[[5],[3],[6]],
    "labels":["Jan"]
};
return {payload:[m]};

ARRAY3B가 제공하는 함수

var m={
    "series":["X"],
    "data":[[5,3,6]],
    "labels":["Jan","Feb","Mar"]
};
return {payload:[m]};

ARRAY3C가 제공하는 함수

var m={
    "series":["X","Y","Z"],
    "data":[[5,6,9],[3,8,5],[6,7,2]],
    "labels":["Jan","Feb","Mar"]
};
return {payload:[m]};

ARRAY FOR PIE가 제공하는 함수

var m = {};
m.labels = ["Download", "In-Store", "Mail-Order"];
m.data = [[300, 500, 100]];
m.series = ["Sales"];
return {payload:[m],topic:msg.topic};

ARRAY 2 FOR PIE가 제공하는 함수

var m = {};
m.labels = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];
m.data = [[28, 48, 40, 19, 86, 27, 90]];
m.series = ['Series A'];
return {payload:[m],topic:msg.topic};

 

반응형

댓글