Navigation

v2.1.0
Comparison

Range chart

Spans between two values: where each begins and where it ends.

On this page

A range chart draws a span as a bar from where it begins to where it ends: the lowest and the highest temperature of each month, the hours a shop is open, a pay band. Each of a series' ranges is a pair of values. The bar floats, with both ends turned, and the scale fits the spans instead of starting at zero, since the length of a bar here is a difference, not an amount.

Range chart

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Temperature</h3>    <p class="card-description">Lowest and highest by month, in degrees Celsius</p>  </div>  <figure class="chart" id="temperature"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('temperature'), {  type: 'range',  label: 'Lowest and highest temperature by month, in degrees Celsius',  labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],  series: [{ name: 'Tokyo', ranges: [[2, 10], [3, 11], [5, 14], [10, 19], [15, 23], [19, 26], [23, 30], [24, 31], [21, 27], [15, 22], [9, 17], [4, 12]] }],  format: function (value) { return value + '°' }})})</script><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto">  <div className="card-header">    <h3 className="card-title">Temperature</h3>    <p className="card-description">Lowest and highest by month, in degrees Celsius</p>  </div>  <Chart    id="temperature"    type="range"    label="Lowest and highest temperature by month, in degrees Celsius"    labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}    series={[{ name: 'Tokyo', ranges: [[2, 10], [3, 11], [5, 14], [10, 19], [15, 23], [19, 26], [23, 30], [24, 31], [21, 27], [15, 22], [9, 17], [4, 12]] }]}    format={function (value) { return value + '°' }}  /></div>
<script>  import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Temperature</h3>    <p class="card-description">Lowest and highest by month, in degrees Celsius</p>  </div>  <Chart    id="temperature"    type="range"    label="Lowest and highest temperature by month, in degrees Celsius"    labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}    series={[{ name: 'Tokyo', ranges: [[2, 10], [3, 11], [5, 14], [10, 19], [15, 23], [19, 26], [23, 30], [24, 31], [21, 27], [15, 22], [9, 17], [4, 12]] }]}    format={function (value) { return value + '°' }}  /></div>
<script setup>import Chart from './ui/Chart.vue'</script><template>  <div class="card max-w(560) mx-auto">    <div class="card-header">      <h3 class="card-title">Temperature</h3>      <p class="card-description">Lowest and highest by month, in degrees Celsius</p>    </div>    <Chart      id="temperature"      type="range"      label="Lowest and highest temperature by month, in degrees Celsius"      :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']"      :series="[{ name: 'Tokyo', ranges: [[2, 10], [3, 11], [5, 14], [10, 19], [15, 23], [19, 26], [23, 30], [24, 31], [21, 27], [15, 22], [9, 17], [4, 12]] }]"      :format="function (value) { return value + '°' }"    />  </div></template>

Several series stand side by side in each band, as bars do. With horizontal the labels run down and the scale across, for spans of time or names too long for a column. Spans of a plan that a reader moves and resizes are a gantt.

#Options

OptionDefault
labelnoneWhat the chart shows and in what unit: the plot's accessible name
labels[]The names along the scale, around a radar or over a heatmap's columns
series[]Each with a name and what its form reads: values, a value, points, ranges or children; optionally a category, a type, low and high, and a ring's max
horizontalfalseBars, ranges, dumbbells and boxes run across
min, max, ticksfit, 4The ends of the scale and about how many steps mark it; xMin, xMax and xTicks for a scatter's scale across
format, tickFormatthe locale'sHow a value and a tick are written; xFormat for a scatter's scale across
currentnoneThe index of the point marked aria-current
legend, togglewith two series, trueWhether a legend is written, and whether its entries are checkboxes

The readout, the keys, the legend, the colors and the scale are the same in every form: Chart holds them, with every option, class and custom property.