The object to manage charts Chart Manager

The DOM element or id of the element to house the app

An array of datasource configs - see Data Source. Each config must contain the size parameter, giving the number of rows in the DataStore.

An object containing the following

  • function - The function to load the data (can be omitted if data loaded from a file)
  • viewLoader - The function that will load the each view (not necessay if only one view)
  • rowDataLoader - (optional) an asunc function which is given the datasource name and row index returns unstructured data . A datasource's config requires row_data_loader:true to activate the loader
  • files - specifies the files to load the data

extra settings

A list of chart configs to initially load if no views are specified

A list of views that can be loaded (a suitable view loader is required to atually load the view)

the current view (only used with all views)

the level of permission the user has. This just makes certain options unavaliable. Any logic should be handled when a state_saved event is broadcast

whether to arrange the charts in a grid

A function to listen to events. (eventType: string, cm: ChartManager, data: any) => void | Promise<void> beware: the way 'event listeners' are implemented is highly unorthodox and may be confusing.

Constructors

  • Parameters

    • div: any
    • dataSources: any
    • dataLoader: any
    • config: {} = {}
    • listener: null = null

    Returns ChartManager

Properties

_inInit: undefined | boolean
_toLoadCharts: undefined | Set<any>
charts: {
    [id: string]: { chart: any; dataSource: DataSource; win: null | Window };
}
columnsLoading: {}
config: {}
containerDiv: HTMLElement
contentDiv: HTMLDivElement
dataLoader: any
dataSources: any[]

!typed according to previous comments - but I was using it in a way that was working and doesn't match the comments... each entry in dataSources will contain dataStore - the actual dataStore object (previously this comment erroneously referred to as 'dataSource') name - the name given to this data source menuBar the dom menu associated with this element contentDiv the div that the charts associated with the datastore will be added

dsIndex: { [k: string]: any }
dsPanes: undefined | {}
filesToLoad: any
gridStack: GridStackManager
infoAlerts: {}
layoutMenus: {}
leftMenuBar: HTMLSpanElement
listeners: {}
menuBar: HTMLDivElement
progressBars: {}
rightMenuBar: HTMLSpanElement
theme: any
themeMenu: undefined | ContextMenu
transactions: {}
viewData: any
viewLoader: any
viewManager: ViewManager

Methods

  • Parameters

    • method: any
    • chart: any
    • dataSource: any

    Returns void

  • Parameters

    • theme: any

    Returns { func: () => void; ghosted: boolean; text: any }

  • Parameters

    • ds: DataStore
    • ods: DataStore

      other data store

    • link: object

      information about what properties to target in ods For instance, { source_column: <column_name>, target_chart: <chart_id>, target_property: <property_name> } more concretely: { source_column: "feature", target_chart: "quadrat_image_chart", target_property: "color_by" }

    Returns void

  • Adds a link that will filter a column in one datasource based on the values in another: when the values in the source column are filtered, the values in the destination column will be filtered so that only those appearing in the selected values of the source column will be displayed.

    Parameters

    • ds: any
    • ods: any
    • link: any

    Returns void

  • Parameters

    • method: any
    • chart: any
    • dataSource: any

    Returns void

  • Parameters

    • dataSource: any
    • columns: any

    Returns Promise<any>

  • Parameters

    • dataSource: any
    • otherDataSource: any
    • columns: any
    • indexCol: any
    • func: any

    Returns void

  • Parameters

    • dataSource: any
    • columns: any
    • func: any

    Returns void

  • Parameters

    • dataStore: any

    Returns { added: never[]; colors_changed: never[]; columns: never[]; removed: never[] }

  • Parameters

    • chart: any
    • dataSource: any
    • index: any

    Returns void

  • Parameters

    • neededCols: any
    • dataSource: any
    • func: any

    Returns void

  • Parameters

    • view: any
    • firstTime: boolean = false

    Returns Promise<void>

  • Parameters

    • config: any
    • dataLoader: any
    • firstTime: boolean = false

    Returns void

  • Adds a chart to the app. Returns asyncronously when needed columns have loaded and the chart has been added (will reject if there is an error)

    Parameters

    • dataSource: string

      The name of the chart's data source

    • config: any

      The chart's config

    • Optionalnotify: boolean = false

      If true any listeners will be informed that a chart has been loaded

    Returns Promise<void>

  • Adds a listener to the ChartManager.

    Note that the signature is different from what might be expected (this is an MDV pattern that may be reviewed in future): The first argument is a string that identifies the listener (not an event type to listen for). Subsequent calls to addListener with the same id will overwrite the previous listener (which could lead to unexpected behaviour, for example if a corresponding removeListener() call is made). The second argument is a function that will be called when the listener is triggered - all registered listeners will be called for any event.

    Parameters

    • id: string
    • func: Function

      Callback function. First argument is the type of event ("state_saved" | "view_loaded" | "chart_added" | "chart_removed"), second is the ChartManager instance, third is the data.

    Returns void

  • Adds a menu icon to either the main menubar or a datasource menubar

    Parameters

    • dataSource: string

      The name of data source or _main if adding an icon to the main (top) toolbar

    • icon: string

      The class name(s) of the icon

    • text: string

      Text that will be displayed in a tooltip

    • func: Function

      The function that will be called when the icon is pressed

    • right: boolean = false

      If true (and dataSource = "_main") the icon will be added to the right of the menu bar

    Returns HTMLSpanElement

  • Get all the charts for a data sorce

    Parameters

    • dataSource: string

      The name of the data source

    Returns any[]

    • An array of chart objects
  • Returns {
        all_views: null | string[];
        currentView: string;
        metadata: {};
        updatedColumns: {};
        view: any;
    }

  • Loads data for specified columns into the appropriate dataStore

    Parameters

    • columns: string[]

      An array of column fields/ids

    • dataSource: string

      The name of the dataSource

    • callback: Function

      A function which will be run once all the columns are loaded, with any failed columns as an argument (although it's not clear that the underlying code actually does this, or that any code that calls this function actually uses the argument)

    • Optionalsplit: number = 10

      the number of columns to send with each request

    • Optionalthreads: number = 2

      the number of concurrent requests

    Returns void

  • Loads data from a remote file -the file must have headers (keys in the case of json) which which match a columns field/id

    Parameters

    • info: { dataSource: string; type: string; url: string }

      A config describing the file -

      • dataSource: string

        the name of the datasource to load the data into

      • type: string

        either csv,tsv ot json

      • url: string

        the url of the file

    • Optionalcallback: Function

      a function to run once the data has loaded

    Returns void

  • Parameters

    • rowLength: number = 5
    • size: number[] = ...
    • margin: number = 10

    Returns void