terezka / elm-charts / Chart.Attributes

This module contains attributes for editing elements in Chart and Chart.Svg. See Chart for usage examples.

Often a single attribute can change several different configurations, so the categories below are only guiding.


type alias Attribute x =
Internal.Helpers.Attribute x

Container

width : Basics.Float -> Attribute { a | width : Basics.Float }

height : Basics.Float -> Attribute { a | height : Basics.Float }

attrs : a -> Attribute { x | attrs : a }

htmlAttrs : a -> Attribute { x | htmlAttrs : a }

events : x -> Attribute { a | events : x }

margin : x -> Attribute { a | margin : x }

padding : x -> Attribute { a | padding : x }

Limits

range : x -> Attribute { a | range : x }

domain : x -> Attribute { a | domain : x }

limits : x -> Attribute { a | limits : x }

lowest : Basics.Float -> (Basics.Float -> Basics.Float -> Basics.Float -> Basics.Float) -> Attribute Internal.Coordinates.Axis

Change the lower bound of an axis.

CA.lowest -5 CA.orLower initial  -- { initial | min = -5, max = 10 }
CA.lowest -5 CA.orHigher initial -- { initial | min = 0, max = 10 }
CA.lowest 2 CA.exactly initial   -- { initial | min = 2, max = 10 }
CA.lowest 2 CA.less initial   -- { initial | min = -2, max = 10 }
CA.lowest 3 CA.more initial   -- { initial | min = 3, max = 10 }

where

initial : Chart.Svg.Axis
initial =
  { .. | min = 0, max = 10 }

highest : Basics.Float -> (Basics.Float -> Basics.Float -> Basics.Float -> Basics.Float) -> Attribute Internal.Coordinates.Axis

Same as lowest, but changes upper bound.

orLower : Basics.Float -> Basics.Float -> Basics.Float -> Basics.Float

See lowest for usage examples.

orHigher : Basics.Float -> Basics.Float -> Basics.Float -> Basics.Float

See lowest for usage examples.

exactly : Basics.Float -> Basics.Float -> Basics.Float -> Basics.Float

See lowest for usage examples.

more : Basics.Float -> Basics.Float -> Basics.Float -> Basics.Float

See lowest for usage examples.

less : Basics.Float -> Basics.Float -> Basics.Float -> Basics.Float

See lowest for usage examples.

window : Basics.Float -> Basics.Float -> Attribute Internal.Coordinates.Axis

Set an axis to an exact window.

CA.window 2 5 initial   -- { initial | min = 2, max = 5 }

where

initial : Axis
initial =
  { .. | min = 0, max = 10 }

likeData : Attribute Internal.Coordinates.Axis

Resets axis to fit data bounds.

zoom : Basics.Float -> Attribute Internal.Coordinates.Axis

Zoom with a certain percentage.

CA.range [ CA.zoom 150 ]

move : Basics.Float -> Attribute Internal.Coordinates.Axis

Offset entire range.

CA.move 5 initial   -- { initial | min = 5, max = 15 }

where

initial : Axis
initial =
  { .. | min = 0, max = 10 }

centerAt : Basics.Float -> Attribute Internal.Coordinates.Axis

Center range/domain at certain point.

CA.centerAt 20 initial -- { initial | min = -30, max = 70 }

where

initial : Axis
initial =
  { .. | min = 0, max = 100 }

pad : Basics.Float -> Basics.Float -> Attribute Internal.Coordinates.Axis

Add padding (in px) to range/domain.

CA.range [ CA.pad 5 10 ]

zero : Internal.Coordinates.Axis -> Basics.Float

Given an axis, find the value within it closest to zero.

CA.zero { dataMin = 0, dataMax = 10, min = 2, max = 5 } -- 2
CA.zero { dataMin = 0, dataMax = 10, min = -5, max = 5 } -- 0
CA.zero { dataMin = 0, dataMax = 10, min = -5, max = -2 } -- -2

middle : Internal.Coordinates.Axis -> Basics.Float

Get the middle value of your axis.

percent : Basics.Float -> Internal.Coordinates.Axis -> Basics.Float

Get the value at a certain percentage of the length of your axis.

Labels

fontSize : Basics.Int -> Attribute { a | fontSize : Maybe Basics.Int }

uppercase : Attribute { a | uppercase : Basics.Bool }

format : x -> Attribute { a | format : Maybe x }

position : x -> Attribute { a | position : x }

alignLeft : Attribute { a | anchor : Maybe Internal.Svg.Anchor }

alignRight : Attribute { a | anchor : Maybe Internal.Svg.Anchor }

alignMiddle : Attribute { a | anchor : Maybe Internal.Svg.Anchor }

ellipsis : Basics.Float -> Basics.Float -> Attribute { a | ellipsis : Maybe { height : Basics.Float, width : Basics.Float } }

Note: There is no SVG feature for ellipsis, so this turns labels into HTML.

Axis

amount : Basics.Int -> Attribute { a | amount : Basics.Int }

flip : Attribute { a | flip : Basics.Bool }

pinned : x -> Attribute { a | pinned : x }

ints : Attribute { a | generate : Internal.Svg.TickType }

times : Time.Zone -> Attribute { a | generate : Internal.Svg.TickType }

Coordinates

