- Expert Data Visualization
- Jos Dirksen
- 106字
- 2021-07-09 18:22:48
Adding a y-axis with absolute income
For this axis, we don't do anything special:
function addAxis(yIncomeScale, yIndexedScale, xScale, xRangeAdjusted) {
...
var rightAxis = d3.axisRight().scale(yIncomeScale).ticks(20);
var rightAxisSVG = chart.append("g")
.attr('transform', 'translate( ' + (width + 4) + ')')
.call(rightAxis);
...
}
We just create d3.axisRight based on the yIncomeScale, and ask for twenty ticks. When we add this axis, we position the axis using the transform attribute and position it a little bit farther to the right to leave some room for the labels of the x-axis.
The axis on the left side will take some more work, since we're going to customize that a bit.
推薦閱讀
- 摩登創客:與智能手機和平板電腦共舞
- 跟老齊學Python:輕松入門
- Java程序員面試算法寶典
- EPLAN實戰設計
- RSpec Essentials
- Learning Apache Karaf
- Principles of Strategic Data Science
- Web App Testing Using Knockout.JS
- Building Dynamics CRM 2015 Dashboards with Power BI
- Instant Apache Camel Messaging System
- JavaWeb從入門到精通(視頻實戰版)
- Python程序員面試算法寶典
- Visual C++網絡編程教程(Visual Studio 2010平臺)
- Learning Java by Building Android Games
- Python接口自動化測試