Skip to content

Commit

Permalink
Upgrade packages
Browse files Browse the repository at this point in the history
  • Loading branch information
hmG3 committed Nov 7, 2024
1 parent d089e0b commit 379f6e3
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 191 deletions.
2 changes: 1 addition & 1 deletion src/TaTooIne.Demo/DemoIndicators/IndicatorChart.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await JsRuntime.InvokeVoidAsync("SiteJsInterop.setupChart", _chartCanvas);
await JsRuntime.InvokeVoidAsync("App.setupChart", _chartCanvas);
}
}
}
2 changes: 1 addition & 1 deletion src/TaTooIne.Demo/DemoIndicators/IndicatorsIndex.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ protected override void OnInitialized()
private async Task ToggleNavMenuAsync()
{
_navMenuOpened = !_navMenuOpened;
await JsRuntime.InvokeVoidAsync("SiteJsInterop.collapseNavMenu", _navMenuOpened, "toc");
await JsRuntime.InvokeVoidAsync("App.collapseNavMenu", _navMenuOpened, "toc");
}
}
2 changes: 1 addition & 1 deletion src/TaTooIne.Demo/Pages/Demo.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ private async Task CalculateExample(Function function)
}
};

await JsRuntime.InvokeVoidAsync("SiteJsInterop.setChartData", function.Name, data);
await JsRuntime.InvokeVoidAsync("App.setChartData", function.Name, data);
}
}
2 changes: 1 addition & 1 deletion src/TaTooIne.Demo/Shared/NavMenu.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public void Dispose()

private async void HandleLocationChanged(object? sender, LocationChangedEventArgs args) => await ToggleNavMenuAsync(false);

private async Task ToggleNavMenuAsync(bool isOpen) => await JsRuntime.InvokeVoidAsync("SiteJsInterop.collapseNavMenu", isOpen, "menu");
private async Task ToggleNavMenuAsync(bool isOpen) => await JsRuntime.InvokeVoidAsync("App.collapseNavMenu", isOpen, "menu");
}
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
import {
BarData,
createChart,
CrosshairMode,
HistogramData,
IChartApi,
ISeriesApi,
LineData,
} from 'lightweight-charts';
import { BarData, createChart, CrosshairMode, HistogramData, IChartApi, ISeriesApi, LineData } from "lightweight-charts";

