pxt-calliope/docs/reference/led/plot-bar-graph.md

40 lines
1.4 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# 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.
2016-03-26 00:47:20 +01:00
```sig
led.plotBarGraph(2, 20);
```
### Parameters
2016-07-18 20:14:51 +02:00
* ``value`` is a [number](/reference/types/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`
2016-07-18 20:14:51 +02:00
because the temperature might be 0 degrees centigrade.
* ``high`` is a [number](/reference/types/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.
2016-03-26 00:47:20 +01:00
### Example: chart acceleration
This program shows a bar graph of the [acceleration](/reference/input/acceleration)
2016-11-02 01:44:37 +01:00
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.
2016-03-26 00:47:20 +01:00
```blocks
basic.forever(() => {
let a = input.acceleration(Dimension.X);
led.plotBarGraph(a, 1023)
})
```
### See also
2016-04-13 17:27:45 +02:00
[brightness](/reference/led/brightness), [fade in](/reference/led/fade-in), [fade out](/reference/led/fade-out), [LED screen](/device/screen), [stop animation](/reference/led/stop-animation)
2016-03-26 00:47:20 +01:00