A KontrastData property connects data (i.e. numbers, arrays of numbers or, in some cases, strings) to axes. Each plot (points, lines, bars, etc.) has a data property of that type.

Data updates

Data often needs to be updated dynamically (for example when data is changed as the result of some user interaction).

Once you assign data to a plot, all the data is copied and stored internally. The following code assigns an array of numbers as data for the axis named 'x':

The array (with values [1, 2, 3, 4, 5]) is stored internally by Kontrast as soon as the above assignment is executed.

If you want to change the data and the visualization, you need to

  1. change the value(s) in the array and
  2. tell Kontrast to update the visualization.

Note that just changing the data (step 1) alone does not update the visualization. Kontrast does not watch for changes of the data and does not automatically update the internally stored data used for the visualization. This is the intended/desired behavior, as it prevents unintended side effects. As a consequence, you (as the creator of an interactive visualization) are responsible of explicit updates of the visualized data.

There are two ways of telling Kontrast to update the visualization: