Comments (5)
Already implemented now!
from line-charts.
@2mol Seems like a natural choice.
from line-charts.
Turns out that the Svg library expects String
for Attributes.stroke
and the like. Replacing the type itself really doesn't need all that many changes. The choice is between
- pulling
eskimoblood/elm-color-extra
as an additional dependency (just forcolorToHex
) - waiting for elm-svg to maybe use the core
Color
type - waiting for core to provide an equivalent to
colorToHex
Did I miss an option? I think neither options are great, but maybe leaving it as-is and waiting for Color
to be used in svg makes the most sense?
from line-charts.
Hi! Thanks for your initiative! I already made a note about this change, but it will probably be the done in a later release, as it is not blocking. However, if you want to come up with some suggestions for this, you're more than welcome :)
from line-charts.
Cool. Since I think that it's better to sometimes copy a little bit of code, my suggestion is a colorToHex
helper function for somewhere like Internals/Util.elm
. I went ahead and wrote a simple implementation.
I am aware that in addition to elm-color-extra
, there is also rtfeldman/hex
, BUT with the assumption that color channels are always in 0-255, the helper functions are fairly simple.
So I would like to make a case to use the code below, maybe with the goal of getting a cleaner version of it into core Color
.
If people are ok with this, then I can weave it in and send a PR.
(sorry if it's bad form to paste a big chunk of code, but at least it's REPL-testable)
module ColorUtil exposing (colorToHex)
import Color exposing (Color)
import Dict exposing (Dict)
colorToHex : Color -> String
colorToHex c =
let
{ red, green, blue } =
Color.toRgb c
in
[ red, green, blue ]
|> List.map toHex
|> String.concat
hexDict : Dict Int String
hexDict =
[ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" ]
|> List.indexedMap (,)
|> Dict.fromList
toHex : Int -> String
toHex n =
let
digit1 =
n // 16
digit0 =
if digit1 /= 0 then
n % (digit1 * 16)
else
n
( hex1, hex0 ) =
( Dict.get digit1 hexDict
, Dict.get digit0 hexDict
)
in
case ( hex1, hex0 ) of
( Just a, Just b ) ->
a ++ b
_ ->
"00"
from line-charts.
Related Issues (20)
- A transparent line isn't transparent HOT 1
- Legends.none still takes up space HOT 4
- Docs wrong for Junk.hover
- `getWithin` buggy when page gets scrolled
- Feature: (de-)selectable lines
- Create LineChart.Axis.Title.none
- Type name typo: 'Transfrom'
- Feature request: plot multiple values of 1 data type in a chart
- `elm package install` doesn't exist in elm 0.19.0 HOT 12
- Junk.hoveryMany doesn't work for more than 310 points HOT 5
- Feature request: annotation HOT 1
- HoverMany and Hover don't actually hover HOT 6
- LineChart.Axis.Ticks.time approximate ticks amount is surprising. HOT 2
- After updating to Elm 0.19, Example4 Junk appears below chart HOT 2
- README out of date for elm 0.19 HOT 1
- Update tests to 0.19
- Convert example to use elm 0.19 HOT 1
- </br> shown on package.elm-lang.org
- Test.Html.Query fails to find LineChart by classes
- do not run as described
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from line-charts.