function draw_scale(ctx, metrics, alphabet_ic) {
      var tic_height = metrics.stack_height / alphabet_ic;
      ctx.save();
      ctx.lineWidth = 1.5;
      ctx.translate(metrics.y_label_height, metrics.y_num_height/2);
      //draw the axis label
      ctx.save();
      ctx.font = metrics.y_label_font;
      ctx.translate(0, metrics.stack_height/2);
      ctx.save();
      ctx.rotate(-(Math.PI / 2));
      ctx.textAlign = "center";
      ctx.fillText("bits", 0, 0);
      ctx.restore();
      ctx.restore();

      ctx.translate(metrics.y_label_spacer + metrics.y_num_width, 0);

      //draw the axis tics
      ctx.save();
      ctx.translate(0, metrics.stack_height);
      ctx.font = metrics.y_num_font;
      ctx.textAlign = "right";
      ctx.textBaseline = "middle";
      for (var i = 0; i <= alphabet_ic; i++) {
        //draw the number
        ctx.fillText("" + i, 0, 0);
        //draw the tic
        ctx.beginPath();
        ctx.moveTo(0, 0);
        ctx.lineTo(metrics.y_tic_width, 0);
        ctx.stroke();
        //prepare for next tic
        ctx.translate(0, -tic_height);
      }
      ctx.restore();

      ctx.translate(metrics.y_tic_width, 0);

      ctx.beginPath();
      ctx.moveTo(0, 0);
      ctx.lineTo(0, metrics.stack_height);
      ctx.stroke();

      ctx.restore();
    }
//draws the scale, returns the width
draws the scale, returns the width
draws the scale returns the width
function draw_scale(ctx, metrics, alphabet_ic) {
      var tic_height = metrics.stack_height / alphabet_ic;
      ctx.save();
      ctx.lineWidth = 1.5;
      ctx.translate(metrics.y_label_height, metrics.y_num_height/2);
      ctx.save();
      ctx.font = metrics.y_label_font;
      ctx.translate(0, metrics.stack_height/2);
      ctx.save();
      ctx.rotate(-(Math.PI / 2));
      ctx.textAlign = "center";
      ctx.fillText("bits", 0, 0);
      ctx.restore();
      ctx.restore();
      ctx.translate(metrics.y_label_spacer + metrics.y_num_width, 0);
      ctx.save();
      ctx.translate(0, metrics.stack_height);
      ctx.font = metrics.y_num_font;
      ctx.textAlign = "right";
      ctx.textBaseline = "middle";
      for (var i = 0; i <= alphabet_ic; i++) {
        ctx.fillText("" + i, 0, 0);
        ctx.beginPath();
        ctx.moveTo(0, 0);
        ctx.lineTo(metrics.y_tic_width, 0);
        ctx.stroke();
        ctx.translate(0, -tic_height);
      }
      ctx.restore();
      ctx.translate(metrics.y_tic_width, 0);
      ctx.beginPath();
      ctx.moveTo(0, 0);
      ctx.lineTo(0, metrics.stack_height);
      ctx.stroke();
      ctx.restore();
    }
function draw_scale ( ctx , metrics , alphabet_ic ) { var tic_height = metrics . stack_height / alphabet_ic ; ctx . save ( ) ; ctx . lineWidth = 1.5 ; ctx . translate ( metrics . y_label_height , metrics . y_num_height / 2 ) ; ctx . save ( ) ; ctx . font = metrics . y_label_font ; ctx . translate ( 0 , metrics . stack_height / 2 ) ; ctx . save ( ) ; ctx . rotate ( - ( Math . PI / 2 ) ) ; ctx . textAlign = "center" ; ctx . fillText ( "bits" , 0 , 0 ) ; ctx . restore ( ) ; ctx . restore ( ) ; ctx . translate ( metrics . y_label_spacer + metrics . y_num_width , 0 ) ; ctx . save ( ) ; ctx . translate ( 0 , metrics . stack_height ) ; ctx . font = metrics . y_num_font ; ctx . textAlign = "right" ; ctx . textBaseline = "middle" ; for ( var i = 0 ; i <= alphabet_ic ; i ++ ) { ctx . fillText ( "" + i , 0 , 0 ) ; ctx . beginPath ( ) ; ctx . moveTo ( 0 , 0 ) ; ctx . lineTo ( metrics . y_tic_width , 0 ) ; ctx . stroke ( ) ; ctx . translate ( 0 , - tic_height ) ; } ctx . restore ( ) ; ctx . translate ( metrics . y_tic_width , 0 ) ; ctx . beginPath ( ) ; ctx . moveTo ( 0 , 0 ) ; ctx . lineTo ( 0 , metrics . stack_height ) ; ctx . stroke ( ) ; ctx . restore ( ) ; }
draws the scale, returns the width
draws the scale returns the width
//draw the axis label //draw the axis tics //draw the number //draw the tic //prepare for next tic