Skip to content

Instantly share code, notes, and snippets.

@Fil

Fil/fixes.patch Secret

Last active September 3, 2024 13:27
Show Gist options
  • Save Fil/8b1c86d23a2f44a3261d5029ead293be to your computer and use it in GitHub Desktop.
Save Fil/8b1c86d23a2f44a3261d5029ead293be to your computer and use it in GitHub Desktop.
mboard patch
diff --git a/Mboard-Debug/src/index.md b/Mboard-Debug/src/index.md
index c7dc608..882b7ca 100644
--- a/Mboard-Debug/src/index.md
+++ b/Mboard-Debug/src/index.md
@@ -75,17 +75,9 @@ const OHLCVBufferForSelectedIntervalWithIndicators = calculateAndInsertIndicator
<!--[ INTERFACE ]-------------------------------------------------------------->
-```html
-
-<div>
-</div>
-
<div class="grid grid-cols-1">
-
<div class="card">
-
<div class="grid grid-cols-1">
-
<div style="display: flex; font-size:12pt; gap: 8px;">
<span style="color: var(--theme-foreground-faint);">BTC/USDT</span>
<span style="color: var(--theme-foreground);">${selectedMarketInterval}</span>
@@ -105,23 +97,15 @@ const OHLCVBufferForSelectedIntervalWithIndicators = calculateAndInsertIndicator
${marketInterval_control_1w}
${marketInterval_control_1M}
</span>
-
</div>
-
-
</div>
-
<div id="charts">
-
<div>
${mainChart} ${volumeChart}
</div>
-
</div>
</div>
-
</div>
-```
<!----[ CHARTS ] ---------------------------------------------------------->
diff --git a/Mboard-Debug/src/modules/charts/main.js b/Mboard-Debug/src/modules/charts/main.js
index 263b33e..4746af4 100644
--- a/Mboard-Debug/src/modules/charts/main.js
+++ b/Mboard-Debug/src/modules/charts/main.js
@@ -2,6 +2,16 @@ import * as Plot from "npm:@observablehq/plot"
import * as d3 from "npm:d3"
import { defaults } from "../defaults.js"
+const prev = [];
+
+function resync(i) {
+ return (index, scales, values, dimensions, context, next) => {
+ if (!context.ownerSVGElement.isConnected) index = [prev[i]];
+ else prev[i] = index[0];
+ return next(index, scales, values, dimensions, context);
+ };
+}
+
const createMainChart = ({ OHLCVData,
priceData,
width,
@@ -124,7 +134,8 @@ const createMainChart = ({ OHLCVData,
y: "close",
stroke: "orange",
strokeWidth: 1,
- strokeDasharray: "4,4"
+ strokeDasharray: "4,4",
+ render: resync(0)
})
),
@@ -136,7 +147,8 @@ const createMainChart = ({ OHLCVData,
py: "close",
stroke: "orange",
strokeWidth: 1,
- strokeDasharray: "4,4"
+ strokeDasharray: "4,4",
+ render: resync(1)
})
),
@@ -151,7 +163,8 @@ const createMainChart = ({ OHLCVData,
frameAnchor: "top-right",
fill: "orange",
fontVariant: "tabular-nums",
- text: (d) => d3.timeFormat("%b %d %Y, %H:%M")(d.time)
+ text: (d) => d3.timeFormat("%b %d %Y, %H:%M")(d.time),
+ render: resync(2)
})
),
@@ -166,7 +179,8 @@ const createMainChart = ({ OHLCVData,
frameAnchor: "top-right",
fill: "orange",
fontVariant: "tabular-nums",
- text: (d) => d.close
+ text: (d) => d.close,
+ render: resync(3)
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment