A simple linear regression model built using Elixir and made interactive and visual using Phoenix LiveView. Read the blogposts here
- Clone this repo
- cd into
linreg
- Start the Phoenix server:
mix phx.server
- Play around with it over at http://localhost:4000
If you've been following the blogpost and it doesn't appear to register clicks, it is probably due to an update in Phoenix Live View (since 0.13.0) where the metadata of each event is not included by default anymore. To fix this; open up assets/js/app.js
and find the line where it says let liveSocket = new LiveSocket(..snip..)
and replace it with:
let liveSocket = new LiveSocket("/live", Socket, {
params: {_csrf_token: csrfToken},
metadata: {
click: (e, _el) => {
return {
offsetX: e.offsetX,
offsetY: e.offsetY
}
}
}
})
Thanks to @rinbo for making me aware