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
609b70e3
Commit
609b70e3
authored
May 31, 2018
by
Mael NICOLAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor Data and TextStyle
parent
1e9c64d6
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
152 additions
and
86 deletions
+152
-86
Color.purs
src/Charts/Color.purs
+1
-1
ECharts.purs
src/Charts/ECharts.purs
+64
-41
Font.purs
src/Charts/Font.purs
+47
-1
Legend.purs
src/Charts/Legend.purs
+23
-5
Position.purs
src/Charts/Position.purs
+1
-0
Type.purs
src/Charts/Type.purs
+16
-38
No files found.
src/Charts/Color.purs
View file @
609b70e3
...
...
@@ -2,7 +2,7 @@ module Charts.Color
(
ChartColor(),
chartColor
)where
)
where
import Prelude ((<<<))
import CSS (Color, toHexString)
...
...
src/Charts/ECharts.purs
View file @
609b70e3
module Charts.ECharts where
import CSS (black, blue, white, yellow)
import CSS (black, blue, italic, violet, white, yellow)
import CSS.Common (normal)
import Charts.Data
import Charts.Color (chartColor)
import Charts.Font (
chartFontStyle, chartFontWeight
)
import Charts.Legend (legendType, Legend
Type, PlainOrScroll(..)
)
import Charts.Font (
IconOptions(..), Shape(..), TextStyle, chartFontStyle, chartFontWeight, icon
)
import Charts.Legend (legendType, Legend
Mode(..), PlainOrScroll(..), selectedMode, Orientation(..), orient
)
import Charts.Position (Align(..), LeftRelativePosition(..), TopRelativePosition(..), numberPosition, percentPosition, relativePosition)
import Charts.Type (Data
, DataZoom, Echarts, Legend, Option, Series, TextStyle
, Title, Tooltip, XAxis, YAxis)
import Charts.Type (Data
Zoom, Echarts, Legend, Option, Series
, Title, Tooltip, XAxis, YAxis)
import Data.Either (Either(..))
import Data.Maybe (Maybe(..))
import Prelude (($))
...
...
@@ -18,41 +20,42 @@ foreign import eChartsClass :: R.ReactClass Echarts
echarts :: forall eff. Echarts -> R.ReactElement
echarts chart = R.createElementDynamic eChartsClass chart []
legend
'
:: Legend
legend
'
=
legend :: Legend
legend =
{
id: ""
id: "
Muda
"
,"type": legendType Plain
, show: true
, zlevel:
4
0.0
, z:
40
.0
, left:
percentPosition 40.0
, top:
percentPosition 40.0
, right:
percentPosition 40.0
, bottom:
percentPosition 40.0
, width:
percentPosition 40.0
, height:
percentPosition 40.0
, orient:
Nothing
, align:
Nothing
, padding:
Nothing
, itemGap:
Nothing
, itemWidth:
Nothing
, itemHeight:
Nothing
, zlevel: 0.0
, z:
2
.0
, left:
relativePosition Auto
, top:
relativePosition Auto
, right:
relativePosition Auto
, bottom:
relativePosition Auto
, width:
relativePosition Auto
, height:
relativePosition Auto
, orient:
orient Horizontal
, align:
relativePosition Auto
, padding:
5.0
, itemGap:
10.0
, itemWidth:
25.0
, itemHeight:
14.0
, formatter: Nothing
, selectedMode:
Nothing
, inactiveColor:
Nothing
, selectedMode:
selectedMode $ Bool true
, inactiveColor:
chartColor violet
, selected: Nothing
, "data": Nothing
, textStyle: textStyle
, "data": [data1]
}
data1 :: Data
data1 = {name: "Map terms coverage", icon:
Nothing, textStyle: Nothing
}
data1 :: Data
N
data1 = {name: "Map terms coverage", icon:
icon $ Shape Circle, textStyle: textStyle'
}
data2 :: Data
data2 = {name: "Favorites", icon:
Nothing, textStyle: Nothing
}
data2 :: Data
N
data2 = {name: "Favorites", icon:
icon $ Shape Circle, textStyle: textStyle'
}
data3 :: Data
data3 = {name: "
All", icon: Nothing, textStyle: Nothing
}
data3 :: Data
N
data3 = {name: "
Test", icon: icon $ Shape Diamond, textStyle: textStyle'
}
xAxis' :: XAxis
xAxis' =
...
...
@@ -62,14 +65,14 @@ xAxis' =
, axisTick: {alignWithLabel: true}
}
xData1 :: Data
xData1 = {
name: "Jan", icon: Nothing, textStyle: Nothing
}
xData1 :: Data
V
xData1 = {
value: "Jan", textStyle: textStyle'
}
xData2 :: Data
xData2 = {
name: "Feb", icon: Nothing, textStyle: Nothing
}
xData2 :: Data
V
xData2 = {
value: "Feb", textStyle: textStyle'
}
xData3 :: Data
xData3 = {
name: "Mar", icon: Nothing, textStyle: Nothing
}
xData3 :: Data
V
xData3 = {
value: "Mar", textStyle: textStyle'
}
yData1 :: YAxis
yData1 =
...
...
@@ -101,7 +104,7 @@ opt :: Option
opt =
{
title: title
,legend:
Nothing
,legend:
legend
,tooltip: tooltip'
,grid: {containLabel: true}
,xAxis: xAxis'
...
...
@@ -113,7 +116,7 @@ opt =
title :: Title
title =
{
id: ""
id: "
Muda
"
,show: true
,text: "MudaTitre rpz les pyramides"
,link: "https://google.com"
...
...
@@ -127,8 +130,8 @@ title =
,itemGap: 0.0
,zlevel: 2.0
,z: 2.0
,left: relativePosition (Relative
Center
)
,top: relativePosition (Relative
Middle
)
,left: relativePosition (Relative
LeftPos
)
,top: relativePosition (Relative
Top
)
,right: numberPosition 60.0
,bottom: percentPosition 40.0
,backgroundColor: chartColor black
...
...
@@ -145,7 +148,7 @@ textStyle2 :: TextStyle
textStyle2 =
{
color: chartColor yellow
,fontStyle: chartFontStyle
normal
,fontStyle: chartFontStyle
italic
,fontWeight: chartFontWeight normal
,fontFamily: "sans-serif"
,fontSize: 12
...
...
@@ -162,6 +165,26 @@ textStyle2 =
,textShadowOffsetY: 0.0
}
textStyle' :: TextStyle
textStyle' =
{
color: chartColor violet
,fontStyle: chartFontStyle normal
,fontWeight: chartFontWeight normal
,fontFamily: "sans-serif"
,fontSize: 12
,align: relativePosition $ Relative LeftPos
,verticalAlign: relativePosition $ Relative Top
,lineHeight: percentPosition 0.0
,width: percentPosition 100.0
,height: percentPosition 100.0
,textBorderColor: chartColor black
,textBorderWidth: 5.0
,textShadowColor: chartColor black
,textShadowBlur: chartColor black
,textShadowOffsetX: 0.0
,textShadowOffsetY: 0.0
}
textStyle :: TextStyle
textStyle =
...
...
src/Charts/Font.purs
View file @
609b70e3
module Charts.Font
(
TextStyle,
ChartFontStyle(),
chartFontStyle,
ChartFontWeight(),
chartFontWeight
chartFontWeight,
Icon(),
ImageURL(..),
Shape(..),
IconOptions(..),
icon
) where
import CSS (FontStyle(..), FontWeight(..), Prefixed(..), Value(..))
import Charts.Color (ChartColor)
import Charts.Position (LeftRelativePosition, Position, TopRelativePosition)
import Data.Generic (class Generic, gShow)
import Data.String (toLower)
import Prelude (Unit, ($), (<<<), (<>))
type TextStyle =
{ color :: ChartColor
, fontStyle :: ChartFontStyle
, fontWeight :: ChartFontWeight
, fontFamily :: String
, fontSize :: Int
, align :: Position LeftRelativePosition
, verticalAlign :: Position TopRelativePosition
, lineHeight :: Position Unit
, width :: Position Unit
, height :: Position Unit
, textBorderColor :: ChartColor
, textBorderWidth :: Number
, textShadowColor :: ChartColor
, textShadowBlur :: ChartColor
, textShadowOffsetX :: Number
, textShadowOffsetY :: Number
}
newtype ChartFontStyle = ChartFontStyle String
...
...
@@ -15,6 +46,7 @@ chartFontStyle (FontStyle (Value (Plain "italic"))) = ChartFontStyle "italic"
chartFontStyle (FontStyle (Value (Plain "oblique"))) = ChartFontStyle "oblique"
chartFontStyle _ = ChartFontStyle "normal"
newtype ChartFontWeight = ChartFontWeight String
chartFontWeight :: FontWeight -> ChartFontWeight
...
...
@@ -22,3 +54,17 @@ chartFontWeight (FontWeight (Value (Plain "bold"))) = ChartFontWeight "bold"
chartFontWeight (FontWeight (Value (Plain "bolder"))) = ChartFontWeight "bolder"
chartFontWeight (FontWeight (Value (Plain "lighter"))) = ChartFontWeight "lighter"
chartFontWeight _ = ChartFontWeight "normal"
newtype Icon = Icon String
newtype ImageURL = ImageURL String
data Shape = Circle | Rect | RoundRect | Triangle | Diamond | Pin | Arrow
derive instance genericShape :: Generic Shape
data IconOptions = Shape Shape | Image ImageURL
icon :: IconOptions -> Icon
icon (Shape s) = Icon <<< toLower $ gShow s
icon (Image (ImageURL url)) = Icon $ "image://" <> url
src/Charts/Legend.purs
View file @
609b70e3
module Charts.Legend
(
LegendType(),
LegendType(
..
),
PlainOrScroll(..),
legendType,
Orient(),
Orientation(..),
orient
orient,
SelectedMode(),
LegendMode(..),
selectedMode
) where
import Data.Generic (class Generic, gShow)
import Data.String (toLower)
import Prelude ((<<<))
import Prelude (class Show, show, (<<<))
import Unsafe.Coerce (unsafeCoerce)
newtype LegendType = LegendType String
data PlainOrScroll = Plain | Scroll
derive instance genericPlainOrScroll :: Generic PlainOrScroll
instance showPlainOrScroll :: Show PlainOrScroll where
show (Plain) = "plain"
show (Scroll) = "scroll"
legendType :: PlainOrScroll -> LegendType
legendType = LegendType <<< toLower <<<
gS
how
legendType = LegendType <<< toLower <<<
s
how
newtype Orient = Orient String
...
...
@@ -28,3 +34,15 @@ derive instance genericOrientation :: Generic Orientation
orient :: Orientation -> Orient
orient = Orient <<< toLower <<< gShow
foreign import data SelectedMode :: Type
data LegendMode = Bool Boolean | Single | Multiple
derive instance genericLegendMode :: Generic LegendMode
selectedMode :: LegendMode -> SelectedMode
selectedMode (Bool b) = unsafeCoerce b
selectedMode (Single) = unsafeCoerce "single"
selectedMode (Multiple) = unsafeCoerce "multiple"
src/Charts/Position.purs
View file @
609b70e3
...
...
@@ -8,6 +8,7 @@ module Charts.Position
TopRelativePosition(..),
LeftRelativePosition(..)
) where
import Prelude (class Show, show, ($), (<>))
import Unsafe.Coerce (unsafeCoerce)
...
...
src/Charts/Type.purs
View file @
609b70e3
...
...
@@ -3,8 +3,10 @@ module Charts.Type where
import Charts.Font
import CSS (Color)
import Charts.Color (ChartColor)
import Charts.Legend (LegendType)
import Charts.Data
import Charts.Color (ChartColor(..))
import Charts.Font (Icon, icon, TextStyle)
import Charts.Legend (LegendType, SelectedMode, selectedMode, Orient)
import Charts.Position (LeftRelativePosition, Position, TopRelativePosition)
import Data.Either (Either)
import Data.Maybe (Maybe)
...
...
@@ -31,7 +33,7 @@ type Echarts =
type Option =
{ title :: Title
, legend ::
Maybe
Legend
, legend :: Legend
, tooltip :: Tooltip
, grid :: Grid
, xAxis :: XAxis
...
...
@@ -103,42 +105,18 @@ type Legend =
, bottom :: Position Unit
, width :: Position Unit
, height :: Position Unit
, orient ::
Maybe String
, align ::
Maybe String
, padding ::
Maybe
Number
, itemGap ::
Maybe
Number
, itemWidth ::
Maybe
Number
, itemHeight ::
Maybe
Number
, orient ::
Orient
, align ::
Position LeftRelativePosition
, padding :: Number
, itemGap :: Number
, itemWidth :: Number
, itemHeight :: Number
, formatter :: Maybe String
, selectedMode ::
Maybe Boolean
, inactiveColor ::
Maybe
Color
, selectedMode ::
SelectedMode
, inactiveColor ::
Chart
Color
, selected :: Maybe String -- object
, "data" :: Maybe (Array Data)
}
type Data =
{ name :: String
, icon :: Maybe String
, textStyle :: Maybe {}
}
type TextStyle =
{ color :: ChartColor
, fontStyle :: ChartFontStyle
, fontWeight :: ChartFontWeight
, fontFamily :: String
, fontSize :: Int
, align :: Position LeftRelativePosition
, verticalAlign :: Position TopRelativePosition
, lineHeight :: Position Unit
, width :: Position Unit
, height :: Position Unit
, textBorderColor :: ChartColor
, textBorderWidth :: Number
, textShadowColor :: ChartColor
, textShadowBlur :: ChartColor
, textShadowOffsetX :: Number
, textShadowOffsetY :: Number
, textStyle :: TextStyle
, "data" :: Array DataN
}
type Tooltip =
...
...
@@ -147,7 +125,7 @@ type Tooltip =
}
type XAxis =
{ "data" :: Array Data
{ "data" :: Array Data
V
, "type" :: String
, axisTick :: AxisTick
}
...
...
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