HOME

5. Labels

In the previous example we drew a simple bars chart using the D3.js's API.
Now we re-use the same source code of the previous example and add two features:

  1. Change bars' color with respect of the bars' height
  2. Add labels showing the value of each bar's datum

As in the previous example, click on the button below to change (randomly) the number of bars in the chart.

Remark: the SVG elements drawn here are rendered by some tiny CSS-like elements defined in the HMTL page,
which are not required to understand the concepts below. However, if you want to investigate also such style elements,
please have a look to the HTML source of this page.




Show code


D3.js API reference