nodesnim/core/chartdata

Types

ChartDataValue = object
  case kind*: ChartDataValueType
  of INTEGER_VALUE:
      ival*: int

  of FLOAT_VALUE:
      fval*: float

  of STRING_VALUE:
      sval*: string

  of CHAR_VALUE:
      cval*: char

  
ChartData = ref object
  chart_type*: ChartType
  data_color*: ColorRef
  data_name*: string
  x_axis*: seq[ChartDataValue]
  y_axis*: seq[ChartDataValue]

Procs

proc newChartData(data_name: string = "data"; data_color: ColorRef = Color();
                  chart_type: ChartType = LINE_CHART): ChartData {...}{.raises: [],
    tags: [].}
Creates a new empty ChartData.

Example:

var my_chart_data = newChartData()
proc newChartData(x_length, y_length: int; data_name: string = "data";
                  data_color: ColorRef = Color();
                  chart_type: ChartType = LINE_CHART): ChartData {...}{.raises: [],
    tags: [].}

Creates a new ChartData with specified length.

Arguments:

  • x_length -- length of x_axis;
  • y_length -- length of y_axis.

Example:

var my_chart_data1 = newChartData(5, 5)
proc newChartData(x_data, y_data: seq[ChartDataValue];
                  data_name: string = "data"; data_color: ColorRef = Color();
                  chart_type: ChartType = LINE_CHART): ChartData {...}{.raises: [],
    tags: [].}

Creates a new ChartData from specified data.

Arguments:

  • x_data -- specified data for x_axis;
  • y_data -- specified data for y_axis.

Example:

var my_chart_data2 = newChartData(@[1, 5, 2], @["10.10.2021", "10.11.2021", "10.01.2021"])
proc findMax(data: seq[ChartDataValue]): ChartDataValue {...}{.raises: [], tags: [].}
Returns max value from sequence.
proc findMax(chart_data: ChartData): tuple[x, y: ChartDataValue] {...}{.raises: [],
    tags: [].}
Returns max values from ChartData.
proc len(data: ChartData): int {...}{.raises: [], tags: [].}
Returns length of the data.
proc getNum(val: ChartDataValue): float {...}{.raises: [], tags: [].}
Returns numeric value of the chart data value.
proc `$`(val: ChartDataValue): string {...}{.raises: [], tags: [].}
proc getSorted(data: ChartData): seq[tuple[x, y: ChartDataValue]] {...}{.raises: [],
    tags: [].}
proc getSum(data: ChartData): float {...}{.raises: [], tags: [].}

Converters

converter toChartDataValue(val: seq[int]): seq[ChartDataValue] {...}{.raises: [],
    tags: [].}
converter toChartDataValue(val: seq[float]): seq[ChartDataValue] {...}{.raises: [],
    tags: [].}
converter toChartDataValue(val: seq[string]): seq[ChartDataValue] {...}{.raises: [],
    tags: [].}
converter toChartDataValue(val: seq[char]): seq[ChartDataValue] {...}{.raises: [],
    tags: [].}