grantwest
I am really struggling with getting D3.js working in my Phoenix app. I have a default Phoenix umbrella app with webpack.
Steps that I have done so far:
- Added
"d3": ">=5.9.1"to myassets/package.json - Added
import "d3"to myassets/js/app.js - Confirmed that the app.js that is loaded in the browser does indeed contain the d3 library.
But no matter what I seem to do every time I try to use d3 I get:
ReferenceError: d3 is not defined
I’m not a web developer. Phoenix generally has been easy enough to figure out because I am pretty good with Elixir, but I am having a really hard time getting this javascript stuff to work. Are my above steps correct? What else am I supposed to be doing?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
New
Other Trending Topics
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
kokolegorille
Hello, welcome to the forum,
Between 1 and 2 You should
I am not sure for your syntax in 2, I think it should be something like
grantwest
Thanks kokolegorille, but it still isn’t working.
I have looked through the d3 code, and it does not assign the d3 variable anywhere. I can search for
d3 =or with regexd3\s*=but I get nothing. Maybe this is why the import is not working? Maybe a different import method is required?The simple D3 tutorials show this:
I’m not sure how to translate that to canonical Phoenix.
sfusato
Looking at D3.js wiki, try to import it like this in every Javascript file you use it:
Then you should be able to reference
d3in your code.adrianrl
Hi, welcome to the forum!
should work as mentioned above, you can also add it to the Webpack dependencies by creating a new entry point:
or using a more complex configuration, so Webpack takes care of splitting your vendor dependencies:
I didn’t test it with D3, but should work. Have in mind that D3 is a heavy dependency, so splitting your JavaScript files in smaller chunks should help to build a better experience for your users.
peerreynders
Using tutorial: Simple Bar Chart Video Tutorial
Check in the browser http://localhost:4000/ to see the “Phoenix Framework” page.
Edit
d3jsDemo/assets/js/app.jsEdit
d3jsDemo/assets/styles/app.cssEdit
d3jsDemo/lib/d3jsDemo_web/templates/page/index.html.eexat the endChecking the browser at http://localhost:4000/ you should see: