Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
});
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;
},
Base.prototype.createSchedules = function(dataList, silent) {
var self = this;
return util.map(dataList, function(data) {
return self.createSchedule(data, silent);
});
};
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'),
_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;
},
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];
},
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]);
}));
}
});
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);
}
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
}));
},
_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;
}