Annotate RoughViz chart using Rough-Notation library

I have a simple bar chart built with RoughViz.js. The key takeaway that I’d like to highlight in the chart is the difference in height between the first bar and the third bar. To do this I’d like to use the bracket annotation from Rough Notation and set the bracket to start at a y-coordiate equal to the height of the first bar and end at a y-coordinate equal to the height of the last bar. What is the best way to accomplish this?

this picture illustrates what I’m trying to accomplish. The large bracket is the one that the rough-notation library is drawing in my code. Note that it wraps the entire chart. I want it to instead draw the bracket like the small dark blue one that I’ve mocked up. The dashed lines are also just mock up so as to better convey the desired positioning.
enter image description here

The external libraries are: and

<!DOCTYPE html>
<html lang="en">

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <script src=""></script>
    <script type="module" src=""></script>

      body {}


      .item1 {
        grid-area: chart;

      .item2 {
        grid-area: annotation;

      .grid-container {
        margin-top: 3rem;
        display: grid;
          'chart annotation';
        grid-template-rows: 1fr;
        grid-template-columns: 8fr, 3fr;


      #typedtext {
        font-family: 'Waiting for the Sunrise', cursive;
        font-size: 25px;
        margin: 10px 50px;
        letter-spacing: 6px;
        font-weight: bold;
        color: blue;
        padding-left: 3rem;
        padding-top: 30%;
        height: 100%;



    <button id="annotate-button">Click me</button>
    <div class="grid-container">
      <div class="item1">
        <div id="viz0"></div>
      <div class="item2">
        <div id="typedtext"></div>



  // create Bar chart from csv file, using default options
  new roughViz.Bar({
    element: '#viz0', // container selection
    data: {
      labels: ['First thing', 'Second thing', 'Third thing'],
      values: [100, 50, 25]
    width: window.innerWidth * .7,
    height: window.innerHeight * .7


<script type="module">
  import { annotate } from '';
    const e = document.querySelector('#viz0');
const annotation = annotate(e, { type: 'bracket', color: 'blue', padding: [2, 10], strokeWidth: 3 });
document.getElementById("annotate-button").addEventListener('click', function(){;



  // set up text to print, each item in array is new line
  var aText = new Array(
    "This is a comment"
  var iSpeed = 10; // time delay of print out
  var iIndex = 0; // start printing array at this posision
  var iArrLength = aText[0].length; // the length of the text array
  var iScrollAt = 20; // start scrolling up at this many lines

  var iTextPos = 0; // initialise text position
  var sContents = ''; // initialise contents variable
  var iRow; // initialise current row

  function typewriter() {
    sContents = ' ';
    iRow = Math.max(0, iIndex - iScrollAt);
    var destination = document.getElementById("typedtext");

    while (iRow < iIndex) {
      sContents += aText[iRow++] + '<br />';
    destination.innerHTML = sContents + aText[iIndex].substring(0, iTextPos) + "_";
    if (iTextPos++ == iArrLength) {
      iTextPos = 0;
      if (iIndex != aText.length) {
        iArrLength = aText[iIndex].length;
        setTimeout("typewriter()", 500);
    } else {
      setTimeout("typewriter()", iSpeed);

  document.getElementById("annotate-button").addEventListener('click', function() {


You can also click here for a JsFiddle with the same code. The chart renders a little better on JsFiddle.

155 thoughts on “Annotate RoughViz chart using Rough-Notation library”

  1. Pingback: purchase viagra
  2. Pingback: female viagra
  3. Pingback: buy sildenafil
  4. Pingback: order cheap cialis
  5. Pingback: cialis india
  6. Pingback: buy generic cialis
  7. Pingback: viagra 100mg
  8. Pingback: viagra samples
  9. Pingback: buy generic viagra
  10. Pingback: cialis on the web
  11. Pingback: tadalafil tablets
  12. Pingback: daily cialis
  13. Pingback: sildenafil 20mg
  14. Pingback: levitra vs viagra
  15. Pingback: herb viagra
  16. Pingback: viagra dosages
  17. Pingback: women viagra
  18. Pingback: viagra price
  19. Pingback: viagra substitute
  20. Pingback: brand viagra
  21. Pingback: cheap viagra
  22. Pingback: natural viagra
  23. Pingback: buy viagra
  24. Pingback: viagra cost

Leave a Comment