"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFunnelChartEchartsConfig = void 0;
const getCommonEChartsConfig_1 = require("../../shared/getCommonEChartsConfig");
/**
 * Generates funnel chart echarts config for server-side rendering
 */
const getFunnelChartEchartsConfig = (queryTool, rows) => {
    const { dimensions, metrics } = queryTool.queryConfig;
    const { chartConfig } = queryTool;
    const metricField = chartConfig?.yAxisMetrics?.[0] || metrics[0];
    // Transform data for funnel chart
    const data = rows.map((row) => {
        // Use first dimension as the name
        const name = dimensions.length > 0 ? String(row[dimensions[0]]) : '';
        return {
            name,
            value: row[metricField],
        };
    });
    return {
        ...(0, getCommonEChartsConfig_1.getCommonEChartsConfig)({
            title: queryTool.title,
            showLegend: false,
            chartData: rows,
        }),
        tooltip: {
            show: true,
            trigger: 'item',
        },
        legend: {
            show: true,
            orient: 'horizontal',
            bottom: 10,
        },
        series: [
            {
                type: 'funnel',
                data,
                label: {
                    position: 'inside',
                },
                sort: 'descending',
            },
        ],
    };
};
exports.getFunnelChartEchartsConfig = getFunnelChartEchartsConfig;
//# sourceMappingURL=funnel.js.map