This file is the core of the dashboard. It puts together the instructions set by the use in the dev/dev-defined.js file (variable stored in g
ie. module:g to create the charts and maps following the layout created in index.html. It uses the data loaded with the js/main-loadfiles.js module and can call additional modules such as: module-chartwarper.js, module-module-colorscale.js, module-datatable.js, module-interface.js or module-multiadm.js depending on the specific needs of the user.
- Since:
- 0.0
Requires
- module:index.html
- module:dev/dev-defined.js
- module:js/main-loadfiles.js
- module:js/module-datacheck.js
- module:lang/module-lang.js
Members
-
innercolor_domainArray
main-core -
Stores the number of values in module:main_core~color_list.
-
innercolor_listArray
main-core -
Stores color values converted from
display_colors
(module:g.viz_definition) to actual colors picked up in the current colorscale module:g.module_colorscale.colors > module:g.module_colorscale.colorscurrent.
Methods
-
innerchartBuilder()
main-core -
Builds charts based on instances created by module:main_core~chartInstancer.
module:g.viz_definition is used extensively in this method:chart_type
is used to access the definitions, the elementsdisplay_axis
will set the axis text anddisplay_colors
picks up the colors from lists (module:main_core~color_list). All the elements created before and stored in this same object: domains, chart instances, dimensions and groups... are also used here.
The height of charts is hard coded directly here.
List of current charts definitions is as follows:bar
creates a bar chart (see: example_barchart),
Added from basic dc.js charts:domain_type
== 'custom_ordinal' (module:main_core~domainBuilder), click bars to filter and custom units,domain_type
== 'custom_linear' (module:main_core~domainBuilder), with range filters taking only integers,- Labels for small bars (difficult or sometimes impossible to click).
pie
creates a pie chart (see: example_piechart),
Added from basic dc.js charts:- Percentages added to tooltips.
multiadm
creates a multiadm choropleth map, requires module:g.geometry_keylist and module:module_multiadm.display (see: example_multiadmmap),
Added from basic dc.js charts:- Administrative levels,
- 'Goto' via dropdown list,
- Different map units ('completeness', 'incidence rates', 'cases'...),
- Different colorscales,
- Automated colorscale,
- Add extra layers.
row
creates a row chart (see: example_rowchart),
Added from basic dc.js charts:domain_type
== 'custom_log', logarithmic scale,- Filters the diseases only one by one.
- Stores currently selected disease in: g.medical_currentdisease,
- Randomly select one disease at start,
- xAxis label.
stackedbar
creates a bar chart with stacked series (see: example_stackedbarchart),
Added from basic dc.js charts:domain_type
== 'custom_ordinal' (module:main_core~domainBuilder), click bars to filter and custom units,domain_type
== 'custom_linear' (module:main_core~domainBuilder), with range filters taking only integers,- Labels for small bars (difficult or sometimes impossible to click).
dimension_type
== 'shared' (module:main_core~dimensionBuilder), synchronizes with an other chart,
series
creates a multi series chart (see: example_serieschart),
Added from basic dc.js charts:domain_type
== 'custom_ordinal' (module:main_core~domainBuilder), click bars to filter and custom units NB: Not Tested,domain_type
== 'custom_linear' (module:main_core~domainBuilder), with range filters taking only integers,dimension_type
== 'shared' (module:main_core~dimensionBuilder), synchronizes with an other chart,
table
uses datatables.js to display tables: module:module_datatable (see: example_datatable).
- TODO
-
- Define properly.
bar
: revise labels.- Improve special xlabel margin...
- Add height to module:g.viz_definition.
multiadm
: add incidence definition or custom value definition to dev-defined.multiadm
: exploitation of mask_data is hardcoded.stackedbar
: u5 and o5 labels are hardcoded.
-
innerchartInstancer()
main-core -
Builds chart instances with dc.js or dc.leaflet.js (tables definitions with datables.js come later).
Definitions are accessed bychart_type
in module:g.viz_definition. The instances also useschart_id
in module:g.viz_definition to connect with the div ids of the layout defined in 'index.html' which are by convention of the form:id= "chart" + chartid
.
List of current chart definitions is as follows:bar
creates a simple bar chart (see: example_barchart),pie
creates a simple pie chart (see: example_piechart),multiadm
creates a multiadm choropleth map (one administrative structure or more that are 'nested' one into the others), requires module:g.geometry_keylist and module:module_multiadm.display (see: example_multiadmmap),row
creates a simple row chart (see: example_rowchart),stackedbar
creates a bar chart with stacked series (see: example_stackedbarchart),series
creates a multi series chart (see: example_serieschart).table
data table instances are actually created later as they require a crossfilter dimension to be setup first (see: example_datatable).
- TODO
-
- Define properly.
-
innercolorAccessor()
main-core -
Returns color number to get map color in module:main_core~color_list.
Depends on module:g.module_colorscale.valuescurrent and module:g.module_colorscale.mapunitcurrent.
Defined in module:main_core~chartBuilder >multiadm
. -
innerdimensionBuilder(){dc.dimension}
main-core -
Builds dimensions with crossfilter.js, it correspond to the method to filter the data, to use a spreadsheet analogy, it correspond to the column that will be used to filter the dataset.
Required objects are in module:g.viz_definition:chart_id
,dimension_type
and, depending on the previous value,dimension_setup
might be necessary. See module:g.viz_definition from more details on how definitions are accessed, this should be simplified in the coming versions.
List of current dimension definitions is as follows:sexpreg
, combines 'sex' and 'pregnancy' to create 3 categories (fromsex
andpreg
keys) and uses module:g.medical_read,fyo
, create 'five years old' categories (fromfyo
key) and uses module:g.medical_read,year
, creates 'year' categories (fromepiwk
key),sev
, creates 'severity' categories (fromsev
key) and uses module:g.medical_read,out
, creates 'output' categories (fromout
key) and uses module:g.medical_read,case
aliastable
, creates 'epiweek' categories (fromepiwk
key),multiadm
, creates 'location' categories for each administrative level combining field from current administrative level and superiors (fromadmNX
keys), requires module:g.geometry_keylist and uses module:module_datacheck.toTitleCase,age
, creates 'age' categories (fromage
key),dur
, creates 'stay duration' categories (fromdur
key),disease
, creates 'disease' categories (fromdisease
key) and uses module:module_datacheck~toTitleCase,epiwk_lin
, creates categories of ('year','week') pairs (fromepiwk
key),auto
, creates simple categories from a given 'key' (from'key'
key).
- TODO
-
- Parsing tests to avoid construction duplication to be revised.
Returns:
Type Description dc.dimension -
innerdomainBuilder(){Array}
main-core -
Builds domains for x/y charts when stated so in module:g.viz_definition:
domain_type =/= 'none'
.
Definitions are accessed bychart_id
* in module:g.viz_definition.
Definitions can be either 'custom_linear': [min,max] (filtering is then performed by range) or 'custom_ordinal': [lists, all, the, values, ...] (categories can be then filtered one by one).
All definitions uses module:g.medical_data except if indicated otherwise. module:g.medical_headerlist is required too.
List of current domain definitions is as follows:epiwk
[ordinal] aliases:case_bar
anddeath_bar
, lists all the epiweeks between the first and the last epiweeks of the dataset (fromepiwk
key),dur
[ordinal] lists all stay durations from zero to the maximum in the dataset (fromdur
key),out
[ordinal] lists all categories of output, not from medical_data but from module:g.medical_read (fromout
key),age
[linear] zero and maximum age of patients in the dataset +2 (to facilitate visualization) (fromage
key)wk
[linear] aliases:case_lin
anddeath_lin
, minimum and maximum week numbers in the dataset (fromepiwk
key).
On top of the domain aNA
category is added as well in order to visualize data with missing or mismatched values.Returns:
Type Description Array -
innergenerateDashboard()
main-core -
Procedural component: should be rethought to be modular (OO programming...).
Main procedure of the main-core. Generates the charts and maps one by one from the list: module:g.viz_definition (defined by the developer in dev/devdefined.js).
The process contains the following steps which are performed for each chart/map:- Creation of domains definitions for x/y charts (bar charts, series...), gives the possibility to have clickable bar behavior, to manage exceptions (NAs) ... - module:main_core~domainBuilder
- Declares the instances of charts and maps dc.js objects - module:main_core~chartInstancer (not properly declared as a method...)
- Declares the instances of crossfilter.js dimensions, it correspond to the method to filter the data, to use a spreadsheet analogy, it correspond to the column that will be used to filter the dataset - module:main_core~dimensionBuilder
- Declares the instances of crossfilter.js groups, it correspond to the method to aggregate the data, counting the records for a patient list or summing a specific column for surveillance data that can contain cases, death... - module:main_core~groupBuilder
- Puts everything together to create the charts and maps (domains, dimensions and groups, colors, text, specific behaviors...). - module:main_core~chartBuilder (not properly declared as a method...)
- Finally, it synchronizes maps movements and charts, loads a bunch of modules and create quick numeric outputs to be displayed... (hem, yes quite messy).
Initiates the dashboard generation process.
Is triggered in module:main_loadfiles~generate_display.
Requires:- module:g.viz_definition
- module:g.medical_data
- module:g.medical_headerlist
- module:g.medical_read
- module:module_multiadm.display
- module:g.geometry_keylist
- module:module_datacheck~toTitleCase
- module:g.medical_datatype
- module:g.module_colorscale.colors
- module:g.module_colorscale.colorscurrent
- module:g.module_colorscale.mapunitcurrent
- module:g.module_colorscale.valuescurrent
- module:g.module_colorscale.modecurrent
- module:module_colorscale.lockcolor
- module:module_datatable.setup
- module:module_datatable.display
- module:module_datatable.interaction
- module:module_datatable.refreshTable
- module:module_multiadm.interaction
- module:module_intro.setup
- module:module_interface.display
- module:module_chartwarper.display
- module:module_chartwarper.interaction
- module:main_core~domainBuilder
- module:main_core~chartInstancer (not properly declared as a method...)
- module:main_core~dimensionBuilder
- module:main_core~groupBuilder
- module:main_core~chartBuilder (not properly declared as a method...)
- module:g.viz_keylist
- module:g.viz_definition - Most of the global variables are stored there.
- module:g.viz_currentvalues
- TODO
-
- Should be broken down in smaller pieces.
- Each of the steps from 1) to x) can actually be broken down into two smaller functions 'Building' which is about defining an Object (echo to an Object 'constructor') and 'Parsing' which is attributing this object to the correct chart/map... These two steps should clearly appear and the 'Parsing' method should be improved (especially for dimensions).
- group_type == 'shared' should not exist, but should be taken from 'dimension_type' instead.
-
innergroupBuilder(){dc.group}
main-core -
Builds groups with crossfilter.js, it correspond to the method to aggregate the data, counting the records for a patient list or summing a specific column for surveillance data that can contain cases, death...
Groups are built on top of dimensions (see: module:main_core~dimensionBuilder and module:g.viz_definition).
Required objects are module:g.medical_datatype and in module:g.viz_definition: depending on the previous value,group_setup
might be necessary,chart_id
,group_type
,dimension_type
and, depending on the previous value,dimension_setup
might be necessary. See module:g.viz_definition from more details on how definitions are accessed, this should be simplified in the coming versions.
List of current group definitions is as follows:outbreak
(simply counts patients in patient list)multiadm
, creates a group for each administrative level, requires module:g.geometry_keylist,auto
, creates a simple group,
surveillance
(sums or counts already aggregated data)multiadm
, creates a group for each administrative level by both summing and counting (currently fromgroup_setup[0]
key), requires module:g.geometry_keylist,stacked
, creates a group summing independently 'under' and 'over' five years old record (currently fromgroup_setup[0]
andgroup_setup[1]
keys),row
, creates a group counting 1/2 per record (currently fromgroup_setup[0]
key),auto
, creates a simple group summing data (currently fromgroup_setup[0]
key),
Returns:
Type Description dc.group -
innernumericOutputs()
main-core -
Creates three numeric outputs:
- For 'surveillance': number of cases and deaths in current subset. Container ids:
case-info
anddeath-info
. - For 'outbreak': number of patients in current subset. Container ids:
count-info
.
- TODO
-
- Define properly.
- For 'surveillance': number of cases and deaths in current subset. Container ids:
-
inneronFiltered()
main-core -
Enable 'Auto' mode for the function module:module_colorscale.lockcolor.
Includes a small delay for 'Incidence' unit as module:main_core~valueAccessor requires more time to parse the data.
Also enables the datatable to refresh module:module_datatable.refreshTable.- TODO
-
- Define properly.
-
innersync_charts()
main-core -
Sync charts filters based on the
sync_to
parameter in module:g.viz_definition.
Triggered by the end of module:main_core:generateDashboard.- TODO
-
- Define properly.
-
innersync_maps()
main-core -
Sync maps movements.
Triggered by the end of module:main_core:generateDashboard.- TODO
-
- Define properly.
- Check if works properly.
-
innervalueAccessor()
main-core -
Populates module:g.viz_currentvalues with values currently displayed on the map and parses values to the
multiadm
chart.
Defined in module:main_core~chartBuilder >multiadm
.
Currently accepts 'Cases', 'Incidence' and 'Completeness' map units (from module:main_core~valueAccessor).
Requires:- module:g.geometry_keylist
- module:g.module_colorscale.mapunitcurrent
- module:g.viz_definition
- module:g.viz_timeline (for 'Incidence' and 'Completeness')
- module:g.population_popdata (for 'Incidence')
- module:g.medical_completeness (for 'Completeness')
- module:g.viz_currentvalues
-
innerzoomToGeom(geom, adm)
main-core -
Zoom a given map to a given geometry.
Name Type Description geom
dc.geometry Geometry
adm
dc.map dc.map