Area chart to line chart

24 views
Skip to first unread message

Emeric

unread,
Jun 16, 2017, 9:12:35 AM6/16/17
to d3-js
Hello,

I would like to transform my chart looks like this example: https://bl.ocks.org/mbostock/34f08d5e11952a80609169b7917d4172
to a line chart (no area, juste lines.
I searched and found some help but it didnt works. I tried that

var area = d3.line()
.x(function(d) { return x(d.date); })
//.y0(height)
.y(function(d) { return y(d.price); });
 
Thank you in advance !

Emeric

unread,
Jun 19, 2017, 3:10:55 AM6/19/17
to d3-js
Has some one an idea ?

Curran

unread,
Jun 19, 2017, 10:08:21 AM6/19/17
to d3-js
Greetings,

Here's a fork of that bl.ock I just made that uses lines and not areas: https://bl.ocks.org/curran/bbff827df486e4c16488fc8bb9653917

The following changes were made:
  • Change d3.area to d3.line
  • Remove y0
  • Change y1 to y
  • Change the fill to none in the CSS
  • Change the stroke and stroke-width in the CSS
I'm curious what you mean by "it didn't work", as the changes you describe are the same changes I made.

Best regards,
Curran

Emeric

unread,
Jun 19, 2017, 10:47:24 AM6/19/17
to d3-js
Thank you a lot that's perfect !

My problem was: i added: path.chart { fill: none; }  and didn't change .area{ ...  } in css.
Reply all
Reply to author
Forward
0 new messages