- Expert Data Visualization
- Jos Dirksen
- 183字
- 2021-07-09 18:22:44
Adding some CSS classes to style the bars and text elements
When we added the rect elements, we added a female class attribute for the girls' names, and a male one for the boys' names and we've also set the style of our text elements to label. In our CSS file, we can now define colors and other styles based on these classes:
.male {
fill: steelblue;
}
.female {
fill: hotpink;
}
.label {
fill: black;
font: 10px sans-serif;
text-anchor: end;
}
With these CSS properties, we set the fill color of our rectangles. The elements with the male class will be filled steelblue and the elements with the female class will be filled hotpink. We also change how the elements with the .label class are rendered. For these elements, we change the font and the text-anchor. The text-anchor, especially, is important here, since it makes sure that the text element's right side is positioned at the x and y value, instead of the left side. The effect is that the text element is nicely aligned at the end of our bars.
- 演進(jìn)式架構(gòu)(原書(shū)第2版)
- Python編程自學(xué)手冊(cè)
- Spring 5企業(yè)級(jí)開(kāi)發(fā)實(shí)戰(zhàn)
- JavaScript+jQuery網(wǎng)頁(yè)特效設(shè)計(jì)任務(wù)驅(qū)動(dòng)教程(第2版)
- Python 深度學(xué)習(xí)
- Apache Karaf Cookbook
- Python機(jī)器學(xué)習(xí)經(jīng)典實(shí)例
- HTML5入門(mén)經(jīng)典
- QGIS By Example
- Python機(jī)器學(xué)習(xí)算法: 原理、實(shí)現(xiàn)與案例
- Hands-On Kubernetes on Windows
- GitHub入門(mén)與實(shí)踐
- Mastering Docker
- Learning Unreal Engine Game Development
- Clojure High Performance Programming(Second Edition)