Commit 083cbffc authored by Alexandre Delanoë's avatar Alexandre Delanoë

[Charts] Fix xAxis labels.

parent 0e975a01
...@@ -11,10 +11,10 @@ type DataLegend = ...@@ -11,10 +11,10 @@ type DataLegend =
, textStyle :: TextStyle , textStyle :: TextStyle
} }
type DataAxis = type DataAxis = Array String
{ value :: String {- value :: String
, textStyle :: TextStyle , textStyle :: TextStyle
} -}
type RequiredData v o = type RequiredData v o =
{ value :: v { value :: v
......
...@@ -2,6 +2,7 @@ module Gargantext.Components.Charts.Options.ECharts where ...@@ -2,6 +2,7 @@ module Gargantext.Components.Charts.Options.ECharts where
import Prelude import Prelude
import Data.String (take)
import CSS (italic) import CSS (italic)
import CSS.Common (normal) import CSS.Common (normal)
import Data.Array (length) import Data.Array (length)
...@@ -128,14 +129,12 @@ yAxisVoid = yAxis ...@@ -128,14 +129,12 @@ yAxisVoid = yAxis
xAxis' :: Array String -> XAxis xAxis' :: Array String -> XAxis
xAxis' [] = unsafeCoerce {show:false} xAxis' [] = unsafeCoerce {show:false}
xAxis' xs = xAxis xAxis' xs = xAxis
{ "data": xData xs { "data": xs
, "type": "category" , "type": "category"
, axisTick: {alignWithLabel: true} , axisTick: {alignWithLabel: true}
, show: true , show: true
, axisLabel: {formatter: "{value}"}
} }
where
xData :: Array String -> Array DataAxis
xData = map (\x -> {value : x, textStyle : textStyle})
-- TODO try to use Optional -- TODO try to use Optional
yAxis' :: { position :: String yAxis' :: { position :: String
...@@ -258,10 +257,10 @@ textStyle = ...@@ -258,10 +257,10 @@ textStyle =
, fontStyle: chartFontStyle normal , fontStyle: chartFontStyle normal
, fontWeight: chartFontWeight normal , fontWeight: chartFontWeight normal
, fontFamily: "sans-serif" , fontFamily: "sans-serif"
, fontSize: 15 , fontSize: 10
, align: relativePosition $ Relative LeftPos , align: relativePosition $ Relative LeftPos
, verticalAlign: relativePosition $ Relative Top , verticalAlign: relativePosition $ Relative Top
, lineHeight: percentPosition 0.0 , lineHeight: percentPosition 10.0
, width: percentPosition 100.0 , width: percentPosition 100.0
, height: percentPosition 100.0 , height: percentPosition 100.0
, textBorderColor: black , textBorderColor: black
......
...@@ -128,7 +128,7 @@ type AxisTick = ...@@ -128,7 +128,7 @@ type AxisTick =
data XAxis data XAxis
type XAxisOptional = type XAxisOptional =
( "data" :: Array DataAxis ( "data" :: Array String -- DataAxis
, "type" :: String , "type" :: String
, axisTick :: AxisTick , axisTick :: AxisTick
, name :: String , name :: String
......
module Gargantext.Pages.Corpus.Chart.Pie where module Gargantext.Pages.Corpus.Chart.Pie where
import Data.Array (foldl, zip) import Data.String (take, joinWith, Pattern(..), split, length)
import Data.Array (foldl, zip, filter)
import Data.Array as A
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Data.Map as Map import Data.Map as Map
import Data.Int (toNumber) import Data.Int (toNumber)
...@@ -61,7 +63,7 @@ chartOptions :: HistoMetrics -> Options ...@@ -61,7 +63,7 @@ chartOptions :: HistoMetrics -> Options
chartOptions (HistoMetrics { dates: dates', count: count'}) = Options chartOptions (HistoMetrics { dates: dates', count: count'}) = Options
{ mainTitle : "Bar" { mainTitle : "Bar"
, subTitle : "Count of GraphTerm" , subTitle : "Count of GraphTerm"
, xAxis : xAxis' dates' , xAxis : xAxis' $ map (\t -> joinWith " " $ map (take 3) $ A.take 3 $ filter (\s -> length s > 3) $ split (Pattern " ") t) dates'
, yAxis : yAxis' { position: "left", show: true, min:0} , yAxis : yAxis' { position: "left", show: true, min:0}
, series : [seriesBarD1 {name: "Number of publication / year"} $ map (\n -> dataSerie {name: "", itemStyle: itemStyle {color:blue}, value: n }) count'] , series : [seriesBarD1 {name: "Number of publication / year"} $ map (\n -> dataSerie {name: "", itemStyle: itemStyle {color:blue}, value: n }) count']
, addZoom : false , addZoom : false
......
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