scichart-react
Version:
React wrapper for SciChart JS
51 lines • 2.89 kB
JavaScript
"use client";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SciChartNestedOverview = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const scichart_1 = require("scichart");
const SciChartSurfaceContext_1 = require("./SciChartSurfaceContext");
const SciChart_1 = require("./SciChart");
/**
* A component that creates a {@link SciChartOverview} for a chart within the parent {@link SciChartReact}
* @remarks Should be rendered as a child of {@link SciChartReact}
*/
const SciChartNestedOverview = (props) => {
const { options } = props, chartComponentProps = __rest(props, ["options"]);
const initResult = (0, react_1.useContext)(SciChartSurfaceContext_1.SciChartSurfaceContext);
const parentSurface = initResult === null || initResult === void 0 ? void 0 : initResult.sciChartSurface;
const overviewRef = (0, react_1.useRef)(null);
const overviewCreatePromiseRef = (0, react_1.useRef)(null);
const initChart = (divElementId) => __awaiter(void 0, void 0, void 0, function* () {
overviewCreatePromiseRef.current = scichart_1.SciChartOverview.create(parentSurface, divElementId, options);
const overview = yield overviewCreatePromiseRef.current;
overviewRef.current = overview;
return { sciChartSurface: overview.overviewSciChartSurface };
});
return parentSurface ? ((0, jsx_runtime_1.jsx)(SciChart_1.SciChartReact, Object.assign({}, chartComponentProps, { initChart: initChart, onDelete: () => {
overviewRef.current.delete();
} }))) : null;
};
exports.SciChartNestedOverview = SciChartNestedOverview;
//# sourceMappingURL=SciChartOverview.js.map
;