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

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.

主站蜘蛛池模板: 宿迁市| 齐河县| 南部县| 涿州市| 长白| 咸丰县| 汝城县| 兴和县| 三都| 息烽县| 莱州市| 大宁县| 绥阳县| 济宁市| 海原县| 永康市| 梓潼县| 武川县| 易门县| 逊克县| 西青区| 金坛市| 甘谷县| 江源县| 类乌齐县| 尚志市| 巴马| 罗源县| 陆川县| 泾阳县| 峨山| 营口市| 桐乡市| 宁安市| 伊春市| 马尔康县| 广南县| 潮安县| 龙里县| 红安县| 如东县|