- Expert Data Visualization
- Jos Dirksen
- 116字
- 2021-07-09 18:22:48
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.
推薦閱讀
- 深度實踐OpenStack:基于Python的OpenStack組件開發
- Visual Basic 6.0程序設計計算機組裝與維修
- Unity 2020 Mobile Game Development
- Mastering Natural Language Processing with Python
- 程序員面試算法寶典
- Web交互界面設計與制作(微課版)
- 深入實踐Spring Boot
- Twilio Best Practices
- 基于Java技術的Web應用開發
- Mastering Articulate Storyline
- Getting Started with Laravel 4
- Python深度學習:模型、方法與實現
- Getting Started with React Native
- 從程序員角度學習數據庫技術(藍橋杯軟件大賽培訓教材-Java方向)
- Mastering Elixir