The ChartManager object links DataSources, loads column data on demand and manages charts/widgets. It is the main interface for interacting with MDV. The ChartManager's constructor requires list of DataStore configs, a dataloader object, a config for construction and optionally a listener.
const cm = new ChartManager("mydiv", datasources, dataloader, config, listener)
DataStore
configs, these configs should also include a size parameter showing the number of rows in the data setrow_data_loader:true
and DataHighlighted
is invoked.binary_data_laoder: true
[
{
"type": "tsv",
"dataSource": "cells",
"url": "data/cell_all_archr.tsv"
},
{
"type": "tsv",
"dataSource": "genes",
"url2": "data/genes.txt"
}
]
Can be added with the method addListener(id, function) and removed with removeListener(id). Alternatively a listener can be added as the last parameter when constructing the ChartManager object.
The listener should be a function which receives the type of event, the ChartManager object and any data associated with the event. A typical listener would be:-
(type, cm, data) => {
switch(type){
case "view_loaded":
..do stuff with data
break;
case "state_saved":
..push data to server
break;
}
}
The types of listeners are:-
notify=true
e.g. when a user adds a chart. The data received is the chart object itself.notify=true
e.g. when a user removes a chart. The data received is the chart object itself.DataStore
is filtered, passing the Dimension
that has done the filteringCalled when the user saves the data. The object passed to the listener consists of the following:-
view
- A config containing all data for the view, or null
if the view is to be deleted
currentView
- the name of a view to be updated, or null
if the state being saved is not a view
all_views
- A list of views
updatedColumns
- a dictionary with a entry for each datasource
columns
- a list of all columns that have either been updated or added containing:
metadata
- the columns metadatadata
an array of the column's raw dataadded
- a list of all column id(fields) that have been addedremoved
- a list of all columns that have been deletedcolors_changed
-a list of columns whose color scheme has changed
column
- the id of the columncolors
-the new color scheme (list of hex values)metadata
- a dictionary of all datasources whose metadata has been updated, with each entry being a dictionary of the parameter and value
{
"view": {....},
"cuurentView": "default",
"all_views": ["default", "myview"],
"updatedColumns": {
"cells": {
"columns": [
{
"metadata": {"field": "new annotations", ...},
"data": [2, 1, 2.....]
},
{
"metadata": {"field": "annotations", ...},
"data": [0, 0, 2.....]
}
],
"added": ["new annotations"],
"removed":[ ],
"colors_changed": [
{
"column": "annotations",
"colors": ["#4532FF", ....]
}
]
}
},
"metadata": {
"cells": {
"param1": {....},
"param2": {....}
}
}
}