pxt-calliope/docs/reference/led/plot-bar-graph.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR ()
* Accessibility changes
2017-09-07 13:42:08 -07:00

1.3 KiB

Plot Bar Graph

Displays a bar graph of the numbers you say. A bar graph is a kind of chart that shows numbers as lines with different lengths.

led.plotBarGraph(2, 20);

Parameters

  • value is a number that means what you are measuring or trying to show. For example, if you are measuring the temperature of ice with the @boardname@, value might be 0 because the temperature might be 0 degrees centigrade.
  • high is a number that means the highest possible number that the value parameter can be. This number is also the tallest that the lines in the bar chart can be.

Example: chart acceleration

This program shows a bar graph of the acceleration in the x direction of the @boardname@. The @boardname@'s x direction is from left to right (or right to left). The more you speed up moving the @boardname@ in this direction, the taller the lines in the bar graph will be, until they are as tall as the parameter high says they can be.

basic.forever(() => {
    let a = input.acceleration(Dimension.X);
    led.plotBarGraph(a, 1023)
})

See also

brightness, fade in, fade out, LED screen, stop animation