import indicatorSegments from '../consts/indicatorSegments';

export function getIndicatorByValue (value) {
    value = value || 0;
    for (let i = 0; i < indicatorSegments.length - 1; i++) {
        const indicatorSegment = indicatorSegments[i];
        let flag = true;
        if (indicatorSegment.max !== undefined && value > indicatorSegment.max) {
            flag = false;
        }
        if (indicatorSegment.min !== undefined && value < indicatorSegment.min) {
            flag = false;
        }
        if (flag) {
            return {
                level: i,
                indicator: indicatorSegment
            };
        }
    }
    return null;
}
