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

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.

主站蜘蛛池模板: 武强县| 定结县| 永仁县| 江川县| 炉霍县| 双流县| 冷水江市| 蒙山县| 安庆市| 突泉县| 清镇市| 鄢陵县| 五华县| 安新县| 梅州市| 彰化市| 乐至县| 新宁县| 巴林左旗| 衡南县| 女性| 望城县| 新营市| 玉屏| 三台县| 安多县| 朝阳区| 阿拉善盟| 荥阳市| 阜南县| 平塘县| 怀仁县| 辉县市| 广南县| 岑巩县| 修文县| 阜南县| 华池县| 翁牛特旗| 旬阳县| 湘潭县|