Manual Reference Source
public class | source

Graph

Extends:

react~Component → Graph

Graph is a component to present data in form of line or bar charts. Up to Graph.MAX_NUMBER_OF_CHARTS charts can be displayed within one Graph component.

Data (data prop) is an array in the following format:

[
    {
         <xDataKey>: <X data value 1>,
         <y1DataKey>: <Y1 data value 1>,
         <y2DataKey>: <Y2 data value 1>,
         <y3DataKey>: <Y3 data value 1>
    },
    {
         <xDataKey>: <X data value 2>,
         <y1DataKey>: <Y1 data value 2>,
         <y2DataKey>: <Y2 data value 2>,
         <y3DataKey>: <Y3 data value 2>
    },
    ...
]

Chart configuration (charts prop) is an array in the following format:

[
     {
          name: <y1DataKey>,
          label: <Chart1Label>,
          axisLabel: <Chart1AxisLabel>,
     },
     {
          name: <y1DataKey>,
          label: <Chart1Label>,
          axisLabel: <Chart1AxisLabel>,
     },
     ...
]

Up to Graph.MAX_NUMBER_OF_CHARTS charts can be defined in charts configuration array.

Access

Stage.Basic.Graphs.Graph

Usage

Bar chart

Graph 0

let data = [
    {time: '10:00', value: 300},
    {time: '11:00', value: 100},
    {time: '12:00', value: 80},
    {time: '13:00', value: 40},
    {time: '14:00', value: 30}
];
return (<Graph dataTimeFormat='HH:mm' charts={[{name:'value', label:'Number of fruits', axisLabel:''}]} data={data} type={Graph.BAR_CHART_TYPE} />);

Line chart

Graph 1

let data = [
     {time: '17:30', value: 1},
     {time: '17:40', value: 2},
     {time: '17:50', value: 1},
     {time: '18:00', value: 3},
     {time: '18:10', value: 5},
     {time: '18:20', value: 8},
     {time: '18:30', value: 5}
];
return (<Graph dataTimeFormat='HH:mm' charts={[{name:'value', label:'CPU load'}]} data={data} type={Graph.LINE_CHART_TYPE} />);

Area chart

Graph 2

let data = [
     {time: '17:30', value: 1},
     {time: '17:40', value: 2},
     {time: '17:50', value: 1},
     {time: '18:00', value: 3},
     {time: '18:10', value: 5},
     {time: '18:20', value: 8},
     {time: '18:30', value: 5}
];
return (<Graph charts={[{name:'value', label='CPU load'}]} data={data} type={Graph.AREA_CHART_TYPE} />);

Line chart - multi-charts, one Y-axis per chart

Graph 3

let data = [
     {cpu_total_system: 3.5,
      loadavg_processes_running: 3.071428571428572,
      memory_MemFree: 146003090.2857143,
      time: "2017-09-26 11:00:00"},
     ...
];

let charts = [
     {name: "cpu_total_system", label: "CPU - System [%]", axisLabel:""},
     {name: "memory_MemFree", label: "Memory - Free [Bytes]", axisLabel:""},
     {name: "loadavg_processes_running", label: "Load [%]", axisLabel:""}
]

return (<Graph charts={charts} data={data} type={Graph.LINE_CHART_TYPE} />);

Line chart - multi-charts, one Y-axis

Graph 4

let data = [
     {cpu_total_system: 3.5,
      cpu_total_user: 5.23,
      loadavg_processes_running: 3.071428571428572,
      time: "2017-09-26 11:20:00"},
     ...
];

let charts = [
     {name: "metrics", label: "metrics", axisLabel:"", fieldNames: ["cpu_total_system","cpu_total_user","loadavg_processes_running"]}
]

return (<Graph charts={charts} data={data} type={Graph.LINE_CHART_TYPE} />);

Static Member Summary

Static Public Members
public static

area chart

public static

bar chart

public static

default X-axis data key

public static

line chart

public static

maximum number of charts

public static

propTypes

Static Public Members

public static AREA_CHART_TYPE: * source

area chart

public static BAR_CHART_TYPE: * source

bar chart

public static DEFAULT_X_DATA_KEY: * source

default X-axis data key

public static LINE_CHART_TYPE: * source

line chart

public static MAX_NUMBER_OF_CHARTS: * source

maximum number of charts

public static propTypes: * source

propTypes

Properties:

NameTypeAttributeDescription
data object[]

charts input data (see class description for the format details)

type string

graph chart type (Graph.LINE_CHART_TYPE, Graph.BAR_CHART_TYPE or Graph.AREA_CHART_TYPE)

charts object[]

charts configuration (see class description for format details)

xDataKey string
  • optional
  • default: Graph.DEFAULT_X_DATA_KEY

X-axis key name, must match key in data object

showXAxis boolean
  • optional
  • default: true

should show X-axis

showYAxis boolean
  • optional
  • default: true

should show Y-axis

showBrush boolean
  • optional
  • default: false

should show brush (zoom)

showTooltip boolean
  • optional
  • default: true

should show tooltip on line

showLegend boolean
  • optional
  • default: true

should show legend

dataTimeFormat string
  • optional
  • default: undefined

input date format, by default not specified

xAxisTimeFormat string
  • optional
  • default: 'DD-MM-YYYY HH:mm'

format of X-axis tick label

xAxisTick object
  • optional
  • default: {fontSize:'10px'}

stylesheet for X-axis tick

yAxisTick object
  • optional
  • default: {fontSize:'10px'}

stylesheet for Y-axis tick

tooltipFormatter object
  • optional
  • default: undefined

callback function to format the text of the tooltip

yAxisAllowDecimals boolean
  • optional
  • default: true

whether to allow decimals in Y-axis tick

yAxisDataFormatter object
  • optional
  • default: undefined

format of Y-axis tick label