Advanced Usage: 3 - Scatter Chart


Scatter Chart

Scatter chart defined as data-type="scatter" plots shapes or labels/letters scattered across x and y axes. Letters to plot with their colors can be provided in the form of data sets where each set represent a single letter/shape to plot. Additionaly a third dimension representing the size/volume of the shape can also be provided inside sets.

3.1 Scatter Chart Configuration

Tip: The Color Pick can be used for RGBA / HSLA / HEX color generation and comparison.

3.2 Simple Scatter Chart

3.3 Scatter Chart with custom shape
JavaScript: drawStar function (Note how a shape function(drawStar) is provided to replace letter with a custom shape by prefixing label string with 'fn#')
function drawStar(ctx, x, y, z) { var r = z || ctx.canvas.width/25, p = 5; ctx.save(); ctx.beginPath(); ctx.translate(x, y); ctx.moveTo(0,0-r); for (var i = 0; i < p; i++) { ctx.rotate(Math.PI / p); ctx.lineTo(0, 0 - (r * 0.5)); ctx.rotate(Math.PI / p); ctx.lineTo(0, 0 - r); } ctx.fill(); ctx.restore(); }

3.4 Scatter Chart with Letters and Colors

3.5 Scatter Chart with TextStroke

3.6 Scatter Chart with Custom Shape and Third Dimension (Size)
JavaScript: drawStar function (Note how a shape function(drawSquare) is provided to replace letter with a custom shape by prefixing label string with 'fn#')
function drawSquare(ctx, x, y, z) { var r = z || ctx.canvas.width/25, p = 5; ctx.save(); ctx.beginPath(); ctx.fillRect(x-z/2,y-z/2,z,z); ctx.fill(); ctx.restore(); }