Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
033c721e
Commit
033c721e
authored
May 28, 2018
by
Mael NICOLAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor, separe in files
parent
ce9e14d5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
75 deletions
+95
-75
Color.purs
src/Charts/Color.purs
+9
-0
ECharts.purs
src/Charts/ECharts.purs
+25
-22
Font.purs
src/Charts/Font.purs
+18
-0
Position.purs
src/Charts/Position.purs
+36
-0
Type.purs
src/Charts/Type.purs
+7
-53
No files found.
src/Charts/Color.purs
0 → 100644
View file @
033c721e
module Charts.Color where
import Prelude ((<<<))
import CSS (Color, toHexString)
newtype ChartColor = ChartColor String
renderChartColor :: Color -> ChartColor
renderChartColor = ChartColor <<< toHexString
src/Charts/ECharts.purs
View file @
033c721e
module Charts.ECharts where
module Charts.ECharts where
import Charts.Types
import Data.Either (Either(..))
import Data.Either
import CSS (Color, black, blue, blueviolet, bolder, borderColor, fontWeight, green, italic, toHexString, turquoise, violet, white, yellow, yellowgreen)
import CSS.Common (class Bottom, normal)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Prelude (show, ($))
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)
import React.DOM.Props (Props)
foreign import eChartsClass :: forall props. R.ReactClass props
foreign import eChartsClass :: forall props. R.ReactClass props
foreign import eChartsClass2 :: R.ReactClass Echarts
foreign import eChartsClass2 :: R.ReactClass Echarts
...
@@ -125,14 +128,14 @@ title =
...
@@ -125,14 +128,14 @@ title =
,itemGap: 0.0
,itemGap: 0.0
,zlevel: 2.0
,zlevel: 2.0
,z: 2.0
,z: 2.0
,left: re
nderRe
lativePosition (Relative Center)
,left: relativePosition (Relative Center)
,top: re
nderRe
lativePosition (Relative Middle)
,top: relativePosition (Relative Middle)
,right:
renderNumber
60.0
,right:
numberPosition
60.0
,bottom:
renderPercentage
40.0
,bottom:
percentPosition
40.0
,backgroundColor: renderChartColor black
,backgroundColor: renderChartColor black
,borderColor: renderChartColor black
,borderColor: renderChartColor black
,borderWidth: 0.0
,borderWidth: 0.0
,borderRadius:
Left
20.0
,borderRadius: 20.0
,shadowBlur: 0.0
,shadowBlur: 0.0
,shadowColor: renderChartColor black
,shadowColor: renderChartColor black
,shadowOffsetX: 0.0
,shadowOffsetX: 0.0
...
@@ -147,11 +150,11 @@ textStyle2 =
...
@@ -147,11 +150,11 @@ textStyle2 =
,fontWeight: renderChartFontWeight normal
,fontWeight: renderChartFontWeight normal
,fontFamily: "sans-serif"
,fontFamily: "sans-serif"
,fontSize: 12
,fontSize: 12
,align: re
nderRe
lativePosition $ Relative RightPos
,align: relativePosition $ Relative RightPos
,verticalAlign: re
nderRe
lativePosition $ Relative Bottom
,verticalAlign: relativePosition $ Relative Bottom
,lineHeight:
renderPercentage
0.0
,lineHeight:
percentPosition
0.0
,width:
renderPercentage
100.0
,width:
percentPosition
100.0
,height:
renderPercentage
100.0
,height:
percentPosition
100.0
,textBorderColor: renderChartColor blue
,textBorderColor: renderChartColor blue
,textBorderWidth: 5.0
,textBorderWidth: 5.0
,textShadowColor: renderChartColor black
,textShadowColor: renderChartColor black
...
@@ -169,11 +172,11 @@ textStyle =
...
@@ -169,11 +172,11 @@ textStyle =
,fontWeight: renderChartFontWeight normal
,fontWeight: renderChartFontWeight normal
,fontFamily: "sans-serif"
,fontFamily: "sans-serif"
,fontSize: 12
,fontSize: 12
,align: re
nderRe
lativePosition $ Relative LeftPos
,align: relativePosition $ Relative LeftPos
,verticalAlign: re
nderRe
lativePosition $ Relative Top
,verticalAlign: relativePosition $ Relative Top
,lineHeight:
renderPercentage
0.0
,lineHeight:
percentPosition
0.0
,width:
renderPercentage
100.0
,width:
percentPosition
100.0
,height:
renderPercentage
100.0
,height:
percentPosition
100.0
,textBorderColor: renderChartColor blue
,textBorderColor: renderChartColor blue
,textBorderWidth: 5.0
,textBorderWidth: 5.0
,textShadowColor: renderChartColor black
,textShadowColor: renderChartColor black
...
...
src/Charts/Font.purs
0 → 100644
View file @
033c721e
module Charts.Font where
import CSS (FontStyle(..), FontWeight(..), Prefixed(..), Value(..))
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
renderChartFontWeight :: FontWeight -> ChartFontWeight
renderChartFontWeight (FontWeight (Value (Plain "bold"))) = ChartFontWeight "bold"
renderChartFontWeight (FontWeight (Value (Plain "bolder"))) = ChartFontWeight "bolder"
renderChartFontWeight (FontWeight (Value (Plain "lighter"))) = ChartFontWeight "lighter"
renderChartFontWeight _ = ChartFontWeight "normal"
src/Charts/Position.purs
0 → 100644
View file @
033c721e
module Charts.Position where
import Prelude (class Show, show, ($), (<>))
import Unsafe.Coerce (unsafeCoerce)
-- | The type `Position` is made to render a css position.
-- | It should be either a `Number`, a `"Number%"` or a `Position` type (`TopRelativePosition` for exemple)
-- | To construct such a type you will have to use one of the smart constructor
foreign import data Position :: Type -> Type
-- | Smart constructor to build a JS Number
numberPosition :: forall r. Number -> Position r
numberPosition = unsafeCoerce
-- | Smart constructor to build a JS Percent
percentPosition :: forall r. Number -> Position r
percentPosition n = unsafeCoerce $ (show n) <> "%"
-- | Smart constructor to build a JS String giving position's detail ("top", "left", ...)
relativePosition :: forall a. Show a => Align a -> Position a
relativePosition (Auto) = unsafeCoerce "auto"
relativePosition (Relative r) = unsafeCoerce $ show r
data Align p = Auto | Relative p
data TopRelativePosition = Top | Middle | Bottom
instance showTopRelativePosition :: Show TopRelativePosition
where show (Top) = "top"
show (Middle) = "middle"
show (Bottom) = "bottom"
data LeftRelativePosition = LeftPos | Center | RightPos
instance showLeftRelativePosition :: Show LeftRelativePosition
where show (LeftPos) = "left"
show (Center) = "center"
show (RightPos) = "right"
src/Charts/Type
s
.purs
→
src/Charts/Type.purs
View file @
033c721e
module Charts.Type
s
where
module Charts.Type where
import Unsafe.Coerce
import Charts.Position (LeftRelativePosition, Position, TopRelativePosition)
import Charts.Font
import CSS (Color, FontStyle(..), FontWeight(..), Prefixed(..), Value(..), toHexString)
import Charts.Color (ChartColor)
import CSS (Color)
import Data.Either (Either)
import Data.Either (Either)
import Data.Maybe (Maybe)
import Data.Maybe (Maybe)
import Prelude ((<>), class Show, show, ($), Unit, (<<<))
import Prelude (Unit, (<<<))
type NumberOrArray = Either Number (Array Number)
data TopRelativePosition = Top | Middle | Bottom
instance showTopRelativePosition :: Show TopRelativePosition
where show (Top) = "top"
show (Middle) = "middle"
show (Bottom) = "bottom"
data LeftRelativePosition = LeftPos | Center | RightPos
instance showLeftRelativePosition :: Show LeftRelativePosition
where show (LeftPos) = "left"
show (Center) = "center"
show (RightPos) = "right"
data Align p = Auto | Relative p
newtype ChartAlign = ChartAlign String
newtype ChartAlign = ChartAlign 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
renderChartFontWeight :: FontWeight -> ChartFontWeight
renderChartFontWeight (FontWeight (Value (Plain "bold"))) = ChartFontWeight "bold"
renderChartFontWeight (FontWeight (Value (Plain "bolder"))) = ChartFontWeight "bolder"
renderChartFontWeight (FontWeight (Value (Plain "lighter"))) = ChartFontWeight "lighter"
renderChartFontWeight _ = ChartFontWeight "normal"
foreign import data Position :: Type -> Type
renderNumber :: forall r. Number -> Position r
renderNumber = unsafeCoerce
renderPercentage :: forall r. Number -> Position r
renderPercentage n = unsafeCoerce $ (show n) <> "%"
renderRelativePosition :: forall a. Show a => Align a -> Position a
renderRelativePosition (Auto) = unsafeCoerce "auto"
renderRelativePosition (Relative r) = unsafeCoerce $ show r
type Echarts =
type Echarts =
{ className :: Maybe String,
{ className :: Maybe String,
style :: Maybe String, -- objealect-black-altdarkmincnaquadahherry-blossomect,
style :: Maybe String, -- objealect-black-altdarkmincnaquadahherry-blossomect,
...
@@ -107,7 +61,7 @@ type Title =
...
@@ -107,7 +61,7 @@ type Title =
, backgroundColor :: ChartColor -- default 'transparent''
, backgroundColor :: ChartColor -- default 'transparent''
, borderColor :: ChartColor -- default '#ccc'
, borderColor :: ChartColor -- default '#ccc'
, borderWidth :: Number -- default '1'
, borderWidth :: Number -- default '1'
, borderRadius :: Number
OrArray
-- default 0; data NumberOrArray = Number | Array Number
, borderRadius :: Number -- default 0; data NumberOrArray = Number | Array Number
, shadowBlur :: Number
, shadowBlur :: Number
, shadowColor :: ChartColor
, shadowColor :: ChartColor
, shadowOffsetX :: Number
, shadowOffsetX :: Number
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment