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

[Charts] Fix xAxis labels.

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