...
 
Commits (4)
......@@ -11737,6 +11737,11 @@
"performance-now": "^2.1.0"
}
},
"ramda": {
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.26.1.tgz",
"integrity": "sha512-hLWjpy7EnsDBb0p+Z3B7rPi3GDeRG5ZtiI33kJhTt+ORCd38AbAIjB/9zRIUoeTbE/AVX5ZkU7m6bznsvrf8eQ=="
},
"randomatic": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz",
......
......@@ -146,7 +146,7 @@ type Msg
setRoute : Maybe Route -> Model -> ( Model, Cmd Msg )
setRoute route ({ apiBaseUrl, pageState } as model) =
setRoute route ({ apiBaseUrl, cartSeriesTuples, pageState } as model) =
let
transition toMsg task =
( { model | pageState = TransitioningFrom (getPage pageState) }
......@@ -176,7 +176,7 @@ setRoute route ({ apiBaseUrl, pageState } as model) =
transition SeriesLoaded (Series.init apiBaseUrl ( providerCode, datasetCode, seriesCode ))
Just Route.Cart ->
transition CartLoaded (Cart.init apiBaseUrl)
transition CartLoaded (Cart.init apiBaseUrl cartSeriesTuples)
Just Route.LastUpdates ->
transition LastUpdatesLoaded (LastUpdates.init apiBaseUrl)
......@@ -295,7 +295,9 @@ updatePage page msg ({ apiBaseUrl } as model) =
( Outside infoForElm, _ ) ->
case infoForElm of
CartChanged seriesTuples ->
( { model | cartSeriesTuples = seriesTuples }, Cmd.none )
( { model | cartSeriesTuples = seriesTuples }
, Task.attempt CartLoaded (Cart.init apiBaseUrl seriesTuples)
)
CartError err ->
( { model | cartSeriesTuples = Set.empty }
......
This diff is collapsed.
......@@ -562,87 +562,81 @@ viewSeriesListItem apiBaseUrl seriesEndpointLimit displayedGraphSeriesCodes seri
viewSeriesTable : ProviderCode -> Dataset -> List DimensionCode -> List Series -> Html msg
viewSeriesTable providerCode dataset dimensionsCodesOrder seriesList =
let
periods =
seriesList
|> List.foldl
(\series acc ->
Set.fromList series.period
|> Set.union acc
)
Set.empty
|> Set.toList
|> List.sort
in
div [ class "table-scroll" ]
[ table [ class "table table-striped table-hover table-sm" ]
[ thead []
[ tr [] <|
[ th []
[ text "Series code" ]
div [ class "table-scroll" ]
[ table [ class "table table-striped table-hover table-sm" ] <|
case List.head seriesList of
Nothing ->
[]
Just firstSeries ->
[ thead []
[ tr [] <|
[ th []
[ text "Series code" ]
]
++ List.indexedMap
(\index dimensionCode ->
th
[ classList [ ( "border-left-secondary", index == 0 ) ]
, title
(Dict.get dimensionCode dataset.dimensionsLabels
|> Maybe.withDefault ""
)
]
[ text dimensionCode ]
)
dimensionsCodesOrder
++ List.indexedMap
(\index period ->
th
[ class "text-nowrap"
, classList [ ( "border-left-secondary", index == 0 ) ]
]
[ text period ]
)
firstSeries.period
]
++ List.indexedMap
(\index dimensionCode ->
th
[ classList [ ( "border-left-secondary", index == 0 ) ]
, title
(Dict.get dimensionCode dataset.dimensionsLabels
|> Maybe.withDefault ""
)
]
[ text dimensionCode ]
)
dimensionsCodesOrder
++ List.indexedMap
(\index period ->
th
[ class "text-nowrap"
, classList [ ( "border-left-secondary", index == 0 ) ]
]
[ text period ]
)
periods
]
, tbody [] <|
List.map
(\{ code, name, value, dimensions } ->
tr [] <|
[ th []
[ a
[ Route.href <| Route.Series providerCode dataset.code code
, title name
, class "text-nowrap"
]
[ text code ]
]
]
++ List.indexedMap
(\index dimensionCode ->
let
dimensionValueCode =
Dict.get dimensionCode dimensions
in
td
[ classList [ ( "border-left-secondary", index == 0 ) ]
, title
(dimensionValueCode
|> Maybe.andThen (getDimensionValueLabel dataset.dimensionsValuesLabels dimensionCode)
|> Maybe.withDefault ""
)
++ [ tbody [] <|
List.map
(\{ code, name, value, dimensions } ->
tr [] <|
[ th []
[ a
[ Route.href <| Route.Series providerCode dataset.code code
, title name
, class "text-nowrap"
]
[ text <| Maybe.withDefault "?" dimensionValueCode ]
)
dimensionsCodesOrder
++ List.indexedMap
(\index value ->
td [ classList [ ( "border-left-secondary", index == 0 ) ] ]
[ text <| formatObservationValue value ]
)
value
)
seriesList
]
]
[ text code ]
]
]
++ List.indexedMap
(\index dimensionCode ->
let
dimensionValueCode =
Dict.get dimensionCode dimensions
in
td
[ classList [ ( "border-left-secondary", index == 0 ) ]
, title
(dimensionValueCode
|> Maybe.andThen (getDimensionValueLabel dataset.dimensionsValuesLabels dimensionCode)
|> Maybe.withDefault ""
)
]
[ text <| Maybe.withDefault "?" dimensionValueCode ]
)
dimensionsCodesOrder
++ List.indexedMap
(\index value ->
td [ classList [ ( "border-left-secondary", index == 0 ) ] ]
[ text <| formatObservationValue value ]
)
value
)
seriesList
]
]
viewSeriesTables : ProviderCode -> Dataset -> List DimensionCode -> List Series -> List (Html msg)
......
......@@ -72,7 +72,12 @@ seriesByIdsUrl apiBaseUrl seriesIds apiOutputFormat =
)
, ( "observations", "1" )
, ( "format", formatApiOutputFormat apiOutputFormat )
, ( "align_periods", "1" )
, ( "align_periods"
, if List.length seriesIds > 1 then
"1"
else
"0"
)
]
......
......@@ -4,6 +4,7 @@ require("../elm/Stylesheets.elm")
var Plotly = require("./custom-plotly")
var R = require("ramda")
var copy = require("clipboard-copy")
var config = require("config") // Defined by webpack resolve.alias key, and is different in dev and prod environments.
......@@ -92,24 +93,24 @@ function buildLineTrace(series, color) {
if (series.value.length === 0) {
return null
}
var x = []
var y = []
for (var index = 0; index < series.value.length; index++) {
x.push(
series.period_start_day && series.period_start_day.length ? series.period_start_day[index] : series.period[index]
)
y.push(series.value[index])
}
var nonAvailableValues = y.filter(function(item) {
return item === "NA"
var nonAvailableValues = series.value.filter(function(value) {
return value === "NA"
})
if (x.length === nonAvailableValues.length) {
if (series.value.length === 0 || series.value.length === nonAvailableValues.length) {
return null
}
const [x, y] = R.pipe(
R.dropWhile(x => x[1] === "NA"),
R.dropLastWhile(x => x[1] === "NA"),
R.transpose,
([x, y]) => [x, y.map(value => (value === "NA" ? null : value))]
)(R.zip(series.period_start_day || series.period, series.value))
return {
type: "scattergl",
x: x,
y: y,
x,
y,
name: series.series_name,
mode: "lines+markers",
line: {
......