Module: main_core

main_core

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 elements display_axis will set the axis text and display_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:
  • 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:
  • series creates a multi series chart (see: example_serieschart),
    Added from basic dc.js charts:
  • 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 by chart_type in module:g.viz_definition. The instances also uses chart_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 (from sex and preg keys) and uses module:g.medical_read,
  • fyo, create 'five years old' categories (from fyo key) and uses module:g.medical_read,
  • year, creates 'year' categories (from epiwk key),
  • sev, creates 'severity' categories (from sev key) and uses module:g.medical_read,
  • out, creates 'output' categories (from out key) and uses module:g.medical_read,
  • case alias table, creates 'epiweek' categories (from epiwk key),
  • multiadm, creates 'location' categories for each administrative level combining field from current administrative level and superiors (from admNX keys), requires module:g.geometry_keylist and uses module:module_datacheck.toTitleCase,
  • age, creates 'age' categories (from age key),
  • dur, creates 'stay duration' categories (from dur key),
  • disease, creates 'disease' categories (from disease key) and uses module:module_datacheck~toTitleCase,
  • epiwk_lin, creates categories of ('year','week') pairs (from epiwk 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 by chart_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 and death_bar, lists all the epiweeks between the first and the last epiweeks of the dataset (from epiwk key),
  • dur [ordinal] lists all stay durations from zero to the maximum in the dataset (from dur key),
  • out [ordinal] lists all categories of output, not from medical_data but from module:g.medical_read (from out key),
  • age [linear] zero and maximum age of patients in the dataset +2 (to facilitate visualization) (from age key)
  • wk [linear] aliases: case_lin and death_lin, minimum and maximum week numbers in the dataset (from epiwk key).

On top of the domain a NA 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:

  1. 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
  2. Declares the instances of charts and maps dc.js objects - module:main_core~chartInstancer (not properly declared as a method...)
  3. 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
  4. 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
  5. 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: Intermediaries: Returns:
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)
  • surveillance (sums or counts already aggregated data)
    • multiadm, creates a group for each administrative level by both summing and counting (currently from group_setup[0] key), requires module:g.geometry_keylist,
    • stacked, creates a group summing independently 'under' and 'over' five years old record (currently from group_setup[0] and group_setup[1] keys),
    • row, creates a group counting 1/2 per record (currently from group_setup[0] key),
    • auto, creates a simple group summing data (currently from group_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 and death-info.
  • For 'outbreak': number of patients in current subset. Container ids: count-info.
TODO
  • Define properly.

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:

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