Transformation code for evaluations

This text describes how transformation codes are used in evaluations to prepare lab data for Highcharts charts or complex tables, including detailed information on data structures and formatting options.

In evaluations, the function can either prepare data for Highcharts or assemble it for a more complex table. The data parameter here is always an array of objects with the result from the SQL evaluation.

[
  {
    "Probe": "P01",
    "Messwert": 0.31
  },
  {
    "Probe": "P02",
    "Messwert": 1.44
  }
]

If data for a chart is to be provided, the return value must be an object whose keys are then used in Highcharts. These can be accessed as variables with the prefix _TRANSFORM_.

/**
 * @param {any} data
 * @return {object}
 */
function transform (data) {
  return {
    series: data.map(d => ({ y: parseFloat(d.Messwert) * -1, Probe: d.Probe }))
  }
}

In this case, _TRANSFORM_SERIES_ would be usable in the Highcharts configuration and would contain the data for a series.

Additional Functions
Chart transformation codes also have the ability to provide functions for Highcharts configurations, as the configuration is a pure JSON object and therefore cannot contain Javascript functions. For these to be used, they must have the prefix _HC_.

Example:

function _HC_ClickHandler () {
  window.location.href = `/demo/samples/view/${this.sampleID}`
}

Variables from the Evaluation
Variables from the evaluation such as _VAR0_, _VAR1_, etc. are replaced in the code with the given values, which then makes something like this possible:

const title = `Evaluation for Sample _VAR0_`

Tables
If a table is to be built here, two keys in the returned object are crucial:

  • rows
  • titleRows (optional)

rows must be an Array containing objects whose keys represent the column titles. This means an Array of this type

{
  "rows": [
    {
      "Probe": "X0001",
      "Anmerkung": "X-ray measurement",
      "Messwert": 0.31
    },
    {
      "Probe": "X0002",
      "Anmerkung": "X-ray measurement",
      "Messwert": 1.41
    }
  ]
}

becomes a table with this structure

Sample Remark Measured Value
X0001 X-ray measurement 0.31
X0002 X-ray measurement 1.41

titleRows can optionally specify additional title columns. This is particularly useful if you want to use advanced formatting options such as colSpan. titleRows is an Array of arrays, where each entry represents a title row. An entry in the title row can either be a String that simply carries the title of the column, or an object if multiple options are desired. This is structured as follows:

  • title: Title of the column
  • colspan: Colspan attribute
  • width: Column width (in px)

Hier ein Beispiel:

{
  "titleRows": [
    [
      {
        "title": "X-ray Measurements",
        "colspan": 3,
        "width": 30,
        "align": "center"
      }
    ],
    [
      "Sample",
      "Remark",
      "Measured Value"
      ]
  ],
  "rows": [
    [ "X0001", "X-ray measurement", 0.32 ],
    [ "X0002", "X-ray measurement", 0.11 ]
  ]
}

This setting for titleRows yields the following table:

X-ray Measurements

Sample Remark Measured Value
X0001 X-ray measurement 1.32
X0002 X-ray measurement 1.11

Tables in Reports - Transformation Code in Report Tables

The structure of the arrays (for rows and titleRows) corresponds to the structure of the arrays in the evaluations (See above - Tables section).

  • rows
  • titleRows (optional)

An entry in the title row can either be a String that simply carries the title of the column, or an object if multiple options are desired. This is structured as follows:

  • title: Title of the column
  • colspan: Colspan attribute
  • width: Column width (in mm)
  • align: 'C' for Center, 'L' for Left, 'R' for Right

If, for example, only 1-2 columns are defined with width, the remaining column widths adapt dynamically to the page width (frame of the PDF template).

Continue with: Export transformation code

Last change: 22.08.2025

Allgemeines

Einführungsphase

Auswertungen

Mitarbeiter

Aufträge

Proben

Probenvorlage

Berichte

Kunden

Berichtstabellen Editor

Kundenzone (optional)

Anlagen

Angebote

Rechnungen

Parameter

Rechnen mit Parametern

Schnittstellen

Webservice

Transformationscode

Prüfpläne / Grenzwerte / Spezifikationen

Dokumentenlenkung

Prüfmittel

Material

Mitarbeiterschulungen

8D-Report

Sonstiges

PDF-Vorlagen

Fragen und Antworten

Lieferantenbewertung

Dateiverwaltung

Prozesse