ABeamer 0.3.1 includes chart series as expressions, allowing to plot mathematical functions.
The standard library now also includes log, log10 and exp.
And also:

  • Fixed the chart legend color for line charts. Previously it used fillColor for the legend in line charts.
  • Fixed chart labelsY when there is not enough y-space created by labelsX. Previously if labelsX weren’t defined the first y-label would be cut from the chart.

Chart Series as Expressions

Before version 0.3.1, ABeamer only supported data series defined as numerical arrays.

scene
    .addAnimations([{
      selector: `canvas`,
      tasks: [{
        handler: 'chart',
        params: {
          chartType: ABeamer.ChartTypes.line,
          data: [[10,20,30,40,50,60,70,80,90]],
        } as ABeamer.AxisChartTaskParams,
      }],
    }])

To plot a mathematical equation in a chart, it was required to write typescript/javascript code to build the data series.

  const series=[];

  for (let i = 0; i < 9; i++) {
    series.push((i + 1)*10);
  }

scene
    .addAnimations([{
      selector: `canvas`,
      tasks: [{
        handler: 'chart',
        params: {
          chartType: ABeamer.ChartTypes.line,
          data: [series],
        } as ABeamer.AxisChartTaskParams,
      }],
    }])

The above example works and is teleportable since it’s not a Code Handler, but when the story is stored on story.json the javascript code is lost and there is no information regarding the equation itself.
With the support of Chart Series as Expressions, now is Chart data can be defined as an expression.

scene
    .addAnimations([{
      selector: `canvas`,
      tasks: [{
        handler: 'chart',
        params: {
          chartType: ABeamer.ChartTypes.line,
          data: [{
            expr: `=(v+1)*10`,
            nrPoints: 50,
          }] as ABeamer.ExprSeries[],
        } as ABeamer.AxisChartTaskParams,
      }],
    }])

This way is simpler to create mathematical equation plots. ABeamer provides v as the iterator variable. More parameters are available, read further details on chart documentation.

But the work isn’t finished yet since the labelX are still directly tied to the data points, and in the case of many data points which is usually the case in mathematical equation plots, the labels will overlap make them useless, so the next step is decouple the labelX from the data points.