x : Basics.Float -> Attribute { a | x : Basics.Float }

y : Basics.Float -> Attribute { a | y : Basics.Float }

x1 : x -> Attribute { a | x1 : Maybe x }

y1 : Basics.Float -> Attribute { a | y1 : Maybe Basics.Float }

x2 : x -> Attribute { a | x2 : Maybe x }

y2 : Basics.Float -> Attribute { a | y2 : Maybe Basics.Float }

x2Svg : x -> Attribute { a | x2Svg : Maybe x }

y2Svg : x -> Attribute { a | y2Svg : Maybe x }

length : Basics.Float -> Attribute { a | length : Basics.Float }

moveLeft : Basics.Float -> Attribute { a | xOff : Basics.Float }

moveRight : Basics.Float -> Attribute { a | xOff : Basics.Float }

moveUp : Basics.Float -> Attribute { a | yOff : Basics.Float }

moveDown : Basics.Float -> Attribute { a | yOff : Basics.Float }

hideOverflow : Attribute { a | hideOverflow : Basics.Bool }

Decoration

border : String -> Attribute { a | border : String }

borderWidth : Basics.Float -> Attribute { a | borderWidth : Basics.Float }

color : String -> Attribute { a | color : String }

opacity : Basics.Float -> Attribute { a | opacity : Basics.Float }

highlight : Basics.Float -> Attribute { a | highlight : Basics.Float }

highlightWidth : Basics.Float -> Attribute { a | highlightWidth : Basics.Float }

highlightColor : String -> Attribute { a | highlightColor : String }

background : String -> Attribute { a | background : String }

noArrow : Attribute { a | arrow : Basics.Bool }

rotate : Basics.Float -> Attribute { a | rotate : Basics.Float }

striped : List (Attribute Internal.Svg.Pattern) -> Attribute { a | design : Maybe Internal.Svg.Design, opacity : Basics.Float }

dotted : List (Attribute Internal.Svg.Pattern) -> Attribute { a | design : Maybe Internal.Svg.Design, opacity : Basics.Float }

gradient : List String -> Attribute { a | design : Maybe Internal.Svg.Design, opacity : Basics.Float }

Bar

ungroup : Attribute { a | grouped : Basics.Bool }

roundTop : Basics.Float -> Attribute { a | roundTop : Basics.Float }

roundBottom : Basics.Float -> Attribute { a | roundBottom : Basics.Float }

spacing : Basics.Float -> Attribute { a | spacing : Basics.Float }

Lines

area : Basics.Float -> Attribute { a | area : Basics.Float, method : Maybe Internal.Svg.Method }

size : Basics.Float -> Attribute { a | size : Basics.Float }

dashed : x -> Attribute { a | dashed : x }

break : Attribute { a | break : Basics.Bool }

tickLength : Basics.Float -> Attribute { a | tickLength : Basics.Float }

tickDirection : Basics.Float -> Attribute { a | tickDirection : Basics.Float }

linear : Attribute { a | method : Maybe Internal.Svg.Method }

monotone : Attribute { a | method : Maybe Internal.Svg.Method }

stepped : Attribute { a | method : Maybe Internal.Svg.Method }

circle : Attribute { a | shape : Maybe Internal.Svg.Shape }

triangle : Attribute { a | shape : Maybe Internal.Svg.Shape }

square : Attribute { a | shape : Maybe Internal.Svg.Shape }

diamond : Attribute { a | shape : Maybe Internal.Svg.Shape }

plus : Attribute { a | shape : Maybe Internal.Svg.Shape }

cross : Attribute { a | shape : Maybe Internal.Svg.Shape }

Tooltip

onTop : Attribute { a | direction : Maybe Internal.Svg.Direction }

onBottom : Attribute { a | direction : Maybe Internal.Svg.Direction }

onRight : Attribute { a | direction : Maybe Internal.Svg.Direction }

onLeft : Attribute { a | direction : Maybe Internal.Svg.Direction }

onLeftOrRight : Attribute { a | direction : Maybe Internal.Svg.Direction }

onTopOrBottom : Attribute { a | direction : Maybe Internal.Svg.Direction }

offset : Basics.Float -> Attribute { a | offset : Basics.Float }

focal : (Internal.Coordinates.Position -> Internal.Coordinates.Position) -> Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

topLeft : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

topRight : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

topCenter : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

bottomLeft : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

bottomRight : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

bottomCenter : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

leftCenter : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

rightCenter : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

top : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

bottom : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

left : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

right : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

center : Attribute { a | focal : Maybe (Internal.Coordinates.Position -> Internal.Coordinates.Position) }

Legends

title : x -> Attribute { a | title : x }

row : Attribute { a | alignment : Internal.Svg.Alignment }

column : Attribute { a | alignment : Internal.Svg.Alignment }

Grid

noGrid : Attribute { a | grid : Basics.Bool }

withGrid : Attribute { a | grid : Basics.Bool }

dotGrid : Attribute { a | dotGrid : Basics.Bool }

Colors

pink : String

purple : String

blue : String

green : String

orange : String

turquoise : String

red : String

magenta : String

brown : String

mint : String

yellow : String

gray : String

darkYellow : String

darkBlue : String

darkGray : String

labelGray : String

Conditional helpers

noChange : Attribute a