private getGradientPoints()

in src/converter/dataConverter.ts [442:526]


    private getGradientPoints(
        axisValues: DataRepresentationAxisValueType[],
        dataRepresentation: IDataRepresentation,
        seriesGroup: IDataRepresentationSeriesGroup,
        groupedValue: powerbi.DataViewValueColumn,
        seriesY: IDataRepresentationAxisBase,
        kpiIndexes: number[],
        seriesSettings: SeriesSettings,
        settings: Settings,
        currentPoint: IDataRepresentationPointIndexed,
    ): {
            points: IDataRepresentationPoint[],
            gradientPoints: IDataRepresentationPointGradientColor[],
        } {
        const gradientPoints: IDataRepresentationPointGradientColor[] = [];

        const dataPointEndsKpiColorSegment: boolean = !seriesSettings.line.dataPointStartsKpiColorSegment;

        const copiedAxisValues: DataRepresentationAxisValueType[] = dataPointEndsKpiColorSegment
            ? axisValues.slice().reverse()
            : axisValues.slice();

        const points: IDataRepresentationPoint[] = copiedAxisValues
            .map((axisValue: DataRepresentationAxisValueType, index: number) => {
                const categoryIndex: number = dataPointEndsKpiColorSegment
                    ? copiedAxisValues.length - 1 - index
                    : index;

                const value: number = groupedValue.values[categoryIndex] as number;

                this.applyXArguments(dataRepresentation, axisValue);
                this.applyYArguments(seriesGroup.y, value);

                this.applyYArguments(seriesY, value);

                const kpiIndex: number = this.getKPIIndex(kpiIndexes[categoryIndex]);

                let color: string = seriesSettings.line.fillColor;

                if (seriesSettings.line.shouldMatchKpiColor) {
                    const currentKPI: IKPIIndicatorSettings = settings
                        .kpiIndicator
                        .getCurrentKPI(kpiIndex);

                    color = currentKPI && currentKPI.color || color;
                }

                if (this.isValueFinite(value)
                    && (categoryIndex > currentPoint.index || !isFinite(currentPoint.index))
                ) {
                    currentPoint.x = axisValue;
                    currentPoint.y = value;
                    currentPoint.index = categoryIndex;
                    currentPoint.kpiIndex = kpiIndex;
                    currentPoint.color = color;
                }

                const point: IDataRepresentationPoint = {
                    color,
                    kpiIndex,
                    x: axisValue,
                    y: value,
                };

                this.pointFilter.groupPointByColor(
                    gradientPoints,
                    point,
                    dataPointEndsKpiColorSegment,
                );

                return point;
            });

        if (dataPointEndsKpiColorSegment) {
            return {
                gradientPoints,
                points: points.reverse(),
            };
        }

        return {
            gradientPoints,
            points,
        };
    }