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.

Chart "Revenue against ad spend, per day" with 2 series. Search ads: 30 values, lowest 1,226 € at 213, highest 3,362 € at 788, trend rising. Display ads: 30 values, lowest 1,280 € at 553, highest 1,745 € at 482, trend stable. Revenue against ad spend, per day1k2k3k4k100200300400500600700800Ad spend, €Revenue, €Search adsDisplay adsUse Left and Right to move between points, Up and Down to change series. Press Escape to leave.
Code
Razor
<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.

Chart with 1 series. Delivery: 300 values, lowest 11.7 h at 4, highest 104.5 h at 894, trend rising. 0501001500100200300400500600700800900Distance, kmHoursUse Left and Right to move between points. Press Escape to leave.
Code
Razor
<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.

Chart "Stores: size against revenue" with 2 series. Lund: 5 values, lowest 262 € at 1,300, highest 350 € at 950, trend stable, Visitors per day 180 to 1,500. Malmö: 5 values, lowest 241 € at 1,600, highest 332 € at 820, trend stable, Visitors per day 300 to 2,600. Stores: size against revenue2002503003504000.4k0.6k0.8k1k1.2k1.4k1.6k1.8k2k2.2kFloor area, m²Revenue per m², €LundMalmöVisitors per day2,000500Use Left and Right to move between points, Up and Down to change series. Press Escape to leave.
Code
Razor
<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

OptionDefaultMeaning
MarkerSize5Marker diameter in pixels. Bubbles: the largest bubble's diameter, by default from the chart size.
TrendLinefalseA dashed least-squares line from the first to the last point.
XValueNumbers or times. Numeric axes get nice ranges with room at the edges.
SizeValueEach 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.SizesautoOn 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.

An unhandled error has occurred. Reload 🗙