Reduce the number of labels in a Line chart


« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Veronica on 12th March 2013
Hi!

My question: Is there any easy way for automatically reduce the number of labels in a line graph with a lot of points? If you have a time serie with let's say 200 elements, the 200 labels in the x axis (the correspondant dates)are imposible to read.

I'm able to do it changing the vector of labels, so reducing its "density", but is there any automated method implemented for that in RGraph?

TY.
Posted by RGraph support on 13th March 2013
Hi there,

There's no option for it but you can simply set some labels to a blank string:

obj.Set('', ['A','',','D','','','G']


PS Could you link to the RGraph website - thanks.

Richard, RGraph Support

1 Year Priority Support now reduced to £299:
   www.rgraph.net/support
Posted by Dan on 24th March 2013
Check out the post "X-axis customization". I use the mod (%) formula to capture only one label per 20 records during the looping of the data.

In addition to a mod formula, add IF statements within the loop (for) formula to customize the labels.

My example below is to take numbers from the 17th column that represent phases in a wash cycle and provide names to them. They are placed in the correct location of the graph because each record is checked and the phase change is a "one shot". This is because the formula returns true only when the phase number does not match the stored value phase_x. The else returns "" for the rest of the records.

      if ((Number(cells[17]) == 3) && (phase_x != 3)) {
       phase.push('HOT WATER FILL');
       phase_x = 3;
      }
      if ((Number(cells[17]) == 4) && (phase_x != 4)) {
       phase.push('WASHING');
       phase_x = 4;
      }
      if ((Number(cells[17]) == 11) && (phase_x != 11)) {
       phase.push('DRYING');
       phase_x = 11;
      }
      else {
      phase.push('');
         }


I added these labels at a 90° angle to a separate graph below the main graph that uses the labels from the mod formula which is a timeline.

Cheers!

Add a reply

 




« Back to message list
RGraph on social media