Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- plotGraph(data){
- let dataset = data.map(function (item) {
- let color = null;
- let value = item.percent;
- if (value > 80){
- color = "red";
- }else{
- color = "green";
- }
- return {"y": item.percent, "x": new Date (item.date), "color": color
- };
- });
- let line = d3.line()
- .x(function(d, i) { return graph.xScale(d.x); }) // set the x values for the line generator
- .y(function(d) { return graph.yScale(d.y); }) // set the y values for the line generator
- .curve(d3.curveMonotoneX) // apply smoothing to the line
- const lineGenerator = d3.line()
- .x(d => x(d.date))
- .y(d => y(d.percent))
- .curve(d3.curveCardinal);
- graph.clearGraph();
- graph.svg.append("path")
- .data([dataset]) // 10. Binds data to the line
- .attr("class", "line") // Assign a class for styling
- .attr("d", line) // 11. Calls the line generator
- .attr('stroke', function(d){
- return d.color;});
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement