diff --git a/Examples/src/components/App.tsx b/Examples/src/components/App.tsx index 60af8f70b..afdf1001c 100644 --- a/Examples/src/components/App.tsx +++ b/Examples/src/components/App.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import { useLocation } from "react-router-dom"; +import {Link, Navigate, Route, Routes, useLocation} from "react-router-dom"; import { Theme } from "@material-ui/core/styles"; import Drawer from "@material-ui/core/Drawer"; import useMediaQuery from "@material-ui/core/useMediaQuery"; @@ -23,9 +23,24 @@ import Gallery from "./Gallery/Gallery"; import { PAGES } from "./AppRouter/pages"; import {GalleryItem} from "../helpers/types/types"; import {allGalleryItems, getSeeAlsoGalleryItems} from "../helpers/SciChartExamples"; +import {REDIRECTION_RULES} from "./AppRouter/redirectionRules"; + +const NotFound = () => ( +
+

404 - Not Found!

+ Go Home +
+) export default function App() { const location = useLocation(); + + // Process redirection rules first + const pathWithoutSlash = location.pathname.endsWith("/") ? location.pathname.slice(0, -1) : location.pathname; + if (REDIRECTION_RULES.has(pathWithoutSlash)) { + return + } + // For charts without layout we use '/iframe' prefix, for example '/iframe/javascript-multiline-labels' const isIFrame = location.pathname.substring(1, 7) === 'iframe'; const pathname = isIFrame ? location.pathname.substring(7) : location.pathname; @@ -95,17 +110,41 @@ export default function App() { } }, [currentExampleId]); - if (isIFrame) { + const isHttp404 = PAGES.homapage.path !== location.pathname && currentExampleKey === undefined; + + if (isIFrame && !isHttp404) { return } const testIsOpened = (id: string): boolean => !!openedMenuItems[id]; + + const pageContent = <>{PAGES.homapage.path === location.pathname && } +
+
+ { + }} + /> +
+ {PAGES.homapage.path === location.pathname ? ( +
+ +
+ ) : ( + + )} +
+ ; + + return (
- - {PAGES.homapage.path === location.pathname && } - -
-
- {}} - /> -
- {PAGES.homapage.path === location.pathname ? ( -
- -
- ) : ( - - )} -
- - + + {isHttp404 ? : pageContent} +
); diff --git a/Examples/src/components/AppRouter/examplePages.ts b/Examples/src/components/AppRouter/examplePages.ts index 3a0f90629..830356228 100644 --- a/Examples/src/components/AppRouter/examplePages.ts +++ b/Examples/src/components/AppRouter/examplePages.ts @@ -4,7 +4,6 @@ import { digitalBandSeriesChartExampleInfo } from "../Examples/Charts2D/BasicCha import { fanChartExampleInfo } from "../Examples/Charts2D/BasicChartTypes/FanChart/exampleInfo"; import { bubbleChartExampleInfo } from "../Examples/Charts2D/BasicChartTypes/BubbleChart/exampleInfo"; import { candlestickChartExampleInfo } from "../Examples/Charts2D/BasicChartTypes/CandlestickChart/exampleInfo"; -import { ohlcChartExampleInfo } from "../Examples/Charts2D/BasicChartTypes/OhlcChart/exampleInfo"; import { columnChartExampleInfo } from "../Examples/Charts2D/BasicChartTypes/ColumnChart/exampleInfo"; import { impulseChartExampleInfo } from "../Examples/Charts2D/BasicChartTypes/ImpulseChart/exampleInfo"; import { errorBarsChartExampleInfo } from "../Examples/Charts2D/BasicChartTypes/ErrorBarsChart/exampleInfo"; @@ -174,10 +173,6 @@ export const EXAMPLES_PAGES = asRecord({ id: "chart2D_basicCharts_CandlestickChart", ...candlestickChartExampleInfo }, - chart2D_basicCharts_OhlcChart: { - id: "chart2D_basicCharts_OhlcChart", - ...ohlcChartExampleInfo - }, chart2D_basicCharts_ErrorBarsChart: { id: "chart2D_basicCharts_ErrorBarsChart", ...errorBarsChartExampleInfo diff --git a/Examples/src/components/AppRouter/examples.ts b/Examples/src/components/AppRouter/examples.ts index 73ee82ad3..3d2871370 100644 --- a/Examples/src/components/AppRouter/examples.ts +++ b/Examples/src/components/AppRouter/examples.ts @@ -3,7 +3,6 @@ import DigitalBandSeriesChart from "../Examples/Charts2D/BasicChartTypes/Digital import FanChart from "../Examples/Charts2D/BasicChartTypes/FanChart"; import BubbleChart from "../Examples/Charts2D/BasicChartTypes/BubbleChart"; import CandlestickChart from "../Examples/Charts2D/BasicChartTypes/CandlestickChart"; -import OhlcChart from "../Examples/Charts2D/BasicChartTypes/OhlcChart"; import ColumnChart from "../Examples/Charts2D/BasicChartTypes/ColumnChart"; import ImpulseChart from "../Examples/Charts2D/BasicChartTypes/ImpulseChart"; import HeatmapChart from "../Examples/Charts2D/BasicChartTypes/HeatmapChart"; @@ -355,8 +354,6 @@ export const getExampleComponent = (exampleId: string): (() => JSX.Element) => { return BubbleChart; case EXAMPLES_PAGES.chart2D_basicCharts_CandlestickChart.id: return CandlestickChart; - case EXAMPLES_PAGES.chart2D_basicCharts_OhlcChart.id: - return OhlcChart; case EXAMPLES_PAGES.chart2D_basicCharts_ColumnChart.id: return ColumnChart; case EXAMPLES_PAGES.chart2D_basicCharts_ErrorBarsChart.id: diff --git a/Examples/src/components/AppRouter/redirectionRules.ts b/Examples/src/components/AppRouter/redirectionRules.ts new file mode 100644 index 000000000..b8f25e0bb --- /dev/null +++ b/Examples/src/components/AppRouter/redirectionRules.ts @@ -0,0 +1,7 @@ +import { Navigate } from "react-router-dom"; + +// Redirection URLs from - to +export const REDIRECTION_RULES = new Map([ + ["/javascript-ohlc-chart", "javascript-candlestick-chart"], +]); + diff --git a/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/GENERATED_GITHUB_URL.ts b/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/GENERATED_GITHUB_URL.ts deleted file mode 100644 index 92151bd0c..000000000 --- a/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/GENERATED_GITHUB_URL.ts +++ /dev/null @@ -1 +0,0 @@ -export const githubUrl = "/components/Examples/Charts2D/BasicChartTypes/OhlcChart/index.tsx"; \ No newline at end of file diff --git a/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/data/data.ts b/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/data/data.ts deleted file mode 100644 index f61f4df0d..000000000 --- a/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/data/data.ts +++ /dev/null @@ -1,160 +0,0 @@ -export const dateValues: number[] = [ - 915408000, - 915494400, - 915580800, - 915667200, - 915753600, - 916012800, - 916099200, - 916185600, - 916272000, - 916358400, - 916617600, - 916704000, - 916790400, - 916876800, - 916963200, - 917222400, - 917308800, - 917395200, - 917481600, - 917568000, - 917827200, - 917913600, - 918000000, - 918086400, - 918172800, - 918432000, - 918518400, - 918604800, - 918691200, - 918777600, -]; -export const openValues: number[] = [ - 1.1801, - 1.1815, - 1.1761, - 1.1623, - 1.1713, - 1.1575, - 1.1504, - 1.1561, - 1.1673, - 1.1683, - 1.1565, - 1.1605, - 1.1598, - 1.1567, - 1.1605, - 1.1579, - 1.1555, - 1.1562, - 1.1445, - 1.1407, - 1.1382, - 1.1323, - 1.1353, - 1.1309, - 1.1343, - 1.1262, - 1.1312, - 1.1314, - 1.1323, - 1.1219, -]; -export const highValues: number[] = [ - 1.1862, - 1.1835, - 1.1773, - 1.1735, - 1.172, - 1.161, - 1.158, - 1.179, - 1.1728, - 1.1749, - 1.162, - 1.1642, - 1.1611, - 1.1619, - 1.1626, - 1.1608, - 1.1591, - 1.1565, - 1.147, - 1.1433, - 1.1397, - 1.1365, - 1.1363, - 1.1346, - 1.1373, - 1.133, - 1.1345, - 1.136, - 1.1336, - 1.1308, -]; -export const lowValues: number[] = [ - 1.1769, - 1.175, - 1.1553, - 1.1612, - 1.1533, - 1.1487, - 1.1447, - 1.1553, - 1.1614, - 1.1552, - 1.1564, - 1.1563, - 1.1539, - 1.1545, - 1.1559, - 1.1547, - 1.155, - 1.1408, - 1.1378, - 1.1342, - 1.129, - 1.1284, - 1.13, - 1.1247, - 1.1253, - 1.122, - 1.1281, - 1.127, - 1.1214, - 1.1216, -]; -export const closeValues: number[] = [ - 1.1815, - 1.1758, - 1.1623, - 1.1712, - 1.1585, - 1.1503, - 1.1555, - 1.1681, - 1.1681, - 1.1563, - 1.1605, - 1.1603, - 1.1566, - 1.1601, - 1.1587, - 1.1552, - 1.1562, - 1.144, - 1.1407, - 1.1367, - 1.1323, - 1.1352, - 1.1306, - 1.1344, - 1.126, - 1.1315, - 1.1315, - 1.1326, - 1.1218, - 1.1306, -]; diff --git a/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/exampleInfo.tsx b/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/exampleInfo.tsx deleted file mode 100644 index 4dae19e59..000000000 --- a/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/exampleInfo.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import * as React from "react"; -import { TExampleInfo } from "../../../../AppRouter/examplePages"; -import { githubUrl } from "./GENERATED_GITHUB_URL"; -import { ExampleStrings } from "../../../ExampleStrings"; -import { TDocumentationLink } from "../../../../../helpers/types/ExampleDescriptionTypes"; -import { GalleryItem } from "../../../../../helpers/types/types"; - -const previewDescription = `SciChart.js supports Candlestick Charts or OHLC with custom colours per bar and Date X-Axis.`; -const description = `OHLC charts can be animated, dynamically updated for real trading apps or combined with other series types to draw technical indicators or shapes.`; -const tips = [ - `Try dragging on the chart to pan or zoom it. Use the mousewheel to zoom and double-click to zoom to fit.` -]; - -const documentationLinks: TDocumentationLink[] = [ - { - href: ExampleStrings.urlDocumentationHome, - title: ExampleStrings.titleDocumentationHome, - linkTitle: "SciChart.js Documentation Home" - }, - { - href: ExampleStrings.urlTutorialsHome, - title: ExampleStrings.titleTutorialsHome, - linkTitle: "SciChart.js Tutorials" - }, - { - href: ExampleStrings.urlOhlcChartDocumentation, - title: ExampleStrings.urlTitleOhlcChartDocumentation, - linkTitle: "JavaScript OHLC Chart Documentation" - }, - { - href: ExampleStrings.urlRenderSeriesPropertiesDocumentation, - title: ExampleStrings.urlTitleRenderSeriesProperties, - linkTitle: "Common RenderableSeries Properties" - } -]; - -const Subtitle = () => ( -

- For this example, we demonstrate how to create a JavaScript OHLC Chart{" "} - or Stock Chart using SciChart.js. This is our powerful{" "} - - JavaScript Chart Component - . -

-); - -export const ohlcChartExampleInfo: TExampleInfo = { - title: ExampleStrings.titleOhlcChart, - pageTitle: ExampleStrings.pageTitleOhlcChart, - path: ExampleStrings.urlOhlcChart, - subtitle: Subtitle, - documentationLinks, - tips, - description, - previewDescription, - githubUrl, - metaDescription: - "Easily create JavaScript OHLC Chart or Stock Chart using feature-rich SciChart.js chart library. Supports custom colors. Get your free trial now. ", - metaKeywords: "ohlc, stock, trading, chart, javascript, webgl, canvas", - thumbnailImage: "javascript-ohlc-chart.jpg" -}; diff --git a/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/index.tsx b/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/index.tsx deleted file mode 100644 index d06081c39..000000000 --- a/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/index.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import * as React from "react"; -import { SciChartSurface } from "scichart"; -import { CategoryAxis } from "scichart/Charting/Visuals/Axis/CategoryAxis"; -import { NumberRange } from "scichart/Core/NumberRange"; -import { NumericAxis } from "scichart/Charting/Visuals/Axis/NumericAxis"; -import { OhlcDataSeries } from "scichart/Charting/Model/OhlcDataSeries"; -import { ZoomPanModifier } from "scichart/Charting/ChartModifiers/ZoomPanModifier"; -import { ZoomExtentsModifier } from "scichart/Charting/ChartModifiers/ZoomExtentsModifier"; -import { closeValues, dateValues as xValues, highValues, lowValues, openValues } from "./data/data"; -import { FastOhlcRenderableSeries } from "scichart/Charting/Visuals/RenderableSeries/FastOhlcRenderableSeries"; -import { MouseWheelZoomModifier } from "scichart/Charting/ChartModifiers/MouseWheelZoomModifier"; -import { SweepAnimation } from "scichart/Charting/Visuals/RenderableSeries/Animations/SweepAnimation"; -import classes from "../../../../Examples/Examples.module.scss"; -import { SmartDateLabelProvider } from "scichart/Charting/Visuals/Axis/LabelProvider/SmartDateLabelProvider"; -import {ENumericFormat} from "scichart/types/NumericFormat"; - -const divElementId = "chart"; - -// SCICHART EXAMPLE -const drawExample = async () => { - - // Create a SciChartSurface - const { sciChartSurface, wasmContext } = await SciChartSurface.create(divElementId); - - // Add an XAxis of type CategoryAxis - which collapses gaps in stock market data - // SmartLabelProvider returns useful labels for stock market data - sciChartSurface.xAxes.add(new CategoryAxis(wasmContext, { - labelProvider: new SmartDateLabelProvider(), - growBy: new NumberRange(0.05, 0.05) - })); - - // Create a NumericAxis on the YAxis with 4 Decimal Places - sciChartSurface.yAxes.add(new NumericAxis(wasmContext, { - visibleRange: new NumberRange(1.1, 1.2), - growBy: new NumberRange(0.1, 0.1), - labelFormat: ENumericFormat.Decimal, - labelPrecision: 4, - })); - - // Create the Ohlc series and add to the chart - sciChartSurface.renderableSeries.add(new FastOhlcRenderableSeries(wasmContext, { - dataSeries: new OhlcDataSeries(wasmContext, { xValues, openValues, highValues, lowValues, closeValues }), - strokeThickness: 1, - dataPointWidth: 0.7, - strokeUp: "#50ff50", - strokeDown: "#ff5050", - animation: new SweepAnimation({ duration: 800, fadeEffect: true }) - })); - - // Optional: Add some interactivity modifiers - sciChartSurface.chartModifiers.add( - new ZoomExtentsModifier(), - new ZoomPanModifier(), - new MouseWheelZoomModifier()); - - sciChartSurface.zoomExtents(); - return { sciChartSurface, wasmContext }; -}; - -// 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 OhlcChart() { - const [sciChartSurface, setSciChartSurface] = React.useState(); - - React.useEffect(() => { - (async () => { - const res = await drawExample(); - setSciChartSurface(res.sciChartSurface); - })(); - // Delete sciChartSurface on unmount component to prevent memory leak - return () => sciChartSurface?.delete(); - }, []); - - return
; -} diff --git a/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/javascript-ohlc-chart.jpg b/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/javascript-ohlc-chart.jpg deleted file mode 100644 index ccb98a2b9..000000000 Binary files a/Examples/src/components/Examples/Charts2D/BasicChartTypes/OhlcChart/javascript-ohlc-chart.jpg and /dev/null differ diff --git a/Examples/tsconfig.json b/Examples/tsconfig.json index 0029cc08a..5bca8d013 100644 --- a/Examples/tsconfig.json +++ b/Examples/tsconfig.json @@ -22,7 +22,13 @@ "./src/types", "./node_modules/@types"], "esModuleInterop": false, "skipLibCheck": false, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "lib": [ + "dom", + "es5", + "scripthost", + "es2015.collection" + ] }, "include": [ "src/**/*",