model/model-chart-type.js

/**
 * Copyright (c) 2019
 *
 * @summary d3 script for charts of AggreSet
 * @author Elitza Vasileva
 * @author Bernhard Pointner
 */
const chartTypes = {
    HORIZONTAL_BAR: 'horizontal_bar',
    VERTICAL_BAR: 'vertical_bar',
    LINE: 'line',
    AGGRESET: 'aggreset'
}

/**
 * Initializes the chart according the to the chart type
 * @param chartType   can be horizontal, vertical, line or aggreset
 * @param restArgs   the rest of the arguments
 * @returns {Chart}
 */
const initChart = function(chartType, ...restArgs) {
    switch(chartType) {
        case chartTypes.VERTICAL_BAR: return new VerticalBarChart( ...restArgs);
        case chartTypes.HORIZONTAL_BAR: return new HorizontalBarChart( ...restArgs);
        case chartTypes.LINE: return new VerticalBarChart( ...restArgs);
        case chartTypes.AGGRESET: return new AggreSetChart( ...restArgs);
    }
}