"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function addSeries(seriesLabel, xSeriesName, ySeriesName, inputChartDef, flotChartDef) {
    var seriesData = inputChartDef.data.values.map(function (row) { return [row[xSeriesName], row[ySeriesName]]; });
    flotChartDef.data.push({
        label: seriesLabel,
        data: seriesData,
    });
}
function extractSeries(axisName, inputChartDef, flotChartDef) {
    var axisMap = inputChartDef.axisMap;
    if (!axisMap) {
        return;
    }
    var series = axisMap[axisName];
    if (!series) {
        return;
    }
    for (var _i = 0, series_1 = series; _i < series_1.length; _i++) {
        var seriesConfig = series_1[_i];
        var label = seriesConfig.label || seriesConfig.series;
        var xSeriesName = seriesConfig.x && seriesConfig.x.series
            || inputChartDef.axisMap.x.series;
        addSeries(label, xSeriesName, seriesConfig.series, inputChartDef, flotChartDef);
    }
}
/**
 * Convert a data-forge-plot chart definition to a flot chart definition.
 */
function formatChartDef(inputChartDef) {
    var flotChartDef = {
        data: [],
        options: {},
    };
    extractSeries("y", inputChartDef, flotChartDef);
    extractSeries("y2", inputChartDef, flotChartDef);
    return flotChartDef;
}
exports.formatChartDef = formatChartDef;
//# sourceMappingURL=format-chart-def.js.map