Commit 5bbc4bc6 authored by Mael NICOLAS's avatar Mael NICOLAS

working on type

parent 24006ff8
...@@ -3,10 +3,11 @@ module Chart where ...@@ -3,10 +3,11 @@ module Chart where
import Prelude import Prelude
import CSS (Color, white) import CSS (Color, white)
import React.DOM.Props (Props, unsafeFromPropsArray, unsafeMkProps) import Data.Maybe (Maybe(..))
import React as R import React as R
import React.DOM (p) import React.DOM (p)
import React.DOM.Props (Props, className, unsafeFromPropsArray) import React.DOM.Props (Props, className, unsafeFromPropsArray)
import React.DOM.Props (Props, unsafeFromPropsArray, unsafeMkProps)
import ReactDOM as RDOM import ReactDOM as RDOM
import Thermite (Render, Spec, createReactSpec, defaultPerformAction, simpleSpec) import Thermite (Render, Spec, createReactSpec, defaultPerformAction, simpleSpec)
...@@ -57,14 +58,14 @@ type OptsLoading = ...@@ -57,14 +58,14 @@ type OptsLoading =
} }
type Option = type Option =
{ title :: Title { title :: Maybe Title
, legend :: Legend , legend :: Maybe Legend
, tooltip :: Tooltip , tooltip :: Maybe Tooltip
, grid :: Grid , grid :: Maybe Grid
, xAxis :: Array XAxis , xAxis :: Maybe Array XAxis
, yAxis :: Array YAxis , yAxis :: Maybe Array YAxis
, series :: Array Series , series :: Maybe Array Series
, dataZoom :: Array DataZoom , dataZoom :: Maybe Array DataZoom
} }
...@@ -81,33 +82,33 @@ type Grid = ...@@ -81,33 +82,33 @@ type Grid =
} }
type Legend = type Legend =
{"type" :: String {"type" :: Maybe String
, show :: Boolean , show :: Maybe Boolean
, zlevel :: Number , zlevel :: Maybe Number
, z :: Number , z :: Maybe Number
, left :: Number , left :: Maybe Number
, top :: Number , top :: Maybe Number
, right :: Number , right :: Maybe Number
, bottom :: Number , bottom :: Maybe Number
, width :: Number , width :: Maybe Number
, height :: Number , height :: Maybe Number
, orient :: String , orient :: Maybe String
, align :: String , align :: Maybe String
, padding :: Number , padding :: Maybe Number
, itemGap :: Number , itemGap :: Maybe Number
, itemWidth :: Number , itemWidth :: Maybe Number
, itemHeight :: Number , itemHeight :: Maybe Number
, formatter :: String , formatter :: Maybe String
, selectedMode :: Boolean , selectedMode :: Maybe Boolean
, inactiveColor :: Color , inactiveColor :: Maybe Color
, selected :: String -- object , selected :: Maybe String -- object
, "data" :: Array Data , "data" :: Maybe (Array Data)
} }
type Data = type Data =
{ name :: String { name :: String
, icon :: String , icon :: Maybe String
, textStyle :: {} , textStyle :: Maybe {}
} }
...@@ -139,7 +140,7 @@ type Tooltip = ...@@ -139,7 +140,7 @@ type Tooltip =
} }
type XAxis = type XAxis =
{ "data" :: Array String { "data" :: Array Data
, "type" :: String , "type" :: String
, axisTick :: AxisTick , axisTick :: AxisTick
} }
...@@ -203,10 +204,14 @@ type Rich = {} ...@@ -203,10 +204,14 @@ type Rich = {}
foreign import eChartsClass :: forall props. R.ReactClass props foreign import eChartsClass :: forall props. R.ReactClass props
foreign import eChartsClass' :: forall props. R.ReactClass Option
echarts :: forall eff. Array Props -> R.ReactElement echarts :: forall eff. Array Props -> R.ReactElement
echarts p = R.createElementDynamic eChartsClass (unsafeFromPropsArray p) [] echarts p = R.createElementDynamic eChartsClass (unsafeFromPropsArray p) []
echarts' :: forall eff. Option -> R.ReactElement
echarts' opt = R.createElementDynamic eChartsClass opt []
-- Props -- Props
loading :: Boolean -> Props loading :: Boolean -> Props
...@@ -362,6 +367,69 @@ yAxisIndex = unsafeMkProps "yAxisIndex" ...@@ -362,6 +367,69 @@ yAxisIndex = unsafeMkProps "yAxisIndex"
-- , p'' -- , p''
-- ] -- ]
legend' :: Maybe Legend
legend' = Just $
{
"type": Nothing
,show: Nothing
,zlevel: Nothing
, z : Nothing
, left : Nothing
, top : Nothing
, right : Nothing
, bottom: Nothing
, width : Nothing
, height: Nothing
, orient: Nothing
, align : Nothing
, padding : Nothing
, itemGap : Nothing
, itemWidth : Nothing
, itemHeight : Nothing
, formatter : Nothing
, selectedMode : Nothing
, inactiveColor: Nothing
, selected : Nothing
, "data" : [data1, data2, data3]
}
data1 :: Data
data1 = {name: "Map terms coverage", icon: Nothing, textStyle: Nothing}
data2 :: Data
data2 = {name: "Favorites", icon: Nothing, textStyle: Nothing}
data3 :: Data
data3 = {name: "All", icon: Nothing, textStyle: Nothing}
xAxis :: XAxis
xAxis =
{
}
opt :: Option
opt =
{
title: title'
,legend: legend'
,tooltip: tooltip'
,grid: grid'
,xAxis: xAxis'
,yAxis: yAxis'
,series: series'
,dataZoom: dataZoom'
}
where title' = Nothing
tooltip' = Nothing
grid' = Nothing
yAxis' = Nothing
series' = Nothing
dataZoom' = Nothing
histogram' :: R.ReactElement
histogram' = echarts []
histogram :: R.ReactElement histogram :: R.ReactElement
histogram = echarts histogram = echarts
[ option [ option
...@@ -481,6 +549,19 @@ sd3 = unsafeFromPropsArray ...@@ -481,6 +549,19 @@ sd3 = unsafeFromPropsArray
, data' [201, 222, 223, 777, 244, 255, 555, 879, 938, 1364, 1806, 2324] , data' [201, 222, 223, 777, 244, 255, 555, 879, 938, 1364, 1806, 2324]
] ]
dataZoom' :: Array DataZoom -> Props
dataZoom' dzs = unsafeMkProps "dataZoom" $ dzToProps <$> dzs
dzToProps :: forall props. DataZoom -> props
dzToProps dz = unsafeFromPropsArray
[ type' dz."type"
, xAxisIndex dz.xAxisIndex
, filterMode dz.filterMode
, start dz.start
, end dz.end
]
sd2 :: forall props. props sd2 :: forall props. props
sd2 = unsafeFromPropsArray sd2 = unsafeFromPropsArray
......
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