Skip to content

Commit

Permalink
Merge branch 'main' into fix/deploy-config-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
KellyMerrick authored Jan 22, 2025
2 parents 17a1b3f + 302a7e0 commit 6b6c5fe
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/elm/Components/BarChart.elm
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,14 @@ view (BarChartConfig { title, width, height, padding, data, maybeMaxY, unit }) =
let
maxY =
case maybeMaxY of
Just max ->
max
Just max_ ->
max_

Nothing ->
List.maximum (List.map Tuple.second data)
|> Maybe.withDefault 0
max 1
(List.maximum (List.map Tuple.second data)
|> Maybe.withDefault 1
)

xScale : List ( Time.Posix, Float ) -> Scale.BandScale Time.Posix
xScale m =
Expand All @@ -202,7 +204,7 @@ view (BarChartConfig { title, width, height, padding, data, maybeMaxY, unit }) =

yAxis : Svg msg
yAxis =
Axis.left [ Axis.tickCount 5 ] yScale
Axis.left [ Axis.tickCount 5, Axis.tickFormat (Float.Extra.toFixedDecimalPlaces 1) ] yScale

column : Scale.BandScale Time.Posix -> ( Time.Posix, Float ) -> Svg msg
column scale ( date, value ) =
Expand Down Expand Up @@ -232,13 +234,13 @@ view (BarChartConfig { title, width, height, padding, data, maybeMaxY, unit }) =
[ div [ class "chart-header" ] [ text title ]
, TypedSvg.svg [ TypedSvg.Attributes.viewBox 0 0 width height ]
[ TypedSvg.g
[ TypedSvg.Attributes.transform [ Translate (padding - 1) (height - padding) ]
[ TypedSvg.Attributes.transform [ Translate (padding + 20) (height - padding) ]
, TypedSvg.Attributes.InPx.strokeWidth 2
, TypedSvg.Attributes.class [ "axis" ]
]
[ xAxis data ]
, TypedSvg.g
[ TypedSvg.Attributes.transform [ Translate (padding - 1) padding ]
[ TypedSvg.Attributes.transform [ Translate (padding + 20) padding ]
, TypedSvg.Attributes.InPx.strokeWidth 2
, TypedSvg.Attributes.class [ "axis" ]
]
Expand Down

0 comments on commit 6b6c5fe

Please sign in to comment.