Module

Hylograph.Shape.Pie

Package
purescript-hylograph-selection
Repository
afcondon/purescript-hylograph-selection

Pure PureScript Pie Layout

Computes start/end angles for pie and donut charts. No D3 dependency.

Usage

import Hylograph.Shape.Pie (pie, PieSlice)
import Hylograph.Shape.Arc (arcPath)

let data = [30.0, 50.0, 20.0]
let slices = pie identity data

-- Each slice has { value, startAngle, endAngle, index, data }
let paths = map (\s -> arcPath { innerRadius: 0.0, outerRadius: 100.0 } s) slices

#PieSlice Source

type PieSlice a = { data :: a, endAngle :: Number, index :: Int, padAngle :: Number, startAngle :: Number, value :: Number }

A slice of the pie with computed angles

#PieConfig Source

type PieConfig = { endAngle :: Number, padAngle :: Number, sort :: forall a. Array a -> Array a, startAngle :: Number }

Configuration for pie layout

#pie Source

pie :: forall a. (a -> Number) -> Array a -> Array (PieSlice a)

Compute pie slices from data using a value accessor

-- Simple array of numbers
pie identity [10.0, 20.0, 30.0]

-- Array of records
pie _.sales [{ name: "A", sales: 100.0 }, { name: "B", sales: 200.0 }]

#pieWithConfig Source

pieWithConfig :: forall a. PieConfig -> (a -> Number) -> Array a -> Array (PieSlice a)

Compute pie slices with custom configuration

#defaultPieConfig Source

defaultPieConfig :: PieConfig

Default pie configuration Full circle, no padding, no sorting

#sortByValue Source

sortByValue :: forall a. Ord a => Array a -> Array a

Sort comparator: by value ascending

#sortByValueDesc Source

sortByValueDesc :: forall a. Ord a => Array a -> Array a

Sort comparator: by value descending

Modules
Data.DependencyGraph
Hylograph.AST
Hylograph.Axis.Axis
Hylograph.Brush
Hylograph.Brush.FFI
Hylograph.Brush.Types
Hylograph.Classify
Hylograph.Data.Graph
Hylograph.Data.Graph.Algorithms
Hylograph.Data.Node
Hylograph.Data.Tree
Hylograph.Expr.Animation
Hylograph.Expr.Attr
Hylograph.Expr.Datum
Hylograph.Expr.Expr
Hylograph.Expr.Friendly
Hylograph.Expr.Integration
Hylograph.Expr.Interpreter.CodeGen
Hylograph.Expr.Interpreter.Eval
Hylograph.Expr.Interpreter.Meta
Hylograph.Expr.Interpreter.PureSVG
Hylograph.Expr.Interpreter.SVG
Hylograph.Expr.Path
Hylograph.Expr.Path.Generators
Hylograph.Expr.Sugar
Hylograph.Expr.Units
Hylograph.HATS
Hylograph.HATS.Friendly
Hylograph.HATS.InterpreterTick
Hylograph.HATS.Transitions
Hylograph.Interaction.Brush
Hylograph.Interaction.Coordinated
Hylograph.Interaction.Pointer
Hylograph.Interaction.Zoom
Hylograph.Internal.Attribute
Hylograph.Internal.Behavior.FFI
Hylograph.Internal.Behavior.Types
Hylograph.Internal.Capabilities.Selection
Hylograph.Internal.Capabilities.Transition
Hylograph.Internal.FFI
Hylograph.Internal.Selection.Join
Hylograph.Internal.Selection.Operations
Hylograph.Internal.Selection.Operations.Conversions
Hylograph.Internal.Selection.Operations.Helpers
Hylograph.Internal.Selection.Operations.Selection
Hylograph.Internal.Selection.Query
Hylograph.Internal.Selection.Types
Hylograph.Internal.Transition.FFI
Hylograph.Internal.Transition.Manager
Hylograph.Internal.Transition.Scene
Hylograph.Internal.Transition.Types
Hylograph.Internal.Types
Hylograph.Interpreter.D3
Hylograph.Interpreter.English
Hylograph.Interpreter.Mermaid
Hylograph.Interpreter.MetaAST
Hylograph.Interpreter.SemiQuine
Hylograph.Interpreter.SemiQuine.TreeToCode
Hylograph.Interpreter.SemiQuine.Types
Hylograph.Render
Hylograph.Scale
Hylograph.Scale.FP
Hylograph.Shape.Arc
Hylograph.Shape.Pie
Hylograph.Shape.Polygon
Hylograph.Tooltip
Hylograph.Transform
Hylograph.TreeDSL
Hylograph.TreeDSL.ShapeTree
Hylograph.Unified
Hylograph.Unified.Attribute
Hylograph.Unified.DataDSL
Hylograph.Unified.Display
Hylograph.Unified.Examples
Hylograph.Unified.Join
Hylograph.Unified.Sugar