Lattice Grid

blog

Venn Chart for Customers Across Products

Building…
Loading a live grid…

If you are a product marketer, the question behind every cross-sell plan is how many of your customers use product A, how many use product B, and how many use both. The size of that overlap tells you whether a second product is a niche add-on or something most customers end up wanting.

A venn chart answers it. Each product is a circle sized by its customers, and the overlap between the circles is the customers who use both, with every region’s count written in it. The chart above is bound to the grid beneath it, one row per customer, so filtering the rows redraws the circles. Filter the Region or Plan column and see the overlap for just those customers.

Why a venn chart and not a bar chart

A bar chart can show the three counts, but it cannot show that the third group is made of people who are also in the first two. A venn chart keeps the overlap as a shape of its own, and the circles are sized so each area matches its set. Click a region and the grid filters to exactly those customers, so you can go from the picture to the list you would email.

The chart over a grid

Each product is a boolean column on the customer row: true when that customer uses it. Name the columns in sets and the chart counts every region off the grid’s own filtered rows. Customers who use neither are counted apart and printed under the picture. Venn is an opt-in chart type, so you import its module once after the charts module. Here is the example in plain JavaScript, with sample rows inline in place of your own.

import { createGrid } from '@toclocoinc/lattice-grid';
import '@toclocoinc/lattice-grid/css';
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
import '@toclocoinc/lattice-grid/modules/chart-venn';

const regions = ['North', 'South', 'East', 'West'];
const use = [[1, 0], [1, 1], [0, 1], [1, 0], [1, 1], [0, 0], [0, 1], [1, 0]];
const rows = Array.from({ length: 24 }, (_, i) => ({
  id: i + 1, customer: `Customer ${i + 1}`, region: regions[i % 4],
  reports: !!use[i % 8][0], alerts: !!use[i % 8][1],
}));

const gridEl = document.createElement('div');
const chartEl = document.createElement('div');
gridEl.style.height = '240px';
chartEl.style.height = '420px';
document.body.append(gridEl, chartEl);

const grid = createGrid(gridEl, {
  rowKey: 'id', rows,
  columns: [
    { field: 'customer', title: 'Customer' },
    { field: 'region', title: 'Region', filter: { type: 'set' } },
    { field: 'reports', title: 'Reports', type: 'boolean' },
    { field: 'alerts', title: 'Alerts', type: 'boolean' },
  ],
});
createChart({ grid, container: chartEl, type: 'venn', sets: ['reports', 'alerts'],
  title: 'Customers by product' });

The same thing in React

The React adapter is a factory, so you build the component once at module scope. The ref’s grid is the real grid, which is what the chart binds to.

import React, { useEffect, useRef } from 'react';
import { createGrid } from '@toclocoinc/lattice-grid';
import '@toclocoinc/lattice-grid/css';
import { createLatticeGrid } from '@toclocoinc/lattice-grid/modules/react';
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
import '@toclocoinc/lattice-grid/modules/chart-venn';

const LatticeGrid = createLatticeGrid({ React, createGrid });
const regions = ['North', 'South', 'East', 'West'];
const use = [[1, 0], [1, 1], [0, 1], [1, 0], [1, 1], [0, 0], [0, 1], [1, 0]];
const rows = Array.from({ length: 24 }, (_, i) => ({
  id: i + 1, customer: `Customer ${i + 1}`, region: regions[i % 4],
  reports: !!use[i % 8][0], alerts: !!use[i % 8][1],
}));
const columns = [
  { field: 'customer', title: 'Customer' },
  { field: 'region', title: 'Region', filter: { type: 'set' } },
  { field: 'reports', title: 'Reports', type: 'boolean' },
  { field: 'alerts', title: 'Alerts', type: 'boolean' },
];

export function ProductOverlap() {
  const gridRef = useRef(null);
  const chartRef = useRef(null);
  useEffect(() => {
    const chart = createChart({ grid: gridRef.current.grid, container: chartRef.current,
      type: 'venn', sets: ['reports', 'alerts'], title: 'Customers by product' });
    return () => chart.destroy();
  }, []);
  return (<>
    <LatticeGrid ref={gridRef} rowKey="id" columns={columns} rows={rows} style={{ height: 200 }} />
    <div ref={chartRef} style={{ height: 360 }} />
  </>);
}

The options used

These are the rows of the charts reference for the options in the listings above.

Option Type What it does
grid Grid Required. The grid to read.
container Element or string Required. Where to draw.
type string 'venn' here, one circle per set.
sets string[] A venn’s membership as boolean columns, two or three of them.
title string Drawn above the plot.

Reading the overlap

Look first at the lens where the circles meet, because that is the share of customers already using both products. In the example, most customers use only one product, and the overlap is the group a bundle or an in-app prompt can reach. Filter the Region column to compare a region against the whole, and clear it to see the total again. Two or three sets are the limit; with more, the chart says so rather than leave a set out.

Next

See the venn beside the other specialist charts in the specialist family demo, read the full list of chart types on the charts page, or follow the how-to for a chart that follows the grid.

Read next

  • Pictorial Chart of Fleet by Vehicle Type

    Bind a pictorial chart to a grid of vehicle counts, one icon for every ten vehicles. Filter the rows by depot and the icons redraw.

  • Pyramid Chart for a Content Audience

    Bind a pyramid chart to a grid of audience counts: reach, engaged, subscribers, customers. Filter the rows by channel to redraw the layers.

  • OHLC Chart for Commodity Prices

    Bind an OHLC chart to a grid of daily open, high, low and close prices. Filter the rows by week to redraw the bars and time a purchase.

All posts RSS