DEV Community

Cover image for D3js, CSS styles
Ștefan Vîlce
Ștefan Vîlce

Posted on

D3js, CSS styles

I have to work with a creating of some charts for some statistics.
Image description

The data are comming from a JSON REST API. For one of the requests I have to count the occurencies of new articles for every single day. I have met many problems being for the first time when I work with D3js library (https://d3js.org/) which seems to be the best way to build charts in Javascript. And it is a very nice solution for that. But, I've been hit by some issues. For instance, I could't change the color of my texts on the chart. I've been trying to change the style for color but it didn't work.

Image description

The problem was solved whe I found out that I souldn't use:
.style("color", "#87A3C3")

The right solution for this problem is:
.attr("fill", "#87A3C3")

So, use attr instead of style!

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more