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
...
@@ -2,7 +2,7 @@ module Charts.Color
(
(
ChartColor(),
ChartColor(),
chartColor
chartColor
)where
)
where
import Prelude ((<<<))
import Prelude ((<<<))
import CSS (Color, toHexString)
import CSS (Color, toHexString)
...
...
src/Charts/ECharts.purs
View file @
609b70e3
module Charts.ECharts where
module Charts.ECharts where
import CSS (black, blue, white, yellow)
import CSS (black, blue, italic, violet, white, yellow)
import CSS.Common (normal)
import CSS.Common (normal)
import Charts.Data
import Charts.Color (chartColor)
import Charts.Color (chartColor)
import Charts.Font (
chartFontStyle, chartFontWeight
)
import Charts.Font (
IconOptions(..), Shape(..), TextStyle, chartFontStyle, chartFontWeight, icon
)
import Charts.Legend (legendType, Legend
Type, PlainOrScroll(..)
)
import Charts.Legend (legendType, Legend
Mode(..), PlainOrScroll(..), selectedMode, Orientation(..), orient
)
import Charts.Position (Align(..), LeftRelativePosition(..), TopRelativePosition(..), numberPosition, percentPosition, relativePosition)
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.Either (Either(..))
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Prelude (($))
import Prelude (($))
...
@@ -18,41 +20,42 @@ foreign import eChartsClass :: R.ReactClass Echarts
...
@@ -18,41 +20,42 @@ foreign import eChartsClass :: R.ReactClass Echarts
echarts :: forall eff. Echarts -> R.ReactElement
echarts :: forall eff. Echarts -> R.ReactElement
echarts chart = R.createElementDynamic eChartsClass chart []
echarts chart = R.createElementDynamic eChartsClass chart []
legend
'
:: Legend
legend :: Legend
legend
'
=
legend =
{
{
id: ""
id: "
Muda
"
,"type": legendType Plain
,"type": legendType Plain
, show: true
, show: true
, zlevel:
4
0.0
, zlevel: 0.0
, z:
40
.0
, z:
2
.0
, left:
percentPosition 40.0
, left:
relativePosition Auto
, top:
percentPosition 40.0
, top:
relativePosition Auto
, right:
percentPosition 40.0
, right:
relativePosition Auto
, bottom:
percentPosition 40.0
, bottom:
relativePosition Auto
, width:
percentPosition 40.0
, width:
relativePosition Auto
, height:
percentPosition 40.0
, height:
relativePosition Auto
, orient:
Nothing
, orient:
orient Horizontal
, align:
Nothing
, align:
relativePosition Auto
, padding:
Nothing
, padding:
5.0
, itemGap:
Nothing
, itemGap:
10.0
, itemWidth:
Nothing
, itemWidth:
25.0
, itemHeight:
Nothing
, itemHeight:
14.0
, formatter: Nothing
, formatter: Nothing
, selectedMode:
Nothing
, selectedMode:
selectedMode $ Bool true
, inactiveColor:
Nothing
, inactiveColor:
chartColor violet
, selected: Nothing
, selected: Nothing
, "data": Nothing
, textStyle: textStyle
, "data": [data1]
}
}
data1 :: Data
data1 :: Data
N
data1 = {name: "Map terms coverage", icon:
Nothing, textStyle: Nothing
}
data1 = {name: "Map terms coverage", icon:
icon $ Shape Circle, textStyle: textStyle'
}
data2 :: Data
data2 :: Data
N
data2 = {name: "Favorites", icon:
Nothing, textStyle: Nothing
}
data2 = {name: "Favorites", icon:
icon $ Shape Circle, textStyle: textStyle'
}
data3 :: Data
data3 :: Data
N
data3 = {name: "
All", icon: Nothing, textStyle: Nothing
}
data3 = {name: "
Test", icon: icon $ Shape Diamond, textStyle: textStyle'
}
xAxis' :: XAxis
xAxis' :: XAxis
xAxis' =
xAxis' =
...
@@ -62,14 +65,14 @@ xAxis' =
...
@@ -62,14 +65,14 @@ xAxis' =
, axisTick: {alignWithLabel: true}
, axisTick: {alignWithLabel: true}
}
}
xData1 :: Data
xData1 :: Data
V
xData1 = {
name: "Jan", icon: Nothing, textStyle: Nothing
}
xData1 = {
value: "Jan", textStyle: textStyle'
}
xData2 :: Data
xData2 :: Data
V
xData2 = {
name: "Feb", icon: Nothing, textStyle: Nothing
}
xData2 = {
value: "Feb", textStyle: textStyle'
}
xData3 :: Data
xData3 :: Data
V
xData3 = {
name: "Mar", icon: Nothing, textStyle: Nothing
}
xData3 = {
value: "Mar", textStyle: textStyle'
}
yData1 :: YAxis
yData1 :: YAxis
yData1 =
yData1 =
...
@@ -101,7 +104,7 @@ opt :: Option
...
@@ -101,7 +104,7 @@ opt :: Option
opt =
opt =
{
{
title: title
title: title
,legend:
Nothing
,legend:
legend
,tooltip: tooltip'
,tooltip: tooltip'
,grid: {containLabel: true}
,grid: {containLabel: true}
,xAxis: xAxis'
,xAxis: xAxis'
...
@@ -113,7 +116,7 @@ opt =
...
@@ -113,7 +116,7 @@ opt =
title :: Title
title :: Title
title =
title =
{
{
id: ""
id: "
Muda
"
,show: true
,show: true
,text: "MudaTitre rpz les pyramides"
,text: "MudaTitre rpz les pyramides"
,link: "https://google.com"
,link: "https://google.com"
...
@@ -127,8 +130,8 @@ title =
...
@@ -127,8 +130,8 @@ title =
,itemGap: 0.0
,itemGap: 0.0
,zlevel: 2.0
,zlevel: 2.0
,z: 2.0
,z: 2.0
,left: relativePosition (Relative
Center
)
,left: relativePosition (Relative
LeftPos
)
,top: relativePosition (Relative
Middle
)
,top: relativePosition (Relative
Top
)
,right: numberPosition 60.0
,right: numberPosition 60.0
,bottom: percentPosition 40.0
,bottom: percentPosition 40.0
,backgroundColor: chartColor black
,backgroundColor: chartColor black
...
@@ -145,7 +148,7 @@ textStyle2 :: TextStyle
...
@@ -145,7 +148,7 @@ textStyle2 :: TextStyle
textStyle2 =
textStyle2 =
{
{
color: chartColor yellow
color: chartColor yellow
,fontStyle: chartFontStyle
normal
,fontStyle: chartFontStyle
italic
,fontWeight: chartFontWeight normal
,fontWeight: chartFontWeight normal
,fontFamily: "sans-serif"
,fontFamily: "sans-serif"
,fontSize: 12
,fontSize: 12
...
@@ -162,6 +165,26 @@ textStyle2 =
...
@@ -162,6 +165,26 @@ textStyle2 =
,textShadowOffsetY: 0.0
,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 :: TextStyle
textStyle =
textStyle =
...
...
src/Charts/Font.purs
View file @
609b70e3
module Charts.Font
module Charts.Font
(
(
TextStyle,
ChartFontStyle(),
ChartFontStyle(),
chartFontStyle,
chartFontStyle,
ChartFontWeight(),
ChartFontWeight(),
chartFontWeight
chartFontWeight,
Icon(),
ImageURL(..),
Shape(..),
IconOptions(..),
icon
) where
) where
import CSS (FontStyle(..), FontWeight(..), Prefixed(..), Value(..))
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
newtype ChartFontStyle = ChartFontStyle String
...
@@ -15,6 +46,7 @@ chartFontStyle (FontStyle (Value (Plain "italic"))) = ChartFontStyle "italic"
...
@@ -15,6 +46,7 @@ chartFontStyle (FontStyle (Value (Plain "italic"))) = ChartFontStyle "italic"
chartFontStyle (FontStyle (Value (Plain "oblique"))) = ChartFontStyle "oblique"
chartFontStyle (FontStyle (Value (Plain "oblique"))) = ChartFontStyle "oblique"
chartFontStyle _ = ChartFontStyle "normal"
chartFontStyle _ = ChartFontStyle "normal"
newtype ChartFontWeight = ChartFontWeight String
newtype ChartFontWeight = ChartFontWeight String
chartFontWeight :: FontWeight -> ChartFontWeight
chartFontWeight :: FontWeight -> ChartFontWeight
...
@@ -22,3 +54,17 @@ chartFontWeight (FontWeight (Value (Plain "bold"))) = ChartFontWeight "bold"
...
@@ -22,3 +54,17 @@ chartFontWeight (FontWeight (Value (Plain "bold"))) = ChartFontWeight "bold"
chartFontWeight (FontWeight (Value (Plain "bolder"))) = ChartFontWeight "bolder"
chartFontWeight (FontWeight (Value (Plain "bolder"))) = ChartFontWeight "bolder"
chartFontWeight (FontWeight (Value (Plain "lighter"))) = ChartFontWeight "lighter"
chartFontWeight (FontWeight (Value (Plain "lighter"))) = ChartFontWeight "lighter"
chartFontWeight _ = ChartFontWeight "normal"
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
module Charts.Legend
(
(
LegendType(),
LegendType(
..
),
PlainOrScroll(..),
PlainOrScroll(..),
legendType,
legendType,
Orient(),
Orient(),
Orientation(..),
Orientation(..),
orient
orient,
SelectedMode(),
LegendMode(..),
selectedMode
) where
) where
import Data.Generic (class Generic, gShow)
import Data.Generic (class Generic, gShow)
import Data.String (toLower)
import Data.String (toLower)
import Prelude ((<<<))
import Prelude (class Show, show, (<<<))
import Unsafe.Coerce (unsafeCoerce)
newtype LegendType = LegendType String
newtype LegendType = LegendType String
data PlainOrScroll = Plain | Scroll
data PlainOrScroll = Plain | Scroll
derive instance genericPlainOrScroll :: Generic PlainOrScroll
instance showPlainOrScroll :: Show PlainOrScroll where
show (Plain) = "plain"
show (Scroll) = "scroll"
legendType :: PlainOrScroll -> LegendType
legendType :: PlainOrScroll -> LegendType
legendType = LegendType <<< toLower <<<
gS
how
legendType = LegendType <<< toLower <<<
s
how
newtype Orient = Orient String
newtype Orient = Orient String
...
@@ -28,3 +34,15 @@ derive instance genericOrientation :: Generic Orientation
...
@@ -28,3 +34,15 @@ derive instance genericOrientation :: Generic Orientation
orient :: Orientation -> Orient
orient :: Orientation -> Orient
orient = Orient <<< toLower <<< gShow
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
...
@@ -8,6 +8,7 @@ module Charts.Position
TopRelativePosition(..),
TopRelativePosition(..),
LeftRelativePosition(..)
LeftRelativePosition(..)
) where
) where
import Prelude (class Show, show, ($), (<>))
import Prelude (class Show, show, ($), (<>))
import Unsafe.Coerce (unsafeCoerce)
import Unsafe.Coerce (unsafeCoerce)
...
...
src/Charts/Type.purs
View file @
609b70e3
...
@@ -3,8 +3,10 @@ module Charts.Type where
...
@@ -3,8 +3,10 @@ module Charts.Type where
import Charts.Font
import Charts.Font
import CSS (Color)
import CSS (Color)
import Charts.Color (ChartColor)
import Charts.Data
import Charts.Legend (LegendType)
import Charts.Color (ChartColor(..))
import Charts.Font (Icon, icon, TextStyle)
import Charts.Legend (LegendType, SelectedMode, selectedMode, Orient)
import Charts.Position (LeftRelativePosition, Position, TopRelativePosition)
import Charts.Position (LeftRelativePosition, Position, TopRelativePosition)
import Data.Either (Either)
import Data.Either (Either)
import Data.Maybe (Maybe)
import Data.Maybe (Maybe)
...
@@ -31,7 +33,7 @@ type Echarts =
...
@@ -31,7 +33,7 @@ type Echarts =
type Option =
type Option =
{ title :: Title
{ title :: Title
, legend ::
Maybe
Legend
, legend :: Legend
, tooltip :: Tooltip
, tooltip :: Tooltip
, grid :: Grid
, grid :: Grid
, xAxis :: XAxis
, xAxis :: XAxis
...
@@ -103,42 +105,18 @@ type Legend =
...
@@ -103,42 +105,18 @@ type Legend =
, bottom :: Position Unit
, bottom :: Position Unit
, width :: Position Unit
, width :: Position Unit
, height :: Position Unit
, height :: Position Unit
, orient ::
Maybe String
, orient ::
Orient
, align ::
Maybe String
, align ::
Position LeftRelativePosition
, padding ::
Maybe
Number
, padding :: Number
, itemGap ::
Maybe
Number
, itemGap :: Number
, itemWidth ::
Maybe
Number
, itemWidth :: Number
, itemHeight ::
Maybe
Number
, itemHeight :: Number
, formatter :: Maybe String
, formatter :: Maybe String
, selectedMode ::
Maybe Boolean
, selectedMode ::
SelectedMode
, inactiveColor ::
Maybe
Color
, inactiveColor ::
Chart
Color
, selected :: Maybe String -- object
, selected :: Maybe String -- object
, "data" :: Maybe (Array Data)
, textStyle :: TextStyle
}
, "data" :: Array DataN
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
}
}
type Tooltip =
type Tooltip =
...
@@ -147,7 +125,7 @@ type Tooltip =
...
@@ -147,7 +125,7 @@ type Tooltip =
}
}
type XAxis =
type XAxis =
{ "data" :: Array Data
{ "data" :: Array Data
V
, "type" :: String
, "type" :: String
, axisTick :: AxisTick
, 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