Scatter plot
Two measures against each other, one dot to a thing.
On this page
A scatter sets two measures against each other: each dot is one thing, placed by its x and its y. Both scales fit the dots, between round numbers, and do not start at zero unless a dot is near it; set xMin, xMax, min and max to hold them. The pointer lands on the room around a dot, not only on the dot, and a dot's own label is the readout's title.
Scatter
<div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Responses</h3> <p class="card-description">Time in milliseconds against size in kilobytes</p> </div> <figure class="chart" id="responses"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('responses'), { type: 'scatter', label: 'Response time in milliseconds against size in kilobytes', series: [ { name: 'API', points: [[12, 38], [18, 52], [25, 61], [31, 70], [38, 96], [44, 88], [52, 120], [60, 131], [66, 150], [74, 142], [81, 171]].map(function (pair) { return { x: pair[0], y: pair[1] } }) }, { name: 'Pages', points: [[20, 160], [28, 150], [35, 175], [47, 190], [55, 168], [63, 210], [72, 224], [80, 205], [88, 240]].map(function (pair) { return { x: pair[0], y: pair[1] } }) } ]})})</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">Responses</h3> <p className="card-description">Time in milliseconds against size in kilobytes</p> </div> <Chart id="responses" type="scatter" label="Response time in milliseconds against size in kilobytes" series={[ { name: 'API', points: [[12, 38], [18, 52], [25, 61], [31, 70], [38, 96], [44, 88], [52, 120], [60, 131], [66, 150], [74, 142], [81, 171]].map(function (pair) { return { x: pair[0], y: pair[1] } }) }, { name: 'Pages', points: [[20, 160], [28, 150], [35, 175], [47, 190], [55, 168], [63, 210], [72, 224], [80, 205], [88, 240]].map(function (pair) { return { x: pair[0], y: pair[1] } }) } ]} /></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">Responses</h3> <p class="card-description">Time in milliseconds against size in kilobytes</p> </div> <Chart id="responses" type="scatter" label="Response time in milliseconds against size in kilobytes" series={[ { name: 'API', points: [[12, 38], [18, 52], [25, 61], [31, 70], [38, 96], [44, 88], [52, 120], [60, 131], [66, 150], [74, 142], [81, 171]].map(function (pair) { return { x: pair[0], y: pair[1] } }) }, { name: 'Pages', points: [[20, 160], [28, 150], [35, 175], [47, 190], [55, 168], [63, 210], [72, 224], [80, 205], [88, 240]].map(function (pair) { return { x: pair[0], y: pair[1] } }) } ]} /></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">Responses</h3> <p class="card-description">Time in milliseconds against size in kilobytes</p> </div> <Chart id="responses" type="scatter" label="Response time in milliseconds against size in kilobytes" :series="[ { name: 'API', points: [[12, 38], [18, 52], [25, 61], [31, 70], [38, 96], [44, 88], [52, 120], [60, 131], [66, 150], [74, 142], [81, 171]].map(function (pair) { return { x: pair[0], y: pair[1] } }) }, { name: 'Pages', points: [[20, 160], [28, 150], [35, 175], [47, 190], [55, 168], [63, 210], [72, 224], [80, 205], [88, 240]].map(function (pair) { return { x: pair[0], y: pair[1] } }) } ]" /> </div></template>#Bubbles
A point with a size is a bubble: a third measure, drawn as the dot's area. The area, not the radius, follows the size, so a bubble four times another reads as four times as large. Bubbles are a wash of their color inside an edge of it, so those that overlap show through each other, and the largest are drawn first, so a small one over a large one can still be reached.
Bubbles
<div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Markets</h3> <p class="card-description">Growth against share; a bubble is as large as its revenue</p> </div> <figure class="chart" id="markets"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('markets'), { type: 'scatter', label: 'Markets: growth in percent against share in percent, sized by revenue in millions', series: [{ name: 'Markets', points: [ { x: 4, y: 12, size: 40, label: 'Japan' }, { x: 9, y: 20, size: 120, label: 'Germany' }, { x: 14, y: 8, size: 20, label: 'Brazil' }, { x: 18, y: 26, size: 260, label: 'United States' }, { x: 6, y: 30, size: 64, label: 'India' }, { x: 12, y: 16, size: 90, label: 'France' } ] }]})})</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">Markets</h3> <p className="card-description">Growth against share; a bubble is as large as its revenue</p> </div> <Chart id="markets" type="scatter" label="Markets: growth in percent against share in percent, sized by revenue in millions" series={[{ name: 'Markets', points: [ { x: 4, y: 12, size: 40, label: 'Japan' }, { x: 9, y: 20, size: 120, label: 'Germany' }, { x: 14, y: 8, size: 20, label: 'Brazil' }, { x: 18, y: 26, size: 260, label: 'United States' }, { x: 6, y: 30, size: 64, label: 'India' }, { x: 12, y: 16, size: 90, label: 'France' } ] }]} /></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">Markets</h3> <p class="card-description">Growth against share; a bubble is as large as its revenue</p> </div> <Chart id="markets" type="scatter" label="Markets: growth in percent against share in percent, sized by revenue in millions" series={[{ name: 'Markets', points: [ { x: 4, y: 12, size: 40, label: 'Japan' }, { x: 9, y: 20, size: 120, label: 'Germany' }, { x: 14, y: 8, size: 20, label: 'Brazil' }, { x: 18, y: 26, size: 260, label: 'United States' }, { x: 6, y: 30, size: 64, label: 'India' }, { x: 12, y: 16, size: 90, label: 'France' } ] }]} /></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">Markets</h3> <p class="card-description">Growth against share; a bubble is as large as its revenue</p> </div> <Chart id="markets" type="scatter" label="Markets: growth in percent against share in percent, sized by revenue in millions" :series="[{ name: 'Markets', points: [ { x: 4, y: 12, size: 40, label: 'Japan' }, { x: 9, y: 20, size: 120, label: 'Germany' }, { x: 14, y: 8, size: 20, label: 'Brazil' }, { x: 18, y: 26, size: 260, label: 'United States' }, { x: 6, y: 30, size: 64, label: 'India' }, { x: 12, y: 16, size: 90, label: 'France' } ] }]" /> </div></template>Area is judged less truly than position: keep the measure that matters most on a scale and give the size to the one that only has to read as larger or smaller.
#Options
| Option | Default | |
|---|---|---|
label | none | What the chart shows and in what unit: the plot's accessible name |
series | [] | Each with a name and values, a value for a slice or a ring, or points for a scatter; optionally a category, a type and a ring's max |
min, max, ticks | fit, 4 | The ends of the scale and about how many steps mark it; xMin, xMax and xTicks for a scatter's scale across |
format, tickFormat | the locale's | How a value and a tick are written; xFormat for a scatter's scale across |
legend, toggle | with two series, true | Whether 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.