Can I use C3 and D3 together?

I look at the graphics libraries and I am very impressed with the power of D3 , but I'm partly documented. It would be much easier to make a C3 decision if I knew I could use D3 to fill in any C3 restrictions.

So, with C3, can D3 functionality be used to improve diagrams generated with C3?

+6
source share
1 answer

Your question is too vague to be responsible - how exactly do you want to use d3 to modify the generated c3 diagram?

However, I will answer anyway. d3 - all about selecting / adding DOM elements, binding data to them and then manipulating them. After c3 does this, nothing prevents you from choosing what it generated and changing it further.

Here is the simplest example that I can think of:

 // basic c3 line chart var chart = c3.generate({ data: { columns: [ ['data1', 30, 200, 100, 400, 150, 250], ['data2', 50, 20, 10, 40, 15, 25] ] } }); // select all it "circles" and make them red d3.selectAll(".c3-circle") .style("fill","red"); 

If I were you, I would bite a bullet and just learn d3 . If you look at the build library built on top of d3 and think that you need more, your code will be cleaner and more maintainable, built from scratch with d3 .

+8
source

Source: https://habr.com/ru/post/984966/


All Articles