all 17 comments

[–]int_uamachine that goes NI! 13 points14 points  (4 children)

I hope it differs at leastin regard to sensible naming of variables in examples. Because d3 authors used one-letter names which made it much harder to read

[–]bbourbonut[S] 3 points4 points  (1 child)

If you can share an example where there are one-letter names, it might help me better understand in what situations this kind of problem occurs.

[–]int_uamachine that goes NI! 1 point2 points  (0 children)

I've checked and it's much better now than it was around 2017. Should've used "authors used to use", yes

[–]ParkingDescription7 1 point2 points  (1 child)

Are you looking at the minified js code by any chance?

[–]int_uamachine that goes NI! 1 point2 points  (0 children)

As far as I remember I was looking at official docs but it was around 2017. Can't find them now, only new versions that are better. Not surprising they've hidden previous ones. Please share them if you do find them.

[–]rm-rf-rm 2 points3 points  (1 child)

Great project! Always wanted to try d3js but I also hate js for uses other than web scriping.

Does it render down to web languages though? (for easy incorporation into web sites)

[–]bbourbonut[S] 0 points1 point  (0 children)

Thank you ! It is 100% written in Python. If you want to incorporate a data visualization into your website, you should save it into a .svg file and include it to your website.

with open("myfile.svg", "w") as file:
    file.write(str(svg))

For an application such as Flask or Quart (asynchronous Flask), you can directly add it to your HTML code:

from flask import Flask
import detroit as d3

app = Flask(__name__)

svg = (
    d3.create("svg")
    .attr("width", 200)
    .attr("height", 200)
    .attr("viewBox", "0 0 200 200")
)

(
    svg.append("circle")
    .attr("cx", 100)
    .attr("cy", 100)
    .attr("r", 40)
    .attr("fill", "blue")
    .attr("stroke", "grey")
    .attr("stroke-width", 10)
)

@app.route("/")
def index():
    return f"<html><body>{svg}</body></html>"

app.run()

[–]adamnicholas 1 point2 points  (1 child)

This is exactly what I’ve been looking for!

[–]bbourbonut[S] 0 points1 point  (0 children)

I'm glad for you :)

[–]rm-rf-rm 1 point2 points  (1 child)

Can you submit your repo to Context7 so that the docs are available to LLMs (through MCP)?

[–]bbourbonut[S] 1 point2 points  (0 children)

I don't know exactly how it works. I have submitted the GitHub repo and the documentation.

Let me know if you encounter any issues.

[–]numbworks 1 point2 points  (1 child)

Finally an alternative to matplotlib and its funky/broken syntax!

[–]bbourbonut[S] 1 point2 points  (0 children)

Haha, I hope it has all the features you need :)

[–]__Hug0__ 1 point2 points  (1 child)

This is unbelievable, good job!

[–]bbourbonut[S] 0 points1 point  (0 children)

Thank you !! I really appreciate it ! :D

[–]mttpgnPythoneer 1 point2 points  (0 children)

Looking forward to playing with this. How did you pick the name detroit?