Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="scichart-root" ></div>
  

              
            
!

CSS

              
                body { margin: 0; }
#scichart-root { width: 100%; height: 100vh; }
  

              
            
!

JS

              
                async function dataSeriesScrollingFifo(divElementId) {

  const {
    SciChartSurface,
    NumericAxis,
    FastLineRenderableSeries,
    XyDataSeries,
    SciChartJsNavyTheme,
    EAutoRange,
    libraryVersion
  } = SciChart;

  // or for npm import { SciChartSurface, ... } from "scichart"

  // Create a chart surface
  const { sciChartSurface, wasmContext } = await SciChartSurface.create(divElementId, {
    theme: new SciChartJsNavyTheme(),
    title: "Scrolling Data using fifoCapacity",
    titleStyle: { fontSize: 16 }
  });

  // For the example to work, axis must have EAutoRange.Always
  sciChartSurface.xAxes.add(new NumericAxis(wasmContext, { autoRange: EAutoRange.Always, axisTitle: "X Axis autoranged" }));
  sciChartSurface.yAxes.add(new NumericAxis(wasmContext, { autoRange: EAutoRange.Always, axisTitle: "Y Axis autoranged" }));

  // Start off with N X,Y values in the series
  const xValues = [];
  const yValues = [];
  let i = 0;
  for(; i < 1000; i++) {
    xValues.push(i);
    yValues.push(0.2 * Math.sin(i*0.1) - Math.cos(i * 0.01));
  }

  // #region ExampleA
  // Create a DataSeries
  const xyDataSeries = new XyDataSeries(wasmContext, {
    xValues,
    yValues,
    fifoCapacity: 1000 // set fifoCapacity to 1000. Requires scichart.js v3.2 or later
  });

  console.log(`version is ${libraryVersion}`);
  console.log(`dataSeries.fifoCapacity is ${xyDataSeries.fifoCapacity}`);

  // Create a renderableSeries and assign the dataSeries
  sciChartSurface.renderableSeries.add(new FastLineRenderableSeries(wasmContext, {
    dataSeries: xyDataSeries,
    strokeThickness: 3,
    stroke: "#50C7E0"
  }));

  // Now let's use a timeout to appendRange() new values every 20ms.
  // using removeRange() causes the number of points in the series to remain fixed and the chart to scroll
  const updateCallback = () => {
    const xUpdate = [];
    const yUpdate = [];
    for(let j = 0; j < 5; i++, j++) {
      xUpdate.push(i);
      yUpdate.push(0.2 * Math.sin(i*0.1) - Math.cos(i * 0.01));
    }
    // With fifoCapacity set, just append new points.
    xyDataSeries.appendRange(xUpdate, yUpdate);
    // result: dataSeries length remains the same. point counts > fifoCapacity are discarded.
    // as x-value increases, and xAxis.autoRange zooms to fit, the chart scrolls
  }

  setTimeout(() => {
    updateCallback();
    setInterval(updateCallback, 20);
  }, 20);
  // #endregion
}

dataSeriesScrollingFifo("scichart-root");




  

              
            
!
999px

Console