From f9dfcb2924fc8d33591029b8dd545bd8b78b3580 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Tue, 25 Feb 2025 23:50:28 +0100 Subject: [PATCH] ui fixes --- .../Options/OpenInterestByStrike.svelte | 207 +++++++++--------- src/lib/components/Options/Volatility.svelte | 1 - src/lib/highcharts.ts | 93 ++++---- .../options/volatility/+page.svelte | 4 +- 4 files changed, 160 insertions(+), 145 deletions(-) diff --git a/src/lib/components/Options/OpenInterestByStrike.svelte b/src/lib/components/Options/OpenInterestByStrike.svelte index 7b338bc0..8a8231b5 100644 --- a/src/lib/components/Options/OpenInterestByStrike.svelte +++ b/src/lib/components/Options/OpenInterestByStrike.svelte @@ -1,28 +1,10 @@

- Open Interest (OI) By Strike + Open Interest Chart

-
- {#if options !== null} -
- -
- {:else} -
-
- -
-
+
+ {#if config !== null} +
{/if}
+ +

+ Open Interest Table +

+
{ - module.default(Highcharts); + Highcharts.setOptions({ + lang: { + numericSymbols: ['K', 'M', 'B', 'T', 'P', 'E'] + } }); - - import('highcharts/modules/export-data').then(module => { - module.default(Highcharts); - }); -} - */ - - -if (browser) { -Highcharts.setOptions({ - lang: { - numericSymbols: ['K', 'M', 'B', 'T', 'P', 'E'] - } -}); } export default (node, config) => { const redraw = true; const oneToOne = true; + + // Merge our watermark load event with any provided chart events + const mergedChartOptions = { + ...(config.chart || {}), + events: { + ...(config.chart && config.chart.events ? config.chart.events : {}), + load: function () { + const chart = this; + const marginX = 10; // Adjust horizontal margin + const marginY = 5; // Adjust vertical margin + + // Destroy existing watermark if it exists + if (chart.watermark) { + chart.watermark.destroy(); + } + + // Get the actual width and height of the plotting area + const x = chart.chartWidth - marginX; + const y = chart.chartHeight - marginY; + + // Add watermark + chart.watermark = chart.renderer + .text('stocknear.com', x, y) + .attr({ + align: 'right' + }) + .css({ + fontSize: '12px', + color: 'rgba(255, 255, 255, 0.6)', + fontWeight: 'medium', + pointerEvents: 'none' + }) + .add(); + + // Adjust on redraw + Highcharts.addEvent(chart, 'redraw', function () { + const newX = chart.chartWidth - marginX; + const newY = chart.chartHeight - marginY; + chart.watermark.attr({ x: newX, y: newY }); + }); +} + + } + }; + const chart = Highcharts.chart(node, { ...config, - /* - exporting: { - filename: 'event-id-metadata-graph', - fetchOptions:{ - credentials: "omit", // omit, same-origin, include - mode: "cors" // cors, no-cors, same-origin - }, - buttons: { - customButton: { - menuItems: [ - 'viewFullscreen', - 'printChart', - 'separator', - 'downloadPNG', - 'downloadJPEG', - 'downloadPDF', - 'downloadSVG', - ], - className: 'bg-gray-500', - text: 'Custom button', - }, - }, - }, - */ + chart: mergedChartOptions, }); return { @@ -60,8 +69,10 @@ export default (node, config) => { destroy() { chart.destroy(); }, + /* exportChart(options = {}, chartOptions = {}) { chart.exportChart(options, chartOptions); }, + */ }; }; diff --git a/src/routes/stocks/[tickerID]/options/volatility/+page.svelte b/src/routes/stocks/[tickerID]/options/volatility/+page.svelte index ec554b52..4e66a755 100644 --- a/src/routes/stocks/[tickerID]/options/volatility/+page.svelte +++ b/src/routes/stocks/[tickerID]/options/volatility/+page.svelte @@ -14,9 +14,7 @@ description={`Track volatility and implied volatility trends with our interactive chart. Analyze price movements, 30-day implied volatility, and realized volatility to make data-driven trading decisions.`} /> -
+