File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed
Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ ^{:kindly/hide-code true
2+ :clay {:title " Simplest Plotly Streaming Chart"
3+ :quarto {:type :post
4+ :author [:harold ]
5+ :date " 2025-12-13"
6+ :description " Driving Plotly to Update a Chart with New Points."
7+ :image " simplest-plotly-streaming-chart.png"
8+ :category :data-visualization
9+ :tags [:chart :data :streaming :update ]
10+ :keywords [:chart :data :streaming :update ]}}}
11+ (ns data-visualization.simplest-ploty-streaming-chart
12+ (:require [scicloj.kindly.v4.kind :as kind]))
13+
14+ (kind/hiccup
15+ [:div#streaming-chart ])
16+
17+ (kind/hiccup
18+ [:div
19+ [:script {:src " https://cdn.plot.ly/plotly-3.3.0.min.js"
20+ :type " application/javascript" }]
21+ [:script {:src " https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/scittle.js"
22+ :type " application/javascript" }]
23+ [:script {:src " simplestplotlystreamingchart.cljs"
24+ :type " application/x-scittle" }]])
Original file line number Diff line number Diff line change 1+ (ns data-visualization.simplestplotlystreamingchart )
2+
3+ (def id " streaming-chart" )
4+
5+ (def v* (atom 0 ))
6+
7+ (js/Plotly.newPlot id (clj->js [{:y [@v*]}]))
8+
9+ (let [f (fn []
10+ (swap! v* + (- (* 2 (rand )) 1 ))
11+ (js/Plotly.extendTraces id (clj->js {:y [[@v*]]}) (clj->js [0 ])))
12+ i (js/setInterval f 300 )]
13+ (js/setTimeout #(js/clearInterval i) 30000 ))
You can’t perform that action at this time.
0 commit comments