class SiteJsInterop {
class App {
private chart: IChartApi;
private chartSeriesMap!: Map<string, ISeriesApi<'Candlestick' | 'Histogram' | 'Line' | 'Bar' | 'Area'>>;
private chartSeriesMap!: Map<string, ISeriesApi<"Candlestick" | "Histogram" | "Line" | "Bar" | "Area">>;

static load(): void {
window[SiteJsInterop.name] = new SiteJsInterop();
window[App.name] = new App();
}

collapseNavMenu(isOpened: boolean, sender: string): void {
document.body.classList[isOpened ? 'add' : 'remove'](`${sender}--opened`);
document.body.classList[isOpened ? "add" : "remove"](`${sender}--opened`);
}

setupChart(element: HTMLElement): void {
this.chart = createChart(element, {
height: 400,
layout: {
attributionLogo: false,
},
grid: {
vertLines: {
color: 'rgba(197, 203, 206, 0.5)',
color: "rgba(197, 203, 206, 0.5)",
},
horzLines: {
color: 'rgba(197, 203, 206, 0.5)',
color: "rgba(197, 203, 206, 0.5)",
},
},
crosshair: {
mode: CrosshairMode.Normal,
},
rightPriceScale: {
visible: true,
borderColor: 'rgba(197, 203, 206, 1)',
borderColor: "rgba(197, 203, 206, 1)",
},
leftPriceScale: {
visible: true,
borderColor: 'rgba(197, 203, 206, 1)',
borderColor: "rgba(197, 203, 206, 1)",
},
timeScale: {
borderColor: 'rgba(197, 203, 206, 0.8)',
borderColor: "rgba(197, 203, 206, 0.8)",
},
watermark: {
visible: true,
fontSize: 24,
horzAlign: 'center',
vertAlign: 'center',
color: 'rgba(171, 71, 188, 0.5)',
horzAlign: "center",
vertAlign: "center",
color: "rgba(171, 71, 188, 0.5)",
},
});

Expand All @@ -62,7 +57,7 @@ class SiteJsInterop {
resizeTimerId = setTimeout(() => this.resizeChart(), 100);
};

this.chartSeriesMap = new Map<string, ISeriesApi<'Candlestick' | 'Histogram' | 'Line' | 'Bar' | 'Area'>>();
this.chartSeriesMap = new Map<string, ISeriesApi<"Candlestick" | "Histogram" | "Line" | "Bar" | "Area">>();
}

setChartData(
Expand All @@ -82,30 +77,30 @@ class SiteJsInterop {

if (data.candle && Array.isArray(data.candle)) {
const candleSeries = this.chart.addCandlestickSeries({
priceScaleId: 'left',
title: 'AAPL',
priceScaleId: "left",
title: "AAPL",
});
candleSeries.setData(data.candle);
this.chartSeriesMap.set('candle', candleSeries);
this.chartSeriesMap.set("candle", candleSeries);
}

if (data.volume && data.volume.length) {
const volumeSeries = this.chart.addHistogramSeries({
priceFormat: {
type: 'volume',
type: "volume",
},
color: 'rgba(76, 175, 80, 0.5)',
color: "rgba(76, 175, 80, 0.5)",
priceLineVisible: false,
priceScaleId: 'left',
priceScaleId: "left",
});
volumeSeries.setData(data.volume);
this.chartSeriesMap.set('volume', volumeSeries);
this.chartSeriesMap.set("volume", volumeSeries);
}

if (data.overlayLines && Array.isArray(data.overlayLines)) {
for (let i = 0; i < data.overlayLines.length; i++) {
const overlayLineSeries = this.chart.addLineSeries({
priceScaleId: 'right',
priceScaleId: "right",
lineWidth: 1,
});
overlayLineSeries.setData(data.overlayLines[i]);
Expand All @@ -116,7 +111,7 @@ class SiteJsInterop {
if (data.valueLines && Array.isArray(data.valueLines)) {
for (let i = 0; i < data.valueLines.length; i++) {
const valueLineSeries = this.chart.addLineSeries({
priceScaleId: '',
priceScaleId: "",
lineWidth: 1,
});
valueLineSeries.priceScale().applyOptions({
Expand All @@ -130,14 +125,14 @@ class SiteJsInterop {
}
}

window.dispatchEvent(new UIEvent('resize'));
window.dispatchEvent(new UIEvent("resize"));
}

private resizeChart(): void {
const chartContainer = document.getElementById('chart') as HTMLElement;
const chartContainer = document.getElementById("chart") as HTMLElement;
this.chart.resize(chartContainer.offsetWidth, chartContainer.offsetHeight);
this.chart.timeScale().fitContent();
}
}

SiteJsInterop.load();
App.load();
2 changes: 1 addition & 1 deletion src/TaTooIne.Demo/wwwroot/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ esbuild
.build({
entryPoints: {
"styles.min": "_scss/main.scss",
"bundle.min": "_ts/SiteJsInterop.ts",
"bundle.min": "_ts/app.ts",
"gh-spa.min": "node_modules/ghspa/ghspa.js"
},
outdir: "dist",
Expand Down
6 changes: 3 additions & 3 deletions src/TaTooIne.Demo/wwwroot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"license": "MIT",
"type": "module",
"devDependencies": {
"esbuild": "~0.20.1",
"esbuild-sass-plugin": "~3.1.0"
"esbuild": "~0.24.0",
"esbuild-sass-plugin": "~3.3.1"
},
"dependencies": {
"ghspa": "~1.0.0",
"lightweight-charts": "~4.1.3"
"lightweight-charts": "~4.2.1"
},
"scripts": {
"build": "node esbuild.js"
Expand Down
Loading

0 comments on commit 379f6e3

Please sign in to comment.