export function createTooltipInfo()

in src/tooltipBuilder.ts [54:109]


export function createTooltipInfo(
    dataViewCat: DataViewCategorical,
    categoryValue: PrimitiveValue,
    value?: PrimitiveValue,
    seriesIndex?: number): VisualTooltipDataItem[] {

    let categorySource: TooltipCategoryDataItem,
        seriesSource: TooltipSeriesDataItem[] = [],
        valuesSource: DataViewMetadataColumn = undefined;

    seriesIndex = seriesIndex | DefaultSeriesIndex;

    let categoriesData: DataViewCategoricalColumn[] = dataViewCat && dataViewCat.categories;

    if (categoriesData && categoriesData.length > 0) {
        if (categoriesData.length > 1) {
            let compositeCategoriesData: DataViewMetadataColumn[] = [];

            for (let i: number = 0, ilen: number = categoriesData.length; i < ilen; i++) {
                compositeCategoriesData.push(categoriesData[i].source);
            }

            categorySource = {
                value: categoryValue,
                metadata: compositeCategoriesData
            };
        }
        else {
            categorySource = {
                value: categoryValue,
                metadata: [categoriesData[0].source]
            };
        }
    }

    if (dataViewCat && dataViewCat.values) {
        if (!categorySource || !(categorySource.metadata[0] === dataViewCat.values.source)) {
            valuesSource = dataViewCat.values.source;
        }

        if (dataViewCat.values.length > 0) {
            const valueColumn: DataViewValueColumn = dataViewCat.values[seriesIndex];
            seriesSource.push({
                value,
                highlightedValue: undefined,
                metadata: valueColumn
            });

        }

        return createTooltipData(
            categorySource,
            valuesSource,
            seriesSource);
    }
}