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

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.

主站蜘蛛池模板: 台湾省| 华池县| 顺平县| 黄骅市| 贡嘎县| 南靖县| 九台市| 策勒县| 昌乐县| 达孜县| 合肥市| 凯里市| 呼和浩特市| 华亭县| 凤阳县| 梓潼县| 宁海县| 和田市| 青海省| 涿州市| 龙泉市| 九江市| 莱西市| 桃江县| 南溪县| 安岳县| 张掖市| 博客| 鄂托克前旗| 晋城| 吉木萨尔县| 嘉兴市| 阿克陶县| 榆林市| 南川市| 黎川县| 道真| 延长县| 进贤县| 临西县| 德州市|