Visualize.Shape.Symbol (Visualize v0.2.25)

Copy Markdown View Source

Symbol generator for categorical point marks.

Provides various symbol shapes commonly used in scatter plots and legends to distinguish categories.

Examples

symbol = Visualize.Shape.Symbol.new()
  |> Visualize.Shape.Symbol.type(:circle)
  |> Visualize.Shape.Symbol.size(64)

path_data = Visualize.Shape.Symbol.generate(symbol)

Summary

Functions

Generates the SVG path data string.

Generates a Path struct

Creates a new symbol generator

Sets the symbol size in square pixels.

Sets the symbol type

Returns all available symbol types

Types

symbol_type()

@type symbol_type() ::
  :circle | :cross | :diamond | :square | :star | :triangle | :wye

t()

@type t() :: %Visualize.Shape.Symbol{
  size: number() | (any() -> number()),
  type: symbol_type() | (any() -> symbol_type())
}

Functions

generate(symbol, data \\ nil)

@spec generate(t(), any()) :: String.t()

Generates the SVG path data string.

Note: For backend-agnostic usage, prefer generate_path/2 and render with your chosen backend.

generate_path(symbol, data)

@spec generate_path(t(), any()) :: Visualize.IR.Path.t()

Generates a Path struct

new()

@spec new() :: t()

Creates a new symbol generator

size(symbol, size)

@spec size(t(), number() | (any() -> number())) :: t()

Sets the symbol size in square pixels.

For a circle, this is the area. For other symbols, the bounding box area is approximately this size.

type(symbol, type)

@spec type(t(), symbol_type() | (any() -> symbol_type())) :: t()

Sets the symbol type

types()

@spec types() :: [symbol_type()]

Returns all available symbol types