Skip to content
Advertisement

how to create a line in d3?

I have managed to create a line chart in d3 but now need to overlay a couple of horizontal lines and vertical lines. Here is what the chart looks like: enter image description here

Here is the code:

JavaScript

I want to create horizontal line at 149 for the upper limit where you want the triglyceride levels to be below. I try to create that line in the “draw the upper limit” section. But no line is drawn.

Advertisement

Answer

Well I’m not real happy with this solution, but it works. Could not figure out why the svg.append(“line”) command failed to display a line, so I used the svg.append(“path”) command instead. I added the following code:

JavaScript

Then I modified the DataPoint code to this:

JavaScript

Now the chart has a red dashed line representing the tryglyceride upper limit: enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement