Scatter and bubbles
A marker per point shows how two measures relate: revenue against ad spend, delivery time against distance, response time against traffic. The order of the points does not matter. Give each point a size too and it is a bubble chart: a third measure at a glance.
Ad spend and revenue
Thirty days of ads: what the store spent each day and the revenue the ads brought in. TrendLine draws the
least-squares line through the points: search ads climb, so more spend brings more revenue; the display ads' line is flat, so
spending more on them does not pay off. Hover a point: the tooltip shows the nearest point, not everything at that x.
Code
<RioChart Items="ads" Title="Revenue against ad spend, per day"
XAxis="@(new AxisOptions { Title = "Ad spend, €" })" YAxis="@(new AxisOptions { Title = "Revenue, €" })">
<ScatterSeries Name="Search ads" XValue="a => a.SearchSpend" YValue="a => a.SearchRevenue" Format="#,0 €" TrendLine="true" />
<ScatterSeries Name="Display ads" XValue="a => a.DisplaySpend" YValue="a => a.DisplayRevenue" Format="#,0 €" TrendLine="true" />
</RioChart>Delivery times
Hours from dispatch to delivery against distance: a day in town, a day or two further away, three to four days to remote places. Smaller markers keep 300 deliveries readable; the markers are translucent, so dense areas look darker.
Code
<RioChart Items="deliveries" XAxis="@(new AxisOptions { Title = "Distance, km" })" YAxis="@(new AxisOptions { Title = "Hours" })">
<ScatterSeries Name="Delivery" XValue="d => d.Km" YValue="d => d.Hours" Format="0.0 'h'" MarkerSize="4" />
</RioChart>Bubbles
SizeValue sizes each marker by a third measure: here a store's floor area against its revenue per m², with visitors
per day as the size. A bubble's area, not its width, is proportional to the size, so a store with four times the visitors is
twice as wide. All bubbles in a chart share one scale, so the cities compare. Large bubbles are drawn first and the axes leave
room for them at the edges. The size legend on the right shows circles for a few round sizes at their real size, so you can
read a bubble's size off the chart; hover a bubble for its exact size under SizeName.
Code
<RioChart TItem="Store" Title="Stores: size against revenue"
XAxis="@(new AxisOptions { Title = "Floor area, m²" })" YAxis="@(new AxisOptions { Title = "Revenue per m², €" })">
@foreach (var (city, cityStores) in storesPerCity) // grouped once, not in the markup
{
<ScatterSeries Items="cityStores" Name="@city" XValue="s => s.Area" YValue="s => s.Revenue" Format="0 €"
SizeValue="s => s.Visitors" SizeName="Visitors per day" SizeFormat="#,0" />
}
</RioChart>Options
| Option | Default | Meaning |
|---|---|---|
MarkerSize | 5 | Marker diameter in pixels. Bubbles: the largest bubble's diameter, by default from the chart size. |
TrendLine | false | A dashed least-squares line from the first to the last point. |
XValue | Numbers or times. Numeric axes get nice ranges with room at the edges. | |
SizeValue | Each item's size; makes a bubble chart. Sizes of zero or less, or null, are not drawn; aggregated points add up their sizes. | |
SizeName | "Size" | What the size is, shown with it in the tooltip. |
SizeFormat | .NET format string for the size, e.g. "#,0". | |
Legend.Sizes | auto | On the chart's LegendOptions: the size legend right of the plot. Auto shows it when the chart is at least 360 px wide and has room for a legend; false hides it, true shows it at any width. JSON: "legend": { "sizes": false }. |
| JSON | "type": "scatter" (also "points"), with "markerSize" and "trendLine"; "type": "bubble" with "size" naming the size field, and "sizeName" and "sizeFormat". |
A chart with scatter series finds the nearest point in both directions, so its tooltip is not shared. Scatter series work with line series in the same chart (e.g. a break-even line), zoom, keyboard navigation, export and the canvas layer.