How to use the tui-code-snippet.map function in tui-code-snippet

To help you get started, weโ€™ve selected a few tui-code-snippet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samuelbetio / storyofmylife / test / app / controller / viewMixin / week.spec.js View on Github external
beforeEach(function() {
        base = ControllerFactory(['Week']);
        ctrl = base.Week;
        mockData = fixture.load('schedule_set_string3.json');
        scheduleList = util.map(mockData, function(data) {
            return Schedule.create(data);
        }).sort(array.compare.schedule.asc);
    });
github nhn / tui.chart / src / js / helpers / renderUtil.js View on Github external
let formattedValue;

        if (value.indexOf('.') > -1) {
            values = value.split('.');
            value = String(Math.abs(values[0]));
            underPointValue = `.${values[1]}`;
        } else {
            value = String(Math.abs(value));
        }

        if (value.length <= betweenLen) {
            formattedValue = orgValue;
        } else {
            values = (value).split('').reverse();
            lastIndex = values.length - 1;
            values = snippet.map(values, (char, index) => {
                const result = [char];
                if (index < lastIndex && (index + 1) % betweenLen === 0) {
                    result.push(comma);
                }

                return result;
            });
            formattedValue = sign + [].concat(...values).reverse().join('') + underPointValue;
        }

        return formattedValue;
    },
github nhn / tui.calendar / src / js / controller / base.js View on Github external
Base.prototype.createSchedules = function(dataList, silent) {
    var self = this;

    return util.map(dataList, function(data) {
        return self.createSchedule(data, silent);
    });
};
github nhn / tui.calendar / src / js / view / week / dayname.js View on Github external
DayName.prototype._getBaseViewModel = function(start, end, grids) {
    var daynames = this.options.daynames,
        theme = this.theme,
        now = new TZDate().toLocalTime(),
        viewModel;

    viewModel = util.map(datetime.range(
        datetime.start(start),
        datetime.end(end),
        datetime.MILLISECONDS_PER_DAY
    ), function(d, i) {
        var day = d.getDay();
        var isToday = datetime.isSameDate(d, now);
        var isPastDay = d < now && !isToday;

        return {
            day: day,
            dayName: daynames[day],
            isToday: isToday,
            date: d.getDate(),
            left: grids[i] ? grids[i].left : 0,
            width: grids[i] ? grids[i].width : 0,
            renderDate: datetime.format(d, 'YYYY-MM-DD'),
github nhn / tui.chart / src / js / models / scaleData / axisDataMaker.js View on Github external
_makeLabelsByIntervalOption: function(labels, labelInterval, addedDataCount) {
        addedDataCount = addedDataCount || 0;
        labels = snippet.map(labels, function(label, index) {
            if (((index + addedDataCount) % labelInterval) !== 0) {
                label = chartConst.EMPTY_AXIS_LABEL;
            }

            return label;
        });

        return labels;
    },
github nhn / tui.calendar / src / js / common / common.js View on Github external
nearest: function(value, nearest) {
        var diff = util.map(nearest, function(v) {
                return Math.abs(value - v);
            }),
            nearestIndex = util.inArray(Math.min.apply(null, diff), diff);

        return nearest[nearestIndex];
    },
github nhn / tui.calendar / src / js / controller / base.js View on Github external
util.forEachArray(range, function(date) {
        ymd = dformat(date, 'YYYYMMDD');
        matrix = ownMatrix[ymd];
        viewModels = result[ymd] = common.createScheduleCollection();

        if (matrix && matrix.length) {
            viewModels.add.apply(viewModels, util.map(matrix, function(id) {
                return ScheduleViewModel.create(ownSchedules[id]);
            }));
        }
    });
github nhn / tui.chart / src / js / models / data / rawDataHandler.js View on Github external
pickStacks: function(seriesData, divergingOption) {
        var stacks, uniqStacks, filteredStack;

        stacks = snippet.map(seriesData, function(seriesDatum) {
            return seriesDatum.stack;
        });

        uniqStacks = arrayUtil.unique(stacks);

        if (divergingOption) {
            uniqStacks = uniqStacks.slice(0, 2);
        }

        filteredStack = snippet.filter(uniqStacks, function(stack) {
            return !!stack;
        });

        if (filteredStack.length < uniqStacks.length) {
            filteredStack.push(chartConst.DEFAULT_STACK);
        }
github nhn / tui.chart / src / js / helpers / renderUtil.js View on Github external
formatValues(values, formatFunctions, typeInfos = {}) {
        const {chartType, areaType, valueType} = typeInfos;

        if (!formatFunctions || !formatFunctions.length) {
            return values;
        }

        return snippet.map(values, value => renderUtil.formatValue({
            value,
            formatFunctions,
            chartType,
            areaType,
            valueType
        }));
    },
github nhn / tui.chart / src / js / plugins / raphaelBarChart.js View on Github external
_renderBarBorders(groupBounds) {
        const {borderColor} = this.theme;

        if (!borderColor) {
            return null;
        }

        const groupBorders = snippet.map(groupBounds, (bounds, groupIndex) => (
            snippet.map(bounds, (bound, index) => {
                if (!bound) {
                    return null;
                }

                const seriesItem = this.seriesDataModel.getSeriesItem(groupIndex, index);

                return this._renderBorderLines(bound.start, borderColor, self.chartType, seriesItem);
            })
        ));

        return groupBorders;
    }