ABTSoftware / SciChart.JS.Examples

MIT License
76 stars 36 forks source link

Refactoring examples with sci chart react #201

Closed jim-risen closed 4 months ago

jim-risen commented 7 months ago

This PR includes:

!!! Some of the examples are not updated yet

For trivial examples the result would look as following:

// drawExample.ts
import { appTheme } from "scichart-example-dependencies";
import { ... } from "scichart";

export const drawExample = async (rootElement: string | HTMLDivElement) => {
    const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
        theme: appTheme.SciChartJsTheme,
    });

   // ... chart setup logic ...

    return { sciChartSurface };
};
// index.tsx
import * as React from "react";
import { appTheme } from "scichart-example-dependencies";
import { SciChartReact } from "scichart-react";
import classes from "../../../styles/Examples.module.scss";
import { drawExample } from "./drawExample";

// React component needed as our examples app is react.
// SciChart can be used in Angular, Vue, Blazor and vanilla JS! See our Github repo for more info
export default function ChartComponent() {
    return <SciChartReact initChart={drawExample} className={classes.ChartWrapper} />;
}
codesandbox[bot] commented 7 months ago

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders
Open Preview