This example demonstrates FastTextRenderableSeries using SciChart.js. The dataset is an AI analysis of 2100 tweets, extracting the organisations mentioned and the sentiment of the tweet.
import { appTheme } from "./appTheme";
import { baseUrl } from "./ExampleDataProvider";
import {
SciChartSurface,
NumericAxis,
NumberRange,
ZoomPanModifier,
ZoomExtentsModifier,
MouseWheelZoomModifier,
LogarithmicAxis,
ENumericFormat,
XyTextDataSeries,
FastTextRenderableSeries,
} from "scichart";
// tslint:disable:no-empty
export const drawExample = async (rootElement: string | HTMLDivElement) => {
// Create a SciChartSurface
const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
theme: appTheme.SciChartJsTheme,
});
const xAxis = new LogarithmicAxis(wasmContext, {
axisTitle: "Number of Tweets",
logBase: 2,
labelFormat: ENumericFormat.SignificantFigures,
growBy: new NumberRange(0, 0.1),
});
sciChartSurface.xAxes.add(xAxis);
sciChartSurface.yAxes.add(
new NumericAxis(wasmContext, {
axisTitle: "Average Sentiment",
labelPrecision: 2,
visibleRange: new NumberRange(0, 1.01),
visibleRangeLimit: new NumberRange(0, 1.01),
})
);
// data is { xValues: number[], yValues: number[], textValues: string[] }
const data: { xValues: number[]; yValues: number[]; textValues: string[] } = await fetch(
baseUrl + "api/tweetData"
).then((r) => r.json());
const series = new FastTextRenderableSeries(wasmContext, {
dataLabels: { style: { fontFamily: "Arial", fontSize: 10 }, calculateTextBounds: false },
dataSeries: new XyTextDataSeries(wasmContext, data),
});
sciChartSurface.renderableSeries.add(series);
sciChartSurface.chartModifiers.add(
new ZoomPanModifier({ enableZoom: true }),
new ZoomExtentsModifier(),
new MouseWheelZoomModifier()
);
return { sciChartSurface, wasmContext };
};
This example demonstrates the use of SciChart.js within a React application to create a high-performance chart that visualizes text-based data. It renders AI-analyzed tweet data to display metrics such as the number of tweets (using a LogarithmicAxis x-axis) and the average sentiment (using a NumericAxis y-axis) by leveraging the FastTextRenderableSeries.
In this example the chart is initialized asynchronously via the <SciChartReact/> component. The initialization logic is encapsulated in the drawExample function, which creates a SciChartSurface and its associated WebAssembly context. Data is fetched asynchronously from an API and passed into an XyTextDataSeries, which is then rendered by the FastTextRenderableSeries as described in the Text Series Type documentation. Interactive modifiers such as ZoomPanModifier, ZoomExtentsModifier, and MouseWheelZoomModifier are applied to enable dynamic user interactions; see details on these modifiers in the ZoomPanModifier documentation.
The implementation includes several advanced features and customizations such as asynchronous data handling for smooth chart initialization and interactive user experience through zooming and panning. The custom theming integrated via the SciChart.js theme further enhances the visual presentation, while WebAssembly ensures high-performance rendering even with complex text series.
This example follows best practices for React integration, encapsulating chart logic within the dedicated <SciChartReact/> component to facilitate reusability and maintainability. Developers can leverage the asynchronous initialization pattern for optimal performance and proper resource management as explained in the Tutorial 02 - Creating a Chart with scichart-react guide. The approach demonstrated here aligns with recommended practices for managing async operations and leveraging WebAssembly for high-performance rendering as further discussed in the React Charts with SciChart.js: Introducing “SciChart React” article.








































