官术网_书友最值得收藏!

Adding the income line

We'll quickly skim over this code, since it's pretty much the same as we used to add the indexed line:

function addIncomeLine(xScale, yIncomeScale, unadjustedCleaned) { 
var lineIncome = d3.line()
.x(function(d) { return xScale(d.date); })
.y(function(d) { return yIncomeScale(d.value); })
.curve(d3.curveCatmullRom.alpha(0.5));

chart.append("path")
.attr("d", lineIncome(unadjustedCleaned))
.style("fill", "none")
.style("stroke", "steelblue")
.style("stroke-width", "2");
}

The main change here is that we don't use a gradient for the stroke but use a fixed color. The chart at this point looks like this:

At this point we have visualized the data, but the chart doesn't really look nice yet, and we don't know what the different lines really mean. We'll add this information using a couple of axes.

主站蜘蛛池模板: 西丰县| 泽普县| 石棉县| 彰化市| 玛沁县| 全南县| 三亚市| 嘉善县| 托里县| 商水县| 萨嘎县| 漳平市| 萨嘎县| 芒康县| 鹿泉市| 微山县| 仲巴县| 长阳| 修武县| 资中县| 广德县| 齐齐哈尔市| 增城市| 衡山县| 石台县| 大宁县| 巴楚县| 阆中市| 宜丰县| 阿图什市| 仪征市| 鄂温| 独山县| 天全县| 响水县| 梓潼县| 四平市| 马边| 江陵县| 天峻县| 望城县|