Commit 3f10486e authored by Mael NICOLAS's avatar Mael NICOLAS

done testStyle and textWeight, working on align

parent c0af47ff
...@@ -97,7 +97,7 @@ series' = ...@@ -97,7 +97,7 @@ series' =
opt :: Option opt :: Option
opt = opt =
{ {
title: title' title: title
,legend: Nothing ,legend: Nothing
,tooltip: tooltip' ,tooltip: tooltip'
,grid: {containLabel: true} ,grid: {containLabel: true}
...@@ -106,7 +106,9 @@ opt = ...@@ -106,7 +106,9 @@ opt =
,series: [series'] ,series: [series']
,dataZoom: [dz1', dz1', dz2', dz2'] ,dataZoom: [dz1', dz1', dz2', dz2']
} }
where title' =
title :: Title
title =
{ {
id: "" id: ""
,show: true ,show: true
...@@ -126,16 +128,22 @@ opt = ...@@ -126,16 +128,22 @@ opt =
,top: renderTopRelativePosition Middle ,top: renderTopRelativePosition Middle
,right: renderNumber 60.0 ,right: renderNumber 60.0
,bottom: renderPercentage 40.0 ,bottom: renderPercentage 40.0
,backgroundColor: renderCSSColor turquoise ,backgroundColor: renderChartColor turquoise
,borderColor: renderCSSColor violet ,borderColor: renderChartColor violet
,borderWidth: 20.0 ,borderWidth: 20.0
,borderRadius: Left 20.0 ,borderRadius: Left 20.0
,shadowBlur: 40.0 ,shadowBlur: 40.0
,shadowColor: renderCSSColor turquoise ,shadowColor: renderChartColor turquoise
,shadowOffsetX: 20.0 ,shadowOffsetX: 20.0
,shadowOffsetY: 40.0 ,shadowOffsetY: 40.0
} }
textStyle :: ChartFontStyle
textStyle =
{
}
charts :: Echarts charts :: Echarts
charts = charts =
{ {
......
...@@ -2,12 +2,10 @@ module Charts.Types where ...@@ -2,12 +2,10 @@ module Charts.Types where
import Unsafe.Coerce import Unsafe.Coerce
import CSS (Color, toHexString) import CSS (Color, FontStyle(..), Value(..), toHexString, Prefixed(..))
import Data.Either (Either) import Data.Either (Either)
import Data.Generic (class Generic, gShow)
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Data.String (toLower) import Prelude ((<>), class Show, show, ($), Unit, (<<<))
import Prelude ((<>), class Show, show, ($), (>>>), Unit, (<<<))
type NumberOrArray = Either Number (Array Number) type NumberOrArray = Either Number (Array Number)
...@@ -17,17 +15,31 @@ instance showTopRelativePosition :: Show TopRelativePosition ...@@ -17,17 +15,31 @@ instance showTopRelativePosition :: Show TopRelativePosition
show (Middle) = "middle" show (Middle) = "middle"
show (Bottom) = "bottom" show (Bottom) = "bottom"
data LeftRelativePosition = LeftPos | Center | RightPos data LeftRelativePosition = LeftPos | Center | RightPos
instance showLeftRelativePosition :: Show LeftRelativePosition instance showLeftRelativePosition :: Show LeftRelativePosition
where show (LeftPos) = "left" where show (LeftPos) = "left"
show (Center) = "center" show (Center) = "center"
show (RightPos) = "right" show (RightPos) = "right"
newtype CSSColor = CSSColor String newtype ChartColor = ChartColor String
renderChartColor :: Color -> ChartColor
renderChartColor = ChartColor <<< toHexString
newtype ChartFontStyle = ChartFontStyle String
renderChartFontStyle :: FontStyle -> ChartFontStyle
renderChartFontStyle (FontStyle (Value (Plain "italic"))) = ChartFontStyle "italic"
renderChartFontStyle (FontStyle (Value (Plain "oblique"))) = ChartFontStyle "oblique"
renderChartFontStyle _ = ChartFontStyle "normal"
newtype ChartFontWeight = ChartFontWeight String
renderCSSColor :: Color -> CSSColor renderChartFontWeight :: FontWeight -> ChartFontWeight
renderCSSColor = CSSColor <<< toHexString renderChartFontWeight (FontStyle (Value (Plain "bold")))) = ChartFontWeight "bold"
renderChartFontWeight (FontStyle (Value (Plain "bolder")))) = ChartFontWeight "bolder"
renderChartFontWeight (FontStyle (Value (Plain "lighter")))) = ChartFontWeight "lighter"
renderChartFontWeight _ = ChartFontWeight "normal"
foreign import data Position :: Type -> Type foreign import data Position :: Type -> Type
...@@ -90,12 +102,12 @@ type Title = ...@@ -90,12 +102,12 @@ type Title =
, top :: Position TopRelativePosition -- default 'auto' , top :: Position TopRelativePosition -- default 'auto'
, right :: Position Unit -- default 'auto' , right :: Position Unit -- default 'auto'
, bottom :: Position Unit -- default 'auto' , bottom :: Position Unit -- default 'auto'
, backgroundColor :: CSSColor -- default 'transparent'' , backgroundColor :: ChartColor -- default 'transparent''
, borderColor :: CSSColor -- default '#ccc' , borderColor :: ChartColor -- default '#ccc'
, borderWidth :: Number -- default '1' , borderWidth :: Number -- default '1'
, borderRadius :: NumberOrArray -- default 0; data NumberOrArray = Number | Array Number , borderRadius :: NumberOrArray -- default 0; data NumberOrArray = Number | Array Number
, shadowBlur :: Number , shadowBlur :: Number
, shadowColor :: CSSColor , shadowColor :: ChartColor
, shadowOffsetX :: Number , shadowOffsetX :: Number
, shadowOffsetY :: Number , shadowOffsetY :: Number
} }
...@@ -151,12 +163,12 @@ type Data = ...@@ -151,12 +163,12 @@ type Data =
} }
type SubtextStyle = type SubtextStyle =
{ color :: Color { color :: ChartColor
, fontStyle :: String , fontStyle :: ChartFontStyle
, fontWeight :: String , fontWeight :: ChartFontWeight
, fontFamily :: String , fontFamily :: String
, fontSize :: Int , fontSize :: Int
, align :: String , align :: LeftRelativePosition
, verticalAlign :: String , verticalAlign :: String
, lineHeight :: Number , lineHeight :: Number
, width :: Number , width :: Number
......
...@@ -18,7 +18,7 @@ performAction :: forall eff props. PerformAction (dom :: DOM | eff) State props ...@@ -18,7 +18,7 @@ performAction :: forall eff props. PerformAction (dom :: DOM | eff) State props
performAction _ _ _ = pure unit performAction _ _ _ = pure unit
render :: forall props. Render State props Action render :: forall props. Render State props Action
render dispatch _ state _ = [text "Dashboard", histogram2] render dispatch _ state _ = [histogram2]
layoutDashboard :: forall props eff. Spec (dom :: DOM | eff) State props Action layoutDashboard :: forall props eff. Spec (dom :: DOM | eff) State props Action
layoutDashboard = simpleSpec performAction render layoutDashboard = simpleSpec performAction render
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment