lauber00/line-charts/1.0.1

NOTE: the latest version is 1.0.3

Renamed to volgariver6/line-charts. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as lauber00/line-charts still install under that name. 4 versions of 4 come from the new location (see their notes).

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/volgariver6/line-charts.

What we checked: The repo moved to github.com/volgariver6/line-charts. Rebuilt with git archive from commit 0f11d0eac8ee of https://github.com/volgariver6/line-charts (zip prefix lauber00-line-charts-eb18a18/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 753022dabb810e0f2ef35feb04e89192f71460de.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/lauber00/line-charts/zipball/1.0.1/

LineChart.Axis.Tick

type alias Config msg =
Config msg

Used in the configuration in the ticks property of the options passed to Axis.custom.

xAxisConfig : Axis.Config Data msg
xAxisConfig =
  Axis.custom
    { ...
    , ticks = ticksConfig
    }


ticksConfig : Ticks.Config msg
ticksConfig =
  Ticks.intCustom 7 Tick.int
  --                ^^^^^^^^
  -- or
  Ticks.timeCustom 7 Tick.time
  -- or
  Ticks.floatCustom 7 Tick.float
  -- or
  Ticks.floatCustom 7 customTick
  -- or ... you get it

See the full example here.

int : Int -> Config msg
float : Float -> Config msg
time : Time -> Config msg

Special styles

You can also make your own with custom!

long : Float -> Config msg
gridless : Float -> Config msg
labelless : Float -> Config msg
opposite : Float -> Config msg

Customiztion

custom : Properties msg -> Config msg

Make your own tick!

customTick : Float -> Tick.Config msg
customTick number =
  let
    color =
      -- Change the color based on value!
      if number < 50 then Colors.purple
      else if number < 70 then Colors.green
      else Colors.pinkLight


    label =
      Junk.label color (toString number)
  in
  Tick.custom
    { position = number
    , color = Colors.black
    , width = 1
    , length = 7
    , grid = True
    , direction = Tick.positive
    , label = Just label
    }

See the full example here.

type alias Properties msg =
{ position : Float
, color : Color
, width : Float
, length : Float
, grid : Bool
, direction : Direction
, label : Maybe (Svg msg)
}

Explanation:

  • position is the position on the axis.
  • color is the color of the little line.
  • width is the width of the little line.
  • length is the length of the little line.
  • grid is whether a grid will be placed by the tick or not.
  • direction is the direction of the little line. If the tick in question is on the x-axis that means that positive means the tick points up, and negative points down.
  • label is the label. If set to Nothing, no label will be drawn.
type alias Direction =
Direction

The direction of the little line. If the tick in question is on the x-axis that means that positive means the tick points up, and negative points down.

negative : Direction
positive : Direction

Time formatting

format : Time -> String

This is the default formatting of the time type. Useful when you want to change other properties of your time tick, but won't bother with the formatting.

tickConfig : Tick.Time -> Tick.Config msg
tickConfig time =
  Tick.custom
    { position = time.timestamp
    , color = Color.blue
    , width = 1
    , length = 7
    , grid = True
    , direction = Tick.positive
    , label = Just <|
        Junk.label Color.blue (Tick.format time)
    }
type alias Time =
{ timestamp : Posix
, zone : Zone
, isFirst : Bool
, interval : Interval
, change : Maybe Unit
}

Explanation:

  • ** timestamp ** is the position where the tick goes on the axis.
  • ** isFirst ** is whether this is the first tick or not.
  • ** interval ** is the interval at which all the ticks are spaced.
  • ** change ** is a Just when the tick is changing to a larger unit than used in the interval. E.g. if the interval is 2 hours, then this will be a Just Day when the day changes. Useful if you want a different formatting for those ticks!
type alias Interval =
{ unit : Unit
, multiple : Int
}

The interval at which ticks are spaced. If ticks a spaced with two hours, this will be { unit = Hour, multiple = 2 }.

type Unit
= Millisecond
| Second
| Minute
| Hour
| Day
| Month
| Year

You can format your tick label differently based on it's unit.