Commit 1e9c64d6 authored by Mael NICOLAS's avatar Mael NICOLAS

hiding constructor, renaming and start to implement Legend

parent 033c721e
module Charts.Color where module Charts.Color
(
ChartColor(),
chartColor
)where
import Prelude ((<<<)) import Prelude ((<<<))
import CSS (Color, toHexString) import CSS (Color, toHexString)
newtype ChartColor = ChartColor String newtype ChartColor = ChartColor String
renderChartColor :: Color -> ChartColor chartColor :: Color -> ChartColor
renderChartColor = ChartColor <<< toHexString chartColor = ChartColor <<< toHexString
...@@ -3,4 +3,3 @@ ...@@ -3,4 +3,3 @@
var ReactEcharts = require("echarts-for-react"); var ReactEcharts = require("echarts-for-react");
exports.eChartsClass = ReactEcharts.default; exports.eChartsClass = ReactEcharts.default;
exports.eChartsClass2 = ReactEcharts.default;
module Charts.ECharts where module Charts.ECharts where
import CSS (black, blue, white, yellow)
import CSS.Common (normal)
import Charts.Color (chartColor)
import Charts.Font (chartFontStyle, chartFontWeight)
import Charts.Legend (legendType, LegendType, PlainOrScroll(..))
import Charts.Position (Align(..), LeftRelativePosition(..), TopRelativePosition(..), numberPosition, percentPosition, relativePosition)
import Charts.Type (Data, DataZoom, Echarts, Legend, Option, Series, TextStyle, Title, Tooltip, XAxis, YAxis)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Prelude (($)) import Prelude (($))
import Charts.Type (Data, DataZoom, Echarts, Legend, Option, Series, TextStyle, Title, Tooltip, XAxis, YAxis)
import Charts.Color (renderChartColor)
import Charts.Font (renderChartFontStyle, renderChartFontWeight)
import Charts.Position (Align(..), LeftRelativePosition(..), TopRelativePosition(..), numberPosition, percentPosition, relativePosition)
import CSS (black, blue, white, yellow)
import CSS.Common (normal)
import React as R import React as R
import React.DOM (p) import React.DOM (p)
foreign import eChartsClass :: forall props. R.ReactClass props foreign import eChartsClass :: R.ReactClass Echarts
foreign import eChartsClass2 :: R.ReactClass Echarts
echarts' :: forall eff. Echarts -> R.ReactElement echarts :: forall eff. Echarts -> R.ReactElement
echarts' chart = R.createElementDynamic eChartsClass2 chart [] echarts chart = R.createElementDynamic eChartsClass chart []
legend' :: Legend legend' :: Legend
legend' = legend' =
{ {
"type": "plain" id: ""
,"type": legendType Plain
, show: true , show: true
, zlevel: Nothing , zlevel: 40.0
, z: Nothing , z: 40.0
, left: Nothing , left: percentPosition 40.0
, top: Nothing , top: percentPosition 40.0
, right: Nothing , right: percentPosition 40.0
, bottom: Nothing , bottom: percentPosition 40.0
, width: Nothing , width: percentPosition 40.0
, height: Nothing , height: percentPosition 40.0
, orient: Nothing , orient: Nothing
, align: Nothing , align: Nothing
, padding: Nothing , padding: Nothing
...@@ -132,12 +131,12 @@ title = ...@@ -132,12 +131,12 @@ title =
,top: relativePosition (Relative Middle) ,top: relativePosition (Relative Middle)
,right: numberPosition 60.0 ,right: numberPosition 60.0
,bottom: percentPosition 40.0 ,bottom: percentPosition 40.0
,backgroundColor: renderChartColor black ,backgroundColor: chartColor black
,borderColor: renderChartColor black ,borderColor: chartColor black
,borderWidth: 0.0 ,borderWidth: 0.0
,borderRadius: 20.0 ,borderRadius: 20.0
,shadowBlur: 0.0 ,shadowBlur: 0.0
,shadowColor: renderChartColor black ,shadowColor: chartColor black
,shadowOffsetX: 0.0 ,shadowOffsetX: 0.0
,shadowOffsetY: 0.0 ,shadowOffsetY: 0.0
} }
...@@ -145,9 +144,9 @@ title = ...@@ -145,9 +144,9 @@ title =
textStyle2 :: TextStyle textStyle2 :: TextStyle
textStyle2 = textStyle2 =
{ {
color: renderChartColor yellow color: chartColor yellow
,fontStyle: renderChartFontStyle normal ,fontStyle: chartFontStyle normal
,fontWeight: renderChartFontWeight normal ,fontWeight: chartFontWeight normal
,fontFamily: "sans-serif" ,fontFamily: "sans-serif"
,fontSize: 12 ,fontSize: 12
,align: relativePosition $ Relative RightPos ,align: relativePosition $ Relative RightPos
...@@ -155,10 +154,10 @@ textStyle2 = ...@@ -155,10 +154,10 @@ textStyle2 =
,lineHeight: percentPosition 0.0 ,lineHeight: percentPosition 0.0
,width: percentPosition 100.0 ,width: percentPosition 100.0
,height: percentPosition 100.0 ,height: percentPosition 100.0
,textBorderColor: renderChartColor blue ,textBorderColor: chartColor blue
,textBorderWidth: 5.0 ,textBorderWidth: 5.0
,textShadowColor: renderChartColor black ,textShadowColor: chartColor black
,textShadowBlur: renderChartColor black ,textShadowBlur: chartColor black
,textShadowOffsetX: 0.0 ,textShadowOffsetX: 0.0
,textShadowOffsetY: 0.0 ,textShadowOffsetY: 0.0
} }
...@@ -167,9 +166,9 @@ textStyle2 = ...@@ -167,9 +166,9 @@ textStyle2 =
textStyle :: TextStyle textStyle :: TextStyle
textStyle = textStyle =
{ {
color: renderChartColor white color: chartColor white
,fontStyle: renderChartFontStyle normal ,fontStyle: chartFontStyle normal
,fontWeight: renderChartFontWeight normal ,fontWeight: chartFontWeight normal
,fontFamily: "sans-serif" ,fontFamily: "sans-serif"
,fontSize: 12 ,fontSize: 12
,align: relativePosition $ Relative LeftPos ,align: relativePosition $ Relative LeftPos
...@@ -177,10 +176,10 @@ textStyle = ...@@ -177,10 +176,10 @@ textStyle =
,lineHeight: percentPosition 0.0 ,lineHeight: percentPosition 0.0
,width: percentPosition 100.0 ,width: percentPosition 100.0
,height: percentPosition 100.0 ,height: percentPosition 100.0
,textBorderColor: renderChartColor blue ,textBorderColor: chartColor blue
,textBorderWidth: 5.0 ,textBorderWidth: 5.0
,textShadowColor: renderChartColor black ,textShadowColor: chartColor black
,textShadowBlur: renderChartColor black ,textShadowBlur: chartColor black
,textShadowOffsetX: 0.0 ,textShadowOffsetX: 0.0
,textShadowOffsetY: 0.0 ,textShadowOffsetY: 0.0
} }
...@@ -204,7 +203,7 @@ charts = ...@@ -204,7 +203,7 @@ charts =
} }
histogram2 :: R.ReactElement histogram2 :: R.ReactElement
histogram2 = echarts' charts histogram2 = echarts charts
{- {-
histogram :: R.ReactElement histogram :: R.ReactElement
......
module Charts.Font where module Charts.Font
(
ChartFontStyle(),
chartFontStyle,
ChartFontWeight(),
chartFontWeight
) where
import CSS (FontStyle(..), FontWeight(..), Prefixed(..), Value(..)) import CSS (FontStyle(..), FontWeight(..), Prefixed(..), Value(..))
newtype ChartFontStyle = ChartFontStyle String newtype ChartFontStyle = ChartFontStyle String
renderChartFontStyle :: FontStyle -> ChartFontStyle chartFontStyle :: FontStyle -> ChartFontStyle
renderChartFontStyle (FontStyle (Value (Plain "italic"))) = ChartFontStyle "italic" chartFontStyle (FontStyle (Value (Plain "italic"))) = ChartFontStyle "italic"
renderChartFontStyle (FontStyle (Value (Plain "oblique"))) = ChartFontStyle "oblique" chartFontStyle (FontStyle (Value (Plain "oblique"))) = ChartFontStyle "oblique"
renderChartFontStyle _ = ChartFontStyle "normal" chartFontStyle _ = ChartFontStyle "normal"
newtype ChartFontWeight = ChartFontWeight String newtype ChartFontWeight = ChartFontWeight String
renderChartFontWeight :: FontWeight -> ChartFontWeight chartFontWeight :: FontWeight -> ChartFontWeight
renderChartFontWeight (FontWeight (Value (Plain "bold"))) = ChartFontWeight "bold" chartFontWeight (FontWeight (Value (Plain "bold"))) = ChartFontWeight "bold"
renderChartFontWeight (FontWeight (Value (Plain "bolder"))) = ChartFontWeight "bolder" chartFontWeight (FontWeight (Value (Plain "bolder"))) = ChartFontWeight "bolder"
renderChartFontWeight (FontWeight (Value (Plain "lighter"))) = ChartFontWeight "lighter" chartFontWeight (FontWeight (Value (Plain "lighter"))) = ChartFontWeight "lighter"
renderChartFontWeight _ = ChartFontWeight "normal" chartFontWeight _ = ChartFontWeight "normal"
module Charts.Legend
(
LegendType(),
PlainOrScroll(..),
legendType,
Orient(),
Orientation(..),
orient
) where
import Data.Generic (class Generic, gShow)
import Data.String (toLower)
import Prelude ((<<<))
newtype LegendType = LegendType String
data PlainOrScroll = Plain | Scroll
derive instance genericPlainOrScroll :: Generic PlainOrScroll
legendType :: PlainOrScroll -> LegendType
legendType = LegendType <<< toLower <<< gShow
newtype Orient = Orient String
data Orientation = Horizontal | Vertical
derive instance genericOrientation :: Generic Orientation
orient :: Orientation -> Orient
orient = Orient <<< toLower <<< gShow
module Charts.Position where module Charts.Position
(
Position(),
numberPosition,
percentPosition,
relativePosition,
Align(..),
TopRelativePosition(..),
LeftRelativePosition(..)
) where
import Prelude (class Show, show, ($), (<>)) import Prelude (class Show, show, ($), (<>))
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
......
module Charts.Type where module Charts.Type where
import Charts.Position (LeftRelativePosition, Position, TopRelativePosition)
import Charts.Font import Charts.Font
import Charts.Color (ChartColor)
import CSS (Color) import CSS (Color)
import Charts.Color (ChartColor)
import Charts.Legend (LegendType)
import Charts.Position (LeftRelativePosition, Position, TopRelativePosition)
import Data.Either (Either) import Data.Either (Either)
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Prelude (Unit, (<<<)) import Prelude (Unit, (<<<))
...@@ -89,27 +91,29 @@ type Grid = ...@@ -89,27 +91,29 @@ type Grid =
} }
type Legend = type Legend =
{"type" :: String {
, show :: Boolean id :: String
, zlevel :: Maybe Number , "type" :: LegendType
, z :: Maybe Number , show :: Boolean
, left :: Maybe Number , zlevel :: Number
, top :: Maybe Number , z :: Number
, right :: Maybe Number , left :: Position LeftRelativePosition -- default 'auto
, bottom :: Maybe Number , top :: Position TopRelativePosition
, width :: Maybe Number , right :: Position Unit
, height :: Maybe Number , bottom :: Position Unit
, width :: Position Unit
, height :: Position Unit
, orient :: Maybe String , orient :: Maybe String
, align :: Maybe String , align :: Maybe String
, padding :: Maybe Number , padding :: Maybe Number
, itemGap :: Maybe Number , itemGap :: Maybe Number
, itemWidth :: Maybe Number , itemWidth :: Maybe Number
, itemHeight :: Maybe Number , itemHeight :: Maybe Number
, formatter :: Maybe String , formatter :: Maybe String
, selectedMode :: Maybe Boolean , selectedMode :: Maybe Boolean
, inactiveColor :: Maybe Color , inactiveColor :: Maybe Color
, selected :: Maybe String -- object , selected :: Maybe String -- object
, "data" :: Maybe (Array Data) , "data" :: Maybe (Array Data)
} }
type Data = type Data =
......
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