").addClass(TABS_NAV_BUTTON_CLASS), _button2.default, {
focusStateEnabled: false,
icon: icon,
onClick: function() {
that._updateScrollPosition(offset, 1)
},
integrationOptions: {}
});
var $navButton = navButton.$element();
_events_engine2.default.on($navButton, holdEventName, {
timeout: FEEDBACK_SCROLL_TIMEOUT
}, function(e) {
holdAction({
event: e
})
}.bind(this));
_events_engine2.default.on($navButton, pointerUpEventName, function() {
that._clearInterval()
});
_events_engine2.default.on($navButton, pointerOutEventName, function() {
that._clearInterval()
});
return navButton
},
_clearInterval: function() {
if (this._holdInterval) {
clearInterval(this._holdInterval)
}
},
_updateSelection: function(addedSelection) {
this._scrollable && this._scrollable.scrollToElement(this.itemElements().eq(addedSelection[0]), {
left: 1,
right: 1
})
},
_visibilityChanged: function(visible) {
if (visible) {
this._dimensionChanged()
}
},
_dimensionChanged: function() {
this._renderScrolling()
},
_itemSelectHandler: function(e) {
if ("single" === this.option("selectionMode") && this.isItemSelected(e.currentTarget)) {
return
}
this.callBase(e)
},
_clean: function() {
this._cleanScrolling();
this.callBase()
},
_optionChanged: function(args) {
switch (args.name) {
case "useInkRipple":
case "scrollingEnabled":
case "showNavButtons":
this._invalidate();
break;
case "scrollByContent":
this._scrollable && this._scrollable.option(args.name, args.value);
break;
case "width":
this.callBase(args);
this._dimensionChanged();
break;
case "selectionMode":
this._renderMultiple();
this.callBase(args);
break;
case "badgeExpr":
this._invalidate();
break;
default:
this.callBase(args)
}
},
_afterItemElementInserted: function() {
this.callBase();
this._renderScrolling()
},
_afterItemElementDeleted: function($item, deletedActionArgs) {
this.callBase($item, deletedActionArgs);
this._renderScrolling()
}
});
Tabs.ItemClass = _item2.default;
(0, _component_registrator2.default)("dxTabs", Tabs);
module.exports = Tabs;
module.exports.getTabsExpandedClass = TABS_EXPANDED_CLASS
},
/*!*******************************************************************************!*\
!*** ./artifacts/transpiled/ui/data_grid/ui.data_grid.data_source_adapter.js ***!
\*******************************************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var _uiGrid_core = __webpack_require__( /*! ../grid_core/ui.grid_core.data_source_adapter */ 342);
var _uiGrid_core2 = _interopRequireDefault(_uiGrid_core);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
}
}
var dataSourceAdapterType = _uiGrid_core2.default;
module.exports = {
extend: function(extender) {
dataSourceAdapterType = dataSourceAdapterType.inherit(extender)
},
create: function(component) {
return new dataSourceAdapterType(component)
}
}
},
/*!*********************************************************!*\
!*** ./artifacts/transpiled/ui/filter_builder/utils.js ***!
\*********************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var _deferred = __webpack_require__( /*! ../../core/utils/deferred */ 6);
var _errors = __webpack_require__( /*! ../../data/errors */ 37);
var _type = __webpack_require__( /*! ../../core/utils/type */ 1);
var _data = __webpack_require__( /*! ../../core/utils/data */ 18);
var _ui = __webpack_require__( /*! ../widget/ui.errors */ 19);
var _ui2 = _interopRequireDefault(_ui);
var _filtering = __webpack_require__( /*! ../shared/filtering */ 166);
var _filtering2 = _interopRequireDefault(_filtering);
var _format_helper = __webpack_require__( /*! ../../format_helper */ 63);
var _format_helper2 = _interopRequireDefault(_format_helper);
var _extend = __webpack_require__( /*! ../../core/utils/extend */ 0);
var _inflector = __webpack_require__( /*! ../../core/utils/inflector */ 33);
var _inflector2 = _interopRequireDefault(_inflector);
var _between = __webpack_require__( /*! ./between */ 641);
var _between2 = _interopRequireDefault(_between);
var _message = __webpack_require__( /*! ../../localization/message */ 10);
var _message2 = _interopRequireDefault(_message);
var _data_source = __webpack_require__( /*! ../../data/data_source/data_source */ 46);
var _ui3 = __webpack_require__( /*! ./ui.filter_operations_dictionary */ 642);
var _ui4 = _interopRequireDefault(_ui3);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
}
}
var DEFAULT_DATA_TYPE = "string",
EMPTY_MENU_ICON = "icon-none",
AND_GROUP_OPERATION = "and",
EQUAL_OPERATION = "=",
NOT_EQUAL_OPERATION = "<>",
DATATYPE_OPERATIONS = {
number: ["=", "<>", "<", ">", "<=", ">=", "isblank", "isnotblank"],
string: ["contains", "notcontains", "startswith", "endswith", "=", "<>", "isblank", "isnotblank"],
date: ["=", "<>", "<", ">", "<=", ">=", "isblank", "isnotblank"],
datetime: ["=", "<>", "<", ">", "<=", ">=", "isblank", "isnotblank"],
"boolean": ["=", "<>", "isblank", "isnotblank"],
object: ["isblank", "isnotblank"]
},
DEFAULT_FORMAT = {
date: "shortDate",
datetime: "shortDateShortTime"
},
LOOKUP_OPERATIONS = ["=", "<>", "isblank", "isnotblank"],
AVAILABLE_FIELD_PROPERTIES = ["caption", "customizeText", "dataField", "dataType", "editorTemplate", "falseText", "editorOptions", "filterOperations", "format", "lookup", "trueText", "calculateFilterExpression", "name"];
function getFormattedValueText(field, value) {
var fieldFormat = field.format || DEFAULT_FORMAT[field.dataType];
return _format_helper2.default.format(value, fieldFormat)
}
function isNegationGroup(group) {
return group && group.length > 1 && "!" === group[0] && !isCondition(group)
}
function getGroupCriteria(group) {
return isNegationGroup(group) ? group[1] : group
}
function setGroupCriteria(group, criteria) {
if (isNegationGroup(group)) {
group[1] = criteria
} else {
group = criteria
}
return group
}
function convertGroupToNewStructure(group, value) {
var isNegationValue = function(value) {
return value.indexOf("!") !== -1
},
convertGroupToNegationGroup = function(group) {
var criteria = group.slice(0);
group.length = 0;
group.push("!", criteria)
},
convertNegationGroupToGroup = function(group) {
var criteria = getGroupCriteria(group);
group.length = 0;
[].push.apply(group, criteria)
};
if (isNegationValue(value)) {
if (!isNegationGroup(group)) {
convertGroupToNegationGroup(group)
}
} else {
if (isNegationGroup(group)) {
convertNegationGroupToGroup(group)
}
}
}
function setGroupValue(group, value) {
convertGroupToNewStructure(group, value);
var i, criteria = getGroupCriteria(group),
getNormalizedGroupValue = function(value) {
return value.indexOf("!") === -1 ? value : value.substring(1)
},
changeCriteriaValue = function(criteria, value) {
for (i = 0; i < criteria.length; i++) {
if (!Array.isArray(criteria[i])) {
criteria[i] = value
}
}
};
value = getNormalizedGroupValue(value);
changeCriteriaValue(criteria, value);
return group
}
function getGroupMenuItem(group, availableGroups) {
var groupValue = getGroupValue(group);
return availableGroups.filter(function(item) {
return item.value === groupValue
})[0]
}
function getCriteriaOperation(criteria) {
if (isCondition(criteria)) {
return AND_GROUP_OPERATION
}
var value = "";
for (var i = 0; i < criteria.length; i++) {
var item = criteria[i];
if (!Array.isArray(item)) {
if (value && value !== item) {
throw new _errors.errors.Error("E4019")
}
if ("!" !== item) {
value = item
}
}
}
return value
}
function getGroupValue(group) {
var criteria = getGroupCriteria(group),
value = getCriteriaOperation(criteria);
if (!value) {
value = AND_GROUP_OPERATION
}
if (criteria !== group) {
value = "!" + value
}
return value
}
function getDefaultFilterOperations(field) {
return field.lookup && LOOKUP_OPERATIONS || DATATYPE_OPERATIONS[field.dataType || DEFAULT_DATA_TYPE]
}
function containItems(entity) {
return Array.isArray(entity) && entity.length
}
function getFilterOperations(field) {
var result = containItems(field.filterOperations) ? field.filterOperations : getDefaultFilterOperations(field);
return (0, _extend.extend)([], result)
}
function getCaptionByOperation(operation, filterOperationDescriptions) {
var operationName = _ui4.default.getNameByFilterOperation(operation);
return filterOperationDescriptions && filterOperationDescriptions[operationName] ? filterOperationDescriptions[operationName] : operationName
}
function getOperationFromAvailable(operation, availableOperations) {
for (var i = 0; i < availableOperations.length; i++) {
if (availableOperations[i].value === operation) {
return availableOperations[i]
}
}
throw new _ui2.default.Error("E1048", operation)
}
function getCustomOperation(customOperations, name) {
var filteredOperations = customOperations.filter(function(item) {
return item.name === name
});
return filteredOperations.length ? filteredOperations[0] : null
}
function getAvailableOperations(field, filterOperationDescriptions, customOperations) {
var filterOperations = getFilterOperations(field);
customOperations.forEach(function(customOperation) {
if (!field.filterOperations && filterOperations.indexOf(customOperation.name) === -1) {
var dataTypes = customOperation && customOperation.dataTypes;
if (dataTypes && dataTypes.indexOf(field.dataType || DEFAULT_DATA_TYPE) >= 0) {
filterOperations.push(customOperation.name)
}
}
});
return filterOperations.map(function(operation) {
var customOperation = getCustomOperation(customOperations, operation);
if (customOperation) {
return {
icon: customOperation.icon || EMPTY_MENU_ICON,
text: customOperation.caption || _inflector2.default.captionize(customOperation.name),
value: customOperation.name,
isCustom: true
}
} else {
return {
icon: _ui4.default.getIconByFilterOperation(operation) || EMPTY_MENU_ICON,
text: getCaptionByOperation(operation, filterOperationDescriptions),
value: operation
}
}
})
}
function getDefaultOperation(field) {
return field.defaultFilterOperation || getFilterOperations(field)[0]
}
function createCondition(field, customOperations) {
var condition = [field.dataField, "", ""],
filterOperation = getDefaultOperation(field);
updateConditionByOperation(condition, filterOperation, customOperations);
return condition
}
function removeItem(group, item) {
var criteria = getGroupCriteria(group),
index = criteria.indexOf(item);
criteria.splice(index, 1);
if (1 !== criteria.length) {
criteria.splice(index, 1)
}
return group
}
function createEmptyGroup(value) {
return value.indexOf("not") !== -1 ? ["!", [value.substring(3).toLowerCase()]] : [value]
}
function isEmptyGroup(group) {
var criteria = getGroupCriteria(group);
if (isCondition(criteria)) {
return false
}
var hasConditions = criteria.some(function(item) {
return isCondition(item)
});
return !hasConditions
}
function addItem(item, group) {
var criteria = getGroupCriteria(group),
groupValue = getGroupValue(criteria);
1 === criteria.length ? criteria.unshift(item) : criteria.push(item, groupValue);
return group
}
function getField(dataField, fields) {
for (var i = 0; i < fields.length; i++) {
if (fields[i].name === dataField) {
return fields[i]
}
if (fields[i].dataField.toLowerCase() === dataField.toLowerCase()) {
return fields[i]
}
}
var extendedFields = getItems(fields, true).filter(function(item) {
return item.dataField.toLowerCase() === dataField.toLowerCase()
});
if (extendedFields.length > 0) {
return extendedFields[0]
}
throw new _ui2.default.Error("E1047", dataField)
}
function isGroup(criteria) {
if (!Array.isArray(criteria)) {
return false
}
return criteria.length < 2 || Array.isArray(criteria[0]) || Array.isArray(criteria[1])
}
function isCondition(criteria) {
if (!Array.isArray(criteria)) {
return false
}
return criteria.length > 1 && !Array.isArray(criteria[0]) && !Array.isArray(criteria[1])
}
function convertToInnerGroup(group, customOperations) {
var groupOperation = getCriteriaOperation(group).toLowerCase() || AND_GROUP_OPERATION,
innerGroup = [];
for (var i = 0; i < group.length; i++) {
if (isGroup(group[i])) {
innerGroup.push(convertToInnerStructure(group[i], customOperations));
innerGroup.push(groupOperation)
} else {
if (isCondition(group[i])) {
innerGroup.push(convertToInnerCondition(group[i], customOperations));
innerGroup.push(groupOperation)
}
}
}
if (0 === innerGroup.length) {
innerGroup.push(groupOperation)
}
return innerGroup
}
function conditionHasCustomOperation(condition, customOperations) {
var customOperation = getCustomOperation(customOperations, condition[1]);
return customOperation && customOperation.name === condition[1]
}
function convertToInnerCondition(condition, customOperations) {
if (conditionHasCustomOperation(condition, customOperations)) {
return condition
}
if (condition.length < 3) {
condition[2] = condition[1];
condition[1] = EQUAL_OPERATION
}
return condition
}
function convertToInnerStructure(value, customOperations) {
if (!value) {
return [AND_GROUP_OPERATION]
}
value = (0, _extend.extend)(true, [], value);
if (isCondition(value)) {
return [convertToInnerCondition(value, customOperations), AND_GROUP_OPERATION]
}
if (isNegationGroup(value)) {
return ["!", isCondition(value[1]) ? [convertToInnerCondition(value[1], customOperations), AND_GROUP_OPERATION] : isNegationGroup(value[1]) ? [convertToInnerStructure(value[1], customOperations), AND_GROUP_OPERATION] : convertToInnerGroup(value[1], customOperations)]
}
return convertToInnerGroup(value, customOperations)
}
function getNormalizedFields(fields) {
return fields.reduce(function(result, field) {
if ((0, _type.isDefined)(field.dataField)) {
var normalizedField = {};
for (var key in field) {
if (field[key] && AVAILABLE_FIELD_PROPERTIES.indexOf(key) > -1) {
normalizedField[key] = field[key]
}
}
normalizedField.defaultCalculateFilterExpression = _filtering2.default.defaultCalculateFilterExpression;
if (!(0, _type.isDefined)(normalizedField.dataType)) {
normalizedField.dataType = DEFAULT_DATA_TYPE
}
result.push(normalizedField)
}
return result
}, [])
}
function getConditionFilterExpression(condition, fields, customOperations, target) {
var field = getField(condition[0], fields),
filterExpression = convertToInnerCondition(condition, customOperations),
customOperation = customOperations.length && getCustomOperation(customOperations, filterExpression[1]);
if (customOperation && customOperation.calculateFilterExpression) {
return customOperation.calculateFilterExpression.apply(customOperation, [filterExpression[2], field, target])
} else {
if (field.createFilterExpression) {
return field.createFilterExpression.apply(field, [filterExpression[2], filterExpression[1], target])
} else {
if (field.calculateFilterExpression) {
return field.calculateFilterExpression.apply(field, [filterExpression[2], filterExpression[1], target])
} else {
return field.defaultCalculateFilterExpression.apply(field, [filterExpression[2], filterExpression[1], target])
}
}
}
}
function getFilterExpression(value, fields, customOperations, target) {
if (!(0, _type.isDefined)(value)) {
return null
}
if (isNegationGroup(value)) {
var filterExpression = getFilterExpression(value[1], fields, customOperations, target);
return ["!", filterExpression]
}
var criteria = getGroupCriteria(value);
if (isCondition(criteria)) {
return getConditionFilterExpression(criteria, fields, customOperations, target) || null
} else {
var _filterExpression = void 0,
groupValue = getGroupValue(criteria),
result = [];
for (var i = 0; i < criteria.length; i++) {
if (isGroup(criteria[i])) {
_filterExpression = getFilterExpression(criteria[i], fields, customOperations, target);
if (_filterExpression) {
i && result.push(groupValue);
result.push(_filterExpression)
}
} else {
if (isCondition(criteria[i])) {
_filterExpression = getConditionFilterExpression(criteria[i], fields, customOperations, target);
if (_filterExpression) {
i && result.push(groupValue);
result.push(_filterExpression)
}
}
}
}
return result.length ? result : null
}
}
function getNormalizedFilter(group) {
var i, criteria = getGroupCriteria(group);
if (0 === criteria.length) {
return null
}
var itemsForRemove = [];
for (i = 0; i < criteria.length; i++) {
if (isGroup(criteria[i])) {
var normalizedGroupValue = getNormalizedFilter(criteria[i]);
if (normalizedGroupValue) {
criteria[i] = normalizedGroupValue
} else {
itemsForRemove.push(criteria[i])
}
} else {
if (isCondition(criteria[i])) {
if (!isValidCondition(criteria[i])) {
itemsForRemove.push(criteria[i])
}
}
}
}
for (i = 0; i < itemsForRemove.length; i++) {
removeItem(criteria, itemsForRemove[i])
}
if (1 === criteria.length) {
return null
}
criteria.splice(criteria.length - 1, 1);
if (1 === criteria.length) {
group = setGroupCriteria(group, criteria[0])
}
if (0 === group.length) {
return null
}
return group
}
function getCurrentLookupValueText(field, value, handler) {
if ("" === value) {
handler("");
return
}
var lookup = field.lookup;
if (lookup.items) {
handler(lookup.calculateCellValue(value) || "")
} else {
var dataSource = new _data_source.DataSource(lookup.dataSource);
dataSource.loadSingle(lookup.valueExpr, value).done(function(result) {
result ? handler(lookup.displayExpr ? (0, _data.compileGetter)(lookup.displayExpr)(result) : result) : handler("")
}).fail(function() {
handler("")
})
}
}
function getPrimitiveValueText(field, value, customOperation, target) {
var valueText;
if (true === value) {
valueText = field.trueText || _message2.default.format("dxDataGrid-trueText")
} else {
if (false === value) {
valueText = field.falseText || _message2.default.format("dxDataGrid-falseText")
} else {
valueText = getFormattedValueText(field, value)
}
}
if (field.customizeText) {
valueText = field.customizeText.call(field, {
value: value,
valueText: valueText,
target: target
})
}
if (customOperation && customOperation.customizeText) {
valueText = customOperation.customizeText.call(customOperation, {
value: value,
valueText: valueText,
field: field,
target: target
})
}
return valueText
}
function getArrayValueText(field, value, customOperation, target) {
return value.map(function(v) {
return getPrimitiveValueText(field, v, customOperation, target)
})
}
function checkDefaultValue(value) {
return "" === value || null === value
}
function getCurrentValueText(field, value, customOperation) {
var target = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : "filterBuilder";
if (checkDefaultValue(value)) {
return ""
}
if (Array.isArray(value)) {
var result = new _deferred.Deferred;
_deferred.when.apply(this, getArrayValueText(field, value, customOperation, target)).done(function() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key]
}
var text = args.some(function(item) {
return !checkDefaultValue(item)
}) ? args.map(function(item) {
return !checkDefaultValue(item) ? item : "?"
}) : "";
result.resolve(text)
});
return result
} else {
return getPrimitiveValueText(field, value, customOperation, target)
}
}
function itemExists(plainItems, parentId) {
return plainItems.some(function(item) {
return item.dataField === parentId
})
}
function pushItemAndCheckParent(originalItems, plainItems, item) {
var dataField = item.dataField;
if (hasParent(dataField)) {
item.parentId = getParentIdFromItemDataField(dataField);
if (!itemExists(plainItems, item.parentId) && !itemExists(originalItems, item.parentId)) {
pushItemAndCheckParent(originalItems, plainItems, {
id: item.parentId,
dataType: "object",
dataField: item.parentId,
caption: generateCaptionByDataField(item.parentId, true),
filterOperations: ["isblank", "isnotblank"]
})
}
}
plainItems.push(item)
}
function generateCaptionByDataField(dataField, allowHierarchicalFields) {
var caption = "";
if (allowHierarchicalFields) {
dataField = dataField.substring(dataField.lastIndexOf(".") + 1)
} else {
if (hasParent(dataField)) {
dataField.split(".").forEach(function(field, index, arr) {
caption += _inflector2.default.captionize(field);
if (index !== arr.length - 1) {
caption += "."
}
});
return caption
}
}
return _inflector2.default.captionize(dataField)
}
function getItems(fields, allowHierarchicalFields) {
var items = [];
for (var i = 0; i < fields.length; i++) {
var item = (0, _extend.extend)(true, {
caption: generateCaptionByDataField(fields[i].dataField, allowHierarchicalFields)
}, fields[i]);
item.id = item.name || item.dataField;
if (allowHierarchicalFields) {
pushItemAndCheckParent(fields, items, item)
} else {
items.push(item)
}
}
return items
}
function hasParent(dataField) {
return dataField.lastIndexOf(".") !== -1
}
function getParentIdFromItemDataField(dataField) {
return dataField.substring(0, dataField.lastIndexOf("."))
}
function getCaptionWithParents(item, plainItems) {
if (hasParent(item.dataField)) {
var parentId = getParentIdFromItemDataField(item.dataField);
for (var i = 0; i < plainItems.length; i++) {
if (plainItems[i].dataField === parentId) {
return getCaptionWithParents(plainItems[i], plainItems) + "." + item.caption
}
}
}
return item.caption
}
function updateConditionByOperation(condition, operation, customOperations) {
var customOperation = getCustomOperation(customOperations, operation);
if (customOperation) {
if (false === customOperation.hasValue) {
condition[1] = operation;
condition.length = 2
} else {
condition[1] = operation;
condition[2] = ""
}
return condition
}
if ("isblank" === operation) {
condition[1] = EQUAL_OPERATION;
condition[2] = null
} else {
if ("isnotblank" === operation) {
condition[1] = NOT_EQUAL_OPERATION;
condition[2] = null
} else {
customOperation = getCustomOperation(customOperations, condition[1]);
if (customOperation || 2 === condition.length || null === condition[2]) {
condition[2] = ""
}
condition[1] = operation
}
}
return condition
}
function getOperationValue(condition) {
var caption;
if (null === condition[2]) {
if (condition[1] === EQUAL_OPERATION) {
caption = "isblank"
} else {
caption = "isnotblank"
}
} else {
caption = condition[1]
}
return caption
}
function isValidCondition(condition) {
return "" !== condition[2]
}
function getMergedOperations(customOperations, betweenCaption) {
var result = (0, _extend.extend)(true, [], customOperations),
betweenIndex = -1;
result.some(function(customOperation, index) {
if ("between" === customOperation.name) {
betweenIndex = index;
return true
}
});
if (betweenIndex !== -1) {
result[betweenIndex] = (0, _extend.extend)(_between2.default.getConfig(betweenCaption), result[betweenIndex])
} else {
result.unshift(_between2.default.getConfig(betweenCaption))
}
return result
}
function isMatchedCondition(filter, addedFilterDataField) {
return filter[0] === addedFilterDataField
}
function removeFieldConditionsFromFilter(filter, dataField) {
if (!filter || 0 === filter.length) {
return null
}
if (isCondition(filter)) {
var hasMatchedCondition = isMatchedCondition(filter, dataField);
return !hasMatchedCondition ? filter : null
} else {
return syncConditionIntoGroup(filter, [dataField], false)
}
}
function syncConditionIntoGroup(filter, addedFilter, canPush) {
var result = [];
filter.forEach(function(item) {
if (isCondition(item)) {
if (isMatchedCondition(item, addedFilter[0])) {
if (canPush) {
result.push(addedFilter);
canPush = false
} else {
result.splice(result.length - 1, 1)
}
} else {
result.push(item)
}
} else {
(result.length || isGroup(item)) && result.push(item)
}
});
if (0 === result.length) {
return null
}
if (canPush) {
result.push(AND_GROUP_OPERATION);
result.push(addedFilter)
}
return 1 === result.length ? result[0] : result
}
function syncFilters(filter, addedFilter) {
if (null === filter || 0 === filter.length) {
return addedFilter
}
if (isCondition(filter)) {
if (isMatchedCondition(filter, addedFilter[0])) {
return addedFilter
} else {
return [filter, AND_GROUP_OPERATION, addedFilter]
}
}
var groupValue = getGroupValue(filter);
if (groupValue !== AND_GROUP_OPERATION) {
return [addedFilter, "and", filter]
}
return syncConditionIntoGroup(filter, addedFilter, true)
}
function getMatchedConditions(filter, dataField) {
if (null === filter || 0 === filter.length) {
return []
}
if (isCondition(filter)) {
if (isMatchedCondition(filter, dataField)) {
return [filter]
} else {
return []
}
}
var groupValue = getGroupValue(filter);
if (groupValue !== AND_GROUP_OPERATION) {
return []
}
var result = filter.filter(function(item) {
return isCondition(item) && isMatchedCondition(item, dataField)
});
return result
}
function filterHasField(filter, dataField) {
if (null === filter || 0 === filter.length) {
return false
}
if (isCondition(filter)) {
return filter[0] === dataField
}
return filter.some(function(item) {
return (isCondition(item) || isGroup(item)) && filterHasField(item, dataField)
})
}
exports.isValidCondition = isValidCondition;
exports.isEmptyGroup = isEmptyGroup;
exports.getOperationFromAvailable = getOperationFromAvailable;
exports.updateConditionByOperation = updateConditionByOperation;
exports.getCaptionWithParents = getCaptionWithParents;
exports.getItems = getItems;
exports.setGroupValue = setGroupValue;
exports.getGroupMenuItem = getGroupMenuItem;
exports.getGroupValue = getGroupValue;
exports.getAvailableOperations = getAvailableOperations;
exports.removeItem = removeItem;
exports.createCondition = createCondition;
exports.createEmptyGroup = createEmptyGroup;
exports.addItem = addItem;
exports.getField = getField;
exports.isGroup = isGroup;
exports.isCondition = isCondition;
exports.getNormalizedFields = getNormalizedFields;
exports.getNormalizedFilter = getNormalizedFilter;
exports.getGroupCriteria = getGroupCriteria;
exports.convertToInnerStructure = convertToInnerStructure;
exports.getDefaultOperation = getDefaultOperation;
exports.getCurrentValueText = getCurrentValueText;
exports.getCurrentLookupValueText = getCurrentLookupValueText;
exports.getFilterOperations = getFilterOperations;
exports.getCaptionByOperation = getCaptionByOperation;
exports.getOperationValue = getOperationValue;
exports.getFilterExpression = getFilterExpression;
exports.getCustomOperation = getCustomOperation;
exports.getMergedOperations = getMergedOperations;
exports.syncFilters = syncFilters;
exports.getMatchedConditions = getMatchedConditions;
exports.filterHasField = filterHasField;
exports.removeFieldConditionsFromFilter = removeFieldConditionsFromFilter
},
/*!*******************************************************************************************!*\
!*** ./artifacts/transpiled/ui/scheduler/workspaces/ui.scheduler.work_space.indicator.js ***!
\*******************************************************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var _renderer = __webpack_require__( /*! ../../../core/renderer */ 2);
var _renderer2 = _interopRequireDefault(_renderer);
var _uiScheduler = __webpack_require__( /*! ./ui.scheduler.work_space */ 391);
var _uiScheduler2 = _interopRequireDefault(_uiScheduler);
var _component_registrator = __webpack_require__( /*! ../../../core/component_registrator */ 9);
var _component_registrator2 = _interopRequireDefault(_component_registrator);
var _date = __webpack_require__( /*! ../../../core/utils/date */ 22);
var _date2 = _interopRequireDefault(_date);
var _extend = __webpack_require__( /*! ../../../core/utils/extend */ 0);
var _window = __webpack_require__( /*! ../../../core/utils/window */ 7);
var _window2 = _interopRequireDefault(_window);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
}
}
var toMs = _date2.default.dateToMilliseconds;
var SCHEDULER_DATE_TIME_INDICATOR_CLASS = "dx-scheduler-date-time-indicator",
TIME_PANEL_CURRENT_TIME_CELL_CLASS = "dx-scheduler-time-panel-current-time-cell",
HEADER_CURRENT_TIME_CELL_CLASS = "dx-scheduler-header-panel-current-time-cell";
var SchedulerWorkSpaceIndicator = _uiScheduler2.default.inherit({
_getToday: function() {
var date = this.option("indicatorTime") || new Date;
return this.invoke("convertDateByTimezone", date) || date
},
_needRenderDateTimeIndicator: function() {
var today = this._getToday(),
endViewDate = _date2.default.trimTime(this.getEndViewDate());
return _date2.default.dateInRange(today, this._firstViewDate, new Date(endViewDate.getTime() + toMs("day")))
},
needRenderDateTimeIndication: function() {
if (!_window2.default.hasWindow()) {
return false
}
var today = this._getToday();
return today >= _date2.default.trimTime(new Date(this.getStartViewDate()))
},
_renderDateTimeIndication: function() {
if (this.needRenderDateTimeIndication()) {
if (this.option("shadeUntilCurrentTime")) {
this._shader.render(this)
}
if (this.option("showCurrentTimeIndicator") && this._needRenderDateTimeIndicator()) {
var groupCount = this._getGroupCount() || 1,
$container = this._dateTableScrollable.$content(),
height = this.getIndicationHeight(),
rtlOffset = this._getRtlOffset(this.getCellWidth());
if (height > 0) {
this._renderIndicator(height, rtlOffset, $container, groupCount)
}
}
}
},
_renderIndicator: function(height, rtlOffset, $container, groupCount) {
for (var i = 0; i < groupCount; i++) {
var $indicator = this._createIndicator($container);
$indicator.width(this.getCellWidth());
this._groupedStrategy.shiftIndicator($indicator, height, rtlOffset, i)
}
},
_createIndicator: function($container) {
var $indicator = (0, _renderer2.default)("
").addClass(SCHEDULER_DATE_TIME_INDICATOR_CLASS);
$container.append($indicator);
return $indicator
},
_getRtlOffset: function(width) {
return this.option("rtlEnabled") ? this._dateTableScrollable.$content().get(0).getBoundingClientRect().width - this.getTimePanelWidth() - width : 0
},
_setIndicationUpdateInterval: function() {
if (!this.option("showCurrentTimeIndicator") || 0 === this.option("indicatorUpdateInterval")) {
return
}
this._clearIndicatorUpdateInterval();
this._indicatorInterval = setInterval(function() {
this._refreshDateTimeIndication()
}.bind(this), this.option("indicatorUpdateInterval"))
},
_clearIndicatorUpdateInterval: function() {
if (this._indicatorInterval) {
clearInterval(this._indicatorInterval);
delete this._indicatorInterval
}
},
_isVerticalShader: function() {
return true
},
getIndicationWidth: function(groupIndex) {
var maxWidth = this.getCellWidth() * this._getCellCount();
var difference = this._getIndicatorDuration();
if (difference > this._getCellCount()) {
difference = this._getCellCount()
}
var width = difference * this.getRoundedCellWidth(groupIndex, groupIndex * this._getCellCount(), difference);
return maxWidth < width ? maxWidth : width
},
getIndicatorOffset: function(groupIndex) {
var difference = this._getIndicatorDuration() - 1,
offset = difference * this.getRoundedCellWidth(groupIndex, groupIndex * this._getCellCount(), difference);
return offset
},
_getIndicatorDuration: function() {
var today = this._getToday(),
firstViewDate = new Date(this._firstViewDate);
var timeDiff = today.getTime() - firstViewDate.getTime();
if ("workWeek" === this.option("type")) {
timeDiff -= this._getWeekendsCount(Math.round(timeDiff / toMs("day"))) * toMs("day")
}
return Math.ceil((timeDiff + 1) / toMs("day"))
},
getIndicationHeight: function() {
var today = this._getToday(),
cellHeight = this.getCellHeight(),
date = new Date(this._firstViewDate);
if (this._needRenderDateTimeIndicator()) {
date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate())
}
var duration = today.getTime() - date.getTime(),
cellCount = duration / this.getCellDuration();
return cellCount * cellHeight
},
_dispose: function() {
this._clearIndicatorUpdateInterval();
this.callBase.apply(this, arguments)
},
_refreshDateTimeIndication: function() {
this._cleanDateTimeIndicator();
this._shader && this._shader.clean();
this._renderDateTimeIndication()
},
_isCurrentTime: function(date) {
if (this.option("showCurrentTimeIndicator") && this._needRenderDateTimeIndicator()) {
var today = this._getToday(),
result = false;
date = new Date(date);
date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate());
var startCellDate = new Date(date),
endCellDate = new Date(date);
if (_date2.default.sameDate(today, date)) {
startCellDate = startCellDate.setMilliseconds(date.getMilliseconds() - this.getCellDuration() + 1);
endCellDate = endCellDate.setMilliseconds(date.getMilliseconds() + this.getCellDuration());
result = _date2.default.dateInRange(today, startCellDate, endCellDate)
}
return result
}
},
_isCurrentTimeHeaderCell: function(headerIndex) {
var result = false;
if (this.option("showCurrentTimeIndicator") && this._needRenderDateTimeIndicator()) {
var date = this._getDateByIndex(headerIndex),
now = this.option("indicatorTime") || new Date;
result = _date2.default.sameDate(date, now)
}
return result
},
_getTimeCellClass: function(i) {
var startViewDate = this._getTimeCellDate(i),
cellClass = this.callBase(i);
if (this._isCurrentTime(startViewDate)) {
return cellClass + " " + TIME_PANEL_CURRENT_TIME_CELL_CLASS
}
return cellClass
},
_getHeaderPanelCellClass: function(i) {
var cellClass = this.callBase(i);
if (this._isCurrentTimeHeaderCell(i)) {
return cellClass + " " + HEADER_CURRENT_TIME_CELL_CLASS
}
return cellClass
},
_cleanView: function() {
this.callBase();
this._cleanDateTimeIndicator()
},
_dimensionChanged: function() {
this.callBase();
this._refreshDateTimeIndication()
},
_cleanDateTimeIndicator: function() {
this.$element().find("." + SCHEDULER_DATE_TIME_INDICATOR_CLASS).remove()
},
_cleanWorkSpace: function() {
this.callBase();
this._renderDateTimeIndication();
this._setIndicationUpdateInterval()
},
_optionChanged: function(args) {
switch (args.name) {
case "showCurrentTimeIndicator":
case "indicatorTime":
this._cleanWorkSpace();
break;
case "indicatorUpdateInterval":
this._setIndicationUpdateInterval();
break;
case "showAllDayPanel":
this.callBase(args);
this._refreshDateTimeIndication();
break;
case "allDayExpanded":
this.callBase(args);
this._refreshDateTimeIndication();
break;
case "crossScrollingEnabled":
this.callBase(args);
this._refreshDateTimeIndication();
break;
case "shadeUntilCurrentTime":
this._refreshDateTimeIndication();
break;
default:
this.callBase(args)
}
},
_getDefaultOptions: function() {
return (0, _extend.extend)(this.callBase(), {
showCurrentTimeIndicator: true,
indicatorTime: new Date,
indicatorUpdateInterval: 5 * toMs("minute"),
shadeUntilCurrentTime: true
})
}
});
(0, _component_registrator2.default)("dxSchedulerWorkSpace", SchedulerWorkSpaceIndicator);
module.exports = SchedulerWorkSpaceIndicator
},
/*!************************************************************************!*\
!*** ./artifacts/transpiled/ui/file_manager/ui.file_manager.common.js ***!
\************************************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var _deferred = __webpack_require__( /*! ../../core/utils/deferred */ 6);
var _common = __webpack_require__( /*! ../../core/utils/common */ 4);
var _type = __webpack_require__( /*! ../../core/utils/type */ 1);
var _type2 = _interopRequireDefault(_type);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
}
}
var ErrorCode = {
NoAccess: 0,
FileExists: 1,
FileNotFound: 2,
DirectoryExists: 3,
DirectoryNotFound: 4,
WrongFileExtension: 5,
MaxFileSizeExceeded: 6,
InvalidSymbols: 7,
Other: 32767
};
var whenSome = function(arg, onSuccess, onError) {
onSuccess = onSuccess || _common.noop;
onError = onError || _common.noop;
if (!Array.isArray(arg)) {
arg = [arg]
}
var deferreds = arg.map(function(item, index) {
return (0, _deferred.when)(item).then(function(result) {
_type2.default.isFunction(onSuccess) && onSuccess({
item: item,
index: index,
result: result
});
return result
}, function(error) {
if (!error) {
error = {}
}
error.index = index;
_type2.default.isFunction(onError) && onError(error);
return (new _deferred.Deferred).resolve().promise()
})
});
return _deferred.when.apply(null, deferreds)
};
module.exports = whenSome;
module.exports.ErrorCode = ErrorCode
},
/*!********************************************************!*\
!*** ./artifacts/transpiled/ui/diagram/diagram_bar.js ***!
\********************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) {
descriptor.writable = true
}
Object.defineProperty(target, descriptor.key, descriptor)
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) {
defineProperties(Constructor.prototype, protoProps)
}
if (staticProps) {
defineProperties(Constructor, staticProps)
}
return Constructor
}
}();
var _diagram_importer = __webpack_require__( /*! ./diagram_importer */ 143);
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function")
}
}
var DiagramBar = function() {
function DiagramBar(owner) {
_classCallCheck(this, DiagramBar);
var _getDiagram = (0, _diagram_importer.getDiagram)(),
EventDispatcher = _getDiagram.EventDispatcher;
this.onChanged = new EventDispatcher;
this._owner = owner
}
_createClass(DiagramBar, [{
key: "raiseBarCommandExecuted",
value: function(key, parameter) {
this.onChanged.raise("notifyBarCommandExecuted", parseInt(key), parameter)
}
}, {
key: "getCommandKeys",
value: function() {
throw "Not Implemented"
}
}, {
key: "setItemValue",
value: function(key, value) {}
}, {
key: "setItemEnabled",
value: function(key, enabled) {}
}, {
key: "setItemVisible",
value: function(key, enabled) {}
}, {
key: "setEnabled",
value: function(enabled) {}
}, {
key: "setItemSubItems",
value: function(key, items) {}
}, {
key: "isVisible",
value: function() {
return true
}
}]);
return DiagramBar
}();
module.exports = DiagramBar
},
/*!*******************************************************!*\
!*** ./artifacts/transpiled/viz/components/legend.js ***!
\*******************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var _utils = __webpack_require__( /*! ../core/utils */ 12);
var _extend2 = __webpack_require__( /*! ../../core/utils/extend */ 0);
var _layout_element = __webpack_require__( /*! ../core/layout_element */ 247);
var _type = __webpack_require__( /*! ../../core/utils/type */ 1);
var _title = __webpack_require__( /*! ../core/title */ 106);
var _title2 = _interopRequireDefault(_title);
var _object = __webpack_require__( /*! ../../core/utils/object */ 47);
var _common = __webpack_require__( /*! ../../core/utils/common */ 4);
var _renderer = __webpack_require__( /*! ../core/renderers/renderer */ 158);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
}
}
var _Number = Number,
_math = Math,
_round = _math.round,
_max = _math.max,
_min = _math.min,
_ceil = _math.ceil,
_isDefined = _type.isDefined,
_isFunction = _type.isFunction,
_enumParser = _utils.enumParser,
_normalizeEnum = _utils.normalizeEnum,
_extend = _extend2.extend,
DEFAULT_MARGIN = 10,
DEFAULT_MARKER_HATCHING_WIDTH = 2,
DEFAULT_MARKER_HATCHING_STEP = 5,
CENTER = "center",
RIGHT = "right",
LEFT = "left",
TOP = "top",
BOTTOM = "bottom",
HORIZONTAL = "horizontal",
VERTICAL = "vertical",
INSIDE = "inside",
OUTSIDE = "outside",
NONE = "none",
HEIGHT = "height",
WIDTH = "width",
parseHorizontalAlignment = _enumParser([LEFT, CENTER, RIGHT]),
parseVerticalAlignment = _enumParser([TOP, BOTTOM]),
parseOrientation = _enumParser([VERTICAL, HORIZONTAL]),
parseItemTextPosition = _enumParser([LEFT, RIGHT, TOP, BOTTOM]),
parsePosition = _enumParser([OUTSIDE, INSIDE]),
parseItemsAlignment = _enumParser([LEFT, CENTER, RIGHT]);
function getState(state, color, stateName) {
if (!state) {
return
}
var colorFromAction = state.fill;
return (0, _extend2.extend)({}, {
state: stateName,
fill: colorFromAction === NONE ? color : colorFromAction,
opacity: state.opacity,
hatching: _extend({}, state.hatching, {
step: DEFAULT_MARKER_HATCHING_STEP,
width: DEFAULT_MARKER_HATCHING_WIDTH
})
})
}
function getAttributes(item, state, size) {
var attrs = (0, _renderer.processHatchingAttrs)(item, state);
if (attrs.fill && 0 === attrs.fill.indexOf("DevExpress")) {
attrs.fill = (0, _renderer.getFuncIri)(attrs.fill)
}
attrs.opacity = attrs.opacity >= 0 ? attrs.opacity : 1;
return (0, _extend2.extend)({}, attrs, {
size: size
})
}
function parseMargins(options) {
var margin = options.margin;
if (margin >= 0) {
margin = _Number(options.margin);
margin = {
top: margin,
bottom: margin,
left: margin,
right: margin
}
} else {
margin = {
top: margin.top >= 0 ? _Number(margin.top) : DEFAULT_MARGIN,
bottom: margin.bottom >= 0 ? _Number(margin.bottom) : DEFAULT_MARGIN,
left: margin.left >= 0 ? _Number(margin.left) : DEFAULT_MARGIN,
right: margin.right >= 0 ? _Number(margin.right) : DEFAULT_MARGIN
}
}
options.margin = margin
}
function getSizeItem(options, markerBBox, labelBBox) {
var width, height, defaultXMargin = 7,
defaultTopMargin = 4;
switch (options.itemTextPosition) {
case LEFT:
case RIGHT:
width = markerBBox.width + defaultXMargin + labelBBox.width;
height = _max(markerBBox.height, labelBBox.height);
break;
case TOP:
case BOTTOM:
width = _max(markerBBox.width, labelBBox.width);
height = markerBBox.height + defaultTopMargin + labelBBox.height
}
return {
width: width,
height: height
}
}
function calculateBBoxLabelAndMarker(markerBBox, labelBBox) {
var bBox = {};
bBox.left = _min(markerBBox.x, labelBBox.x);
bBox.top = _min(markerBBox.y, labelBBox.y);
bBox.right = _max(markerBBox.x + markerBBox.width, labelBBox.x + labelBBox.width);
bBox.bottom = _max(markerBBox.y + markerBBox.height, labelBBox.y + labelBBox.height);
return bBox
}
function applyMarkerState(id, idToIndexMap, items, stateName) {
var item = idToIndexMap && items[idToIndexMap[id]];
if (item) {
item.renderMarker(item.states[stateName])
}
}
function parseOptions(options, textField, allowInsidePosition) {
if (!options) {
return null
}
var debug = __webpack_require__( /*! ../../core/utils/console */ 65).debug;
debug.assertParam(options.visible, "Visibility was not passed");
debug.assertParam(options.markerSize, "markerSize was not passed");
debug.assertParam(options.font.color, "fontColor was not passed");
debug.assertParam(options.font.family, "fontFamily was not passed");
debug.assertParam(options.font.size, "fontSize was not passed");
debug.assertParam(options.paddingLeftRight, "paddingLeftRight was not passed");
debug.assertParam(options.paddingTopBottom, "paddingTopBottom was not passed");
debug.assertParam(options.columnItemSpacing, "columnItemSpacing was not passed");
debug.assertParam(options.rowItemSpacing, "rowItemSpacing was not passed");
parseMargins(options);
options.horizontalAlignment = parseHorizontalAlignment(options.horizontalAlignment, RIGHT);
options.verticalAlignment = parseVerticalAlignment(options.verticalAlignment, options.horizontalAlignment === CENTER ? BOTTOM : TOP);
options.orientation = parseOrientation(options.orientation, options.horizontalAlignment === CENTER ? HORIZONTAL : VERTICAL);
options.itemTextPosition = parseItemTextPosition(options.itemTextPosition, options.orientation === HORIZONTAL ? BOTTOM : RIGHT);
options.position = allowInsidePosition ? parsePosition(options.position, OUTSIDE) : OUTSIDE;
options.itemsAlignment = parseItemsAlignment(options.itemsAlignment, null);
options.hoverMode = _normalizeEnum(options.hoverMode);
options.customizeText = _isFunction(options.customizeText) ? options.customizeText : function() {
return this[textField]
};
options.customizeHint = _isFunction(options.customizeHint) ? options.customizeHint : _common.noop;
options._incidentOccurred = options._incidentOccurred || _common.noop;
return options
}
function createSquareMarker(renderer, size) {
return renderer.rect(0, 0, size, size)
}
function createCircleMarker(renderer, size) {
return renderer.circle(size / 2, size / 2, size / 2)
}
function isCircle(type) {
return "circle" === _normalizeEnum(type)
}
function inRect(rect, x, y) {
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom
}
function checkLinesSize(lines, layoutOptions, countItems, margins) {
var position = {
x: 0,
y: 0
},
maxMeasureLength = 0,
maxAltMeasureLength = 0,
margin = 0;
if ("y" === layoutOptions.direction) {
margin = margins.top + margins.bottom
} else {
margin = margins.left + margins.right
}
lines.forEach(function(line, i) {
var firstItem = line[0],
lineLength = line.length;
line.forEach(function(item, index) {
var offset = item.offset || layoutOptions.spacing;
position[layoutOptions.direction] += item[layoutOptions.measure] + (index !== lineLength - 1 ? offset : 0);
maxMeasureLength = _max(maxMeasureLength, position[layoutOptions.direction])
});
position[layoutOptions.direction] = 0;
position[layoutOptions.altDirection] += firstItem[layoutOptions.altMeasure] + firstItem.altOffset || layoutOptions.altSpacing;
maxAltMeasureLength = _max(maxAltMeasureLength, position[layoutOptions.altDirection])
});
if (maxMeasureLength + margin > layoutOptions.length) {
layoutOptions.countItem = decreaseItemCount(layoutOptions, countItems);
return true
}
}
function decreaseItemCount(layoutOptions, countItems) {
layoutOptions.altCountItem++;
return _ceil(countItems / layoutOptions.altCountItem)
}
function getLineLength(line, layoutOptions) {
return line.reduce(function(lineLength, item) {
var offset = item.offset || layoutOptions.spacing;
return lineLength + item[layoutOptions.measure] + offset
}, 0)
}
function getMaxLineLength(lines, layoutOptions) {
return lines.reduce(function(maxLineLength, line) {
return _max(maxLineLength, getLineLength(line, layoutOptions))
}, 0)
}
function getInitPositionForDirection(line, layoutOptions, maxLineLength) {
var initPosition, lineLength = getLineLength(line, layoutOptions);
switch (layoutOptions.itemsAlignment) {
case RIGHT:
initPosition = maxLineLength - lineLength;
break;
case CENTER:
initPosition = (maxLineLength - lineLength) / 2;
break;
default:
initPosition = 0
}
return initPosition
}
function getPos(layoutOptions) {
switch (layoutOptions.itemTextPosition) {
case BOTTOM:
return {
horizontal: CENTER, vertical: TOP
};
case TOP:
return {
horizontal: CENTER, vertical: BOTTOM
};
case LEFT:
return {
horizontal: RIGHT, vertical: CENTER
};
case RIGHT:
return {
horizontal: LEFT, vertical: CENTER
}
}
}
function getLines(lines, layoutOptions, itemIndex) {
var tableLine = {};
if (itemIndex % layoutOptions.countItem === 0) {
if (layoutOptions.markerOffset) {
lines.push([], [])
} else {
lines.push([])
}
}
if (layoutOptions.markerOffset) {
tableLine.firstLine = lines[lines.length - 1];
tableLine.secondLine = lines[lines.length - 2]
} else {
tableLine.firstLine = tableLine.secondLine = lines[lines.length - 1]
}
return tableLine
}
function setMaxInLine(line, measure) {
var maxLineSize = line.reduce(function(maxLineSize, item) {
var itemMeasure = item ? item[measure] : maxLineSize;
return _max(maxLineSize, itemMeasure)
}, 0);
line.forEach(function(item) {
if (item) {
item[measure] = maxLineSize
}
})
}
function transpose(array) {
var i, j, width = array.length,
height = array[0].length,
transposeArray = [];
for (i = 0; i < height; i++) {
transposeArray[i] = [];
for (j = 0; j < width; j++) {
transposeArray[i][j] = array[j][i]
}
}
return transposeArray
}
function getAlign(position) {
switch (position) {
case TOP:
case BOTTOM:
return CENTER;
case LEFT:
return RIGHT;
case RIGHT:
return LEFT
}
}
var getMarkerCreator = function(type) {
return isCircle(type) ? createCircleMarker : createSquareMarker
};
function getTitleHorizontalAlignment(options) {
if (options.horizontalAlignment === CENTER) {
return CENTER
} else {
if (options.itemTextPosition === RIGHT) {
return LEFT
} else {
if (options.itemTextPosition === LEFT) {
return RIGHT
} else {
return CENTER
}
}
}
}
var _Legend = exports.Legend = function(settings) {
var that = this;
that._renderer = settings.renderer;
that._legendGroup = settings.group;
that._backgroundClass = settings.backgroundClass;
that._itemGroupClass = settings.itemGroupClass;
that._textField = settings.textField;
that._getCustomizeObject = settings.getFormatObject;
that._titleGroupClass = settings.titleGroupClass;
that._allowInsidePosition = settings.allowInsidePosition;
that._widget = settings.widget
};
var legendPrototype = _Legend.prototype = (0, _object.clone)(_layout_element.LayoutElement.prototype);
(0, _extend2.extend)(legendPrototype, {
constructor: _Legend,
getOptions: function() {
return this._options
},
update: function() {
var data = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [];
var options = arguments[1];
var themeManagerTitleOptions = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
var that = this;
options = that._options = parseOptions(options, that._textField, that._allowInsidePosition) || {};
var initMarkerSize = options.markerSize;
this._data = data.map(function(dataItem) {
dataItem.size = _Number(dataItem.size > 0 ? dataItem.size : initMarkerSize);
dataItem.marker = getAttributes(dataItem, dataItem.states.normal);
Object.defineProperty(dataItem.marker, "size", {
get: function() {
return dataItem.size
},
set: function(value) {
dataItem.size = value
}
});
Object.defineProperty(dataItem.marker, "opacity", {
get: function() {
return dataItem.states.normal.opacity
},
set: function(value) {
dataItem.states.normal.opacity = dataItem.states.hover.opacity = dataItem.states.selection.opacity = value
}
});
return dataItem
});
if (options.customizeItems) {
that._data = options.customizeItems(data.slice()) || data
}
that._boundingRect = {
width: 0,
height: 0,
x: 0,
y: 0
};
if (that.isVisible() && !that._title) {
that._title = new _title2.default.Title({
renderer: that._renderer,
cssClass: that._titleGroupClass,
root: that._legendGroup
})
}
if (that._title) {
var titleOptions = options.title;
themeManagerTitleOptions.horizontalAlignment = getTitleHorizontalAlignment(options);
that._title.update(themeManagerTitleOptions, titleOptions)
}
this.erase();
return that
},
isVisible: function() {
return this._options && this._options.visible
},
draw: function(width, height) {
var that = this,
options = that._options,
items = that._getItemData();
that._size = {
width: width,
height: height
};
that.erase();
if (!(that.isVisible() && items && items.length)) {
return that
}
that._insideLegendGroup = that._renderer.g().enableLinks().append(that._legendGroup);
that._title.changeLink(that._insideLegendGroup);
that._createBackground();
if (that._title.hasText()) {
var horizontalPadding = that._background ? 2 * that._options.paddingLeftRight : 0;
that._title.draw(width - horizontalPadding, height)
}
that._markersGroup = that._renderer.g().attr({
"class": that._itemGroupClass
}).append(that._insideLegendGroup);
that._createItems(items);
that._locateElements(options);
that._finalUpdate(options);
var size = that.getLayoutOptions();
if (size.width > width || size.height > height) {
that.freeSpace()
}
return that
},
probeDraw: function(width, height) {
return this.draw(width, height)
},
_createItems: function(items) {
var that = this,
options = that._options,
renderer = that._renderer,
maxBBoxHeight = 0,
createMarker = getMarkerCreator(options.markerShape);
that._markersId = {};
var templateFunction = !options.markerTemplate ? function(dataItem, group) {
var attrs = dataItem.marker;
createMarker(renderer, attrs.size).attr({
fill: attrs.fill,
opacity: attrs.opacity
}).append({
element: group
})
} : options.markerTemplate;
var template = that._widget._getTemplate(templateFunction);
var markersGroup = that._markersGroup;
markersGroup.css((0, _utils.patchFontOptions)(options.font));
that._items = (items || []).map(function(dataItem, i) {
var stateOfDataItem = dataItem.states;
var normalState = stateOfDataItem.normal;
var normalStateFill = normalState.fill;
dataItem.size = dataItem.marker.size;
var states = {
normal: (0, _extend2.extend)(normalState, {
fill: normalStateFill || options.markerColor || options.defaultColor,
state: "normal"
}),
hover: getState(stateOfDataItem.hover, normalStateFill, "hovered"),
selection: getState(stateOfDataItem.selection, normalStateFill, "selected")
};
dataItem.states = states;
var itemGroup = renderer.g().append(markersGroup);
var markerGroup = renderer.g().attr({
"class": "dxl-marker"
}).append(itemGroup);
var item = {
label: that._createLabel(dataItem, itemGroup),
marker: markerGroup,
renderer: renderer,
group: itemGroup,
tracker: {
id: dataItem.id,
argument: dataItem.argument,
argumentIndex: dataItem.argumentIndex
},
states: states,
itemTextPosition: options.itemTextPosition,
markerOffset: 0,
bBoxes: [],
renderMarker: function(state) {
dataItem.marker = getAttributes(item, state, dataItem.size);
markerGroup.clear();
var isRendered = false;
template.render({
model: dataItem,
container: markerGroup.element,
onRendered: function() {
isRendered = true;
if (isAsyncRendering) {
that._widget._requestChange(["LAYOUT"])
}
}
});
var isAsyncRendering = !isRendered && 0 === markerGroup.element.childNodes.length
}
};
item.renderMarker(states.normal);
that._createHint(dataItem, itemGroup);
if (void 0 !== dataItem.id) {
that._markersId[dataItem.id] = i
}
return item
}).map(function(item) {
var labelBBox = item.label.getBBox();
var markerBBox = item.marker.getBBox();
item.markerBBox = markerBBox;
item.markerSize = Math.max(markerBBox.width, markerBBox.height);
var bBox = getSizeItem(options, markerBBox, labelBBox);
item.labelBBox = labelBBox;
item.bBox = bBox;
maxBBoxHeight = _max(maxBBoxHeight, bBox.height);
return item
});
if (options.equalRowHeight) {
that._items.forEach(function(item) {
return item.bBox.height = maxBBoxHeight
})
}
},
_getItemData: function() {
var items = this._data || [];
var options = this._options || {};
if (options.inverted) {
items = items.slice().reverse()
}
return items.filter(function(i) {
return i.visible
})
},
_finalUpdate: function(options) {
this._adjustBackgroundSettings(options);
this._setBoundingRect(options.margin)
},
erase: function() {
var that = this,
insideLegendGroup = that._insideLegendGroup;
insideLegendGroup && insideLegendGroup.dispose();
that._insideLegendGroup = that._markersGroup = that._x1 = that._x2 = that._y2 = that._y2 = null;
return that
},
_locateElements: function(locationOptions) {
this._moveInInitialValues();
this._locateRowsColumns(locationOptions)
},
_moveInInitialValues: function() {
var that = this;
that._title.hasText() && that._title.move([0, 0]);
that._legendGroup && that._legendGroup.move(0, 0);
that._background && that._background.attr({
x: 0,
y: 0,
width: 0,
height: 0
})
},
applySelected: function(id) {
applyMarkerState(id, this._markersId, this._items, "selection");
return this
},
applyHover: function(id) {
applyMarkerState(id, this._markersId, this._items, "hover");
return this
},
resetItem: function(id) {
applyMarkerState(id, this._markersId, this._items, "normal");
return this
},
_createLabel: function(data, group) {
var labelFormatObject = this._getCustomizeObject(data);
var options = this._options;
var align = getAlign(options.itemTextPosition);
var text = options.customizeText.call(labelFormatObject, labelFormatObject);
var fontStyle = _isDefined(data.textOpacity) ? {
color: options.font.color,
opacity: data.textOpacity
} : {};
return this._renderer.text(text, 0, 0).css((0, _utils.patchFontOptions)(fontStyle)).attr({
align: align,
"class": options.cssClass
}).append(group)
},
_createHint: function(data, group) {
var labelFormatObject = this._getCustomizeObject(data),
text = this._options.customizeHint.call(labelFormatObject, labelFormatObject);
if (_isDefined(text) && "" !== text) {
group.setTitle(text)
}
},
_createBackground: function() {
var that = this,
isInside = that._options.position === INSIDE,
color = that._options.backgroundColor,
fill = color || (isInside ? that._options.containerBackgroundColor : NONE);
if (that._options.border.visible || (isInside || color) && color !== NONE) {
that._background = that._renderer.rect(0, 0, 0, 0).attr({
fill: fill,
"class": that._backgroundClass
}).append(that._insideLegendGroup)
}
},
_locateRowsColumns: function(options) {
var lines, that = this,
iteration = 0,
layoutOptions = that._getItemsLayoutOptions(),
countItems = that._items.length;
do {
lines = [];
that._createLines(lines, layoutOptions);
that._alignLines(lines, layoutOptions);
iteration++
} while (checkLinesSize(lines, layoutOptions, countItems, options.margin) && iteration < countItems);
that._applyItemPosition(lines, layoutOptions)
},
_createLines: function(lines, layoutOptions) {
this._items.forEach(function(item, i) {
var firstItem, secondItem, tableLine = getLines(lines, layoutOptions, i),
labelBox = {
width: item.labelBBox.width,
height: item.labelBBox.height,
element: item.label,
bBox: item.labelBBox,
pos: getPos(layoutOptions),
itemIndex: i
},
markerBox = {
width: item.markerBBox.width,
height: item.markerBBox.height,
element: item.marker,
pos: {
horizontal: CENTER,
vertical: CENTER
},
bBox: {
width: item.markerBBox.width,
height: item.markerBBox.height,
x: item.markerBBox.x,
y: item.markerBBox.y
},
itemIndex: i
},
offsetDirection = layoutOptions.markerOffset ? "altOffset" : "offset";
if (layoutOptions.inverseLabelPosition) {
firstItem = labelBox;
secondItem = markerBox
} else {
firstItem = markerBox;
secondItem = labelBox
}
firstItem[offsetDirection] = layoutOptions.labelOffset;
tableLine.secondLine.push(firstItem);
tableLine.firstLine.push(secondItem)
})
},
_alignLines: function(lines, layoutOptions) {
var i, measure = layoutOptions.altMeasure;
lines.forEach(function(line) {
return setMaxInLine(line, measure)
});
measure = layoutOptions.measure;
if (layoutOptions.itemsAlignment) {
if (layoutOptions.markerOffset) {
for (i = 0; i < lines.length;) {
transpose([lines[i++], lines[i++]]).forEach(processLine)
}
}
} else {
transpose(lines).forEach(processLine)
}
function processLine(line) {
setMaxInLine(line, measure)
}
},
_applyItemPosition: function(lines, layoutOptions) {
var that = this,
position = {
x: 0,
y: 0
},
maxLineLength = getMaxLineLength(lines, layoutOptions);
lines.forEach(function(line) {
var firstItem = line[0],
altOffset = firstItem.altOffset || layoutOptions.altSpacing;
position[layoutOptions.direction] = getInitPositionForDirection(line, layoutOptions, maxLineLength);
line.forEach(function(item) {
var offset = item.offset || layoutOptions.spacing,
wrap = new _layout_element.WrapperLayoutElement(item.element, item.bBox),
itemBBoxOptions = {
x: position.x,
y: position.y,
width: item.width,
height: item.height
},
itemBBox = new _layout_element.WrapperLayoutElement(null, itemBBoxOptions),
itemLegend = that._items[item.itemIndex];
wrap.position({
of: itemBBox,
my: item.pos,
at: item.pos
});
itemLegend.bBoxes.push(itemBBox);
position[layoutOptions.direction] += item[layoutOptions.measure] + offset
});
position[layoutOptions.altDirection] += firstItem[layoutOptions.altMeasure] + altOffset
});
this._items.forEach(function(item) {
var itemBBox = calculateBBoxLabelAndMarker(item.bBoxes[0].getLayoutOptions(), item.bBoxes[1].getLayoutOptions()),
horizontal = that._options.columnItemSpacing / 2,
vertical = that._options.rowItemSpacing / 2;
item.tracker.left = itemBBox.left - horizontal;
item.tracker.right = itemBBox.right + horizontal;
item.tracker.top = itemBBox.top - vertical;
item.tracker.bottom = itemBBox.bottom + vertical
})
},
_getItemsLayoutOptions: function() {
var that = this,
options = that._options,
orientation = options.orientation,
layoutOptions = {
itemsAlignment: options.itemsAlignment,
orientation: options.orientation
},
width = that._size.width - (that._background ? 2 * options.paddingLeftRight : 0),
height = that._size.height - (that._background ? 2 * options.paddingTopBottom : 0);
if (orientation === HORIZONTAL) {
layoutOptions.length = width;
layoutOptions.spacing = options.columnItemSpacing;
layoutOptions.direction = "x";
layoutOptions.measure = WIDTH;
layoutOptions.altMeasure = HEIGHT;
layoutOptions.altDirection = "y";
layoutOptions.altSpacing = options.rowItemSpacing;
layoutOptions.countItem = options.columnCount;
layoutOptions.altCountItem = options.rowCount;
layoutOptions.marginTextLabel = 4;
layoutOptions.labelOffset = 7;
if (options.itemTextPosition === BOTTOM || options.itemTextPosition === TOP) {
layoutOptions.labelOffset = 4;
layoutOptions.markerOffset = true
}
} else {
layoutOptions.length = height;
layoutOptions.spacing = options.rowItemSpacing;
layoutOptions.direction = "y";
layoutOptions.measure = HEIGHT;
layoutOptions.altMeasure = WIDTH;
layoutOptions.altDirection = "x";
layoutOptions.altSpacing = options.columnItemSpacing;
layoutOptions.countItem = options.rowCount;
layoutOptions.altCountItem = options.columnCount;
layoutOptions.marginTextLabel = 7;
layoutOptions.labelOffset = 4;
if (options.itemTextPosition === RIGHT || options.itemTextPosition === LEFT) {
layoutOptions.labelOffset = 7;
layoutOptions.markerOffset = true
}
}
if (!layoutOptions.countItem) {
if (layoutOptions.altCountItem) {
layoutOptions.countItem = _ceil(that._items.length / layoutOptions.altCountItem)
} else {
layoutOptions.countItem = that._items.length
}
}
if (options.itemTextPosition === TOP || options.itemTextPosition === LEFT) {
layoutOptions.inverseLabelPosition = true
}
layoutOptions.itemTextPosition = options.itemTextPosition;
layoutOptions.altCountItem = layoutOptions.altCountItem || _ceil(that._items.length / layoutOptions.countItem);
return layoutOptions
},
_adjustBackgroundSettings: function(locationOptions) {
if (!this._background) {
return
}
var border = locationOptions.border,
legendBox = this._calculateTotalBox(),
backgroundSettings = {
x: _round(legendBox.x - locationOptions.paddingLeftRight),
y: _round(legendBox.y - locationOptions.paddingTopBottom),
width: _round(legendBox.width) + 2 * locationOptions.paddingLeftRight,
height: _round(legendBox.height),
opacity: locationOptions.backgroundOpacity
};
if (border.visible && border.width && border.color && border.color !== NONE) {
backgroundSettings["stroke-width"] = border.width;
backgroundSettings.stroke = border.color;
backgroundSettings["stroke-opacity"] = border.opacity;
backgroundSettings.dashStyle = border.dashStyle;
backgroundSettings.rx = border.cornerRadius || 0;
backgroundSettings.ry = border.cornerRadius || 0
}
this._background.attr(backgroundSettings)
},
_setBoundingRect: function(margin) {
if (!this._insideLegendGroup) {
return
}
var box = this._calculateTotalBox();
box.height += margin.top + margin.bottom;
box.widthWithoutMargins = box.width;
box.width += margin.left + margin.right;
box.x -= margin.left;
box.y -= margin.top;
this._boundingRect = box
},
_calculateTotalBox: function() {
var markerBox = this._markersGroup.getBBox();
var titleBox = this._title.getCorrectedLayoutOptions();
var box = this._insideLegendGroup.getBBox();
var verticalPadding = this._background ? 2 * this._options.paddingTopBottom : 0;
box.height = markerBox.height + titleBox.height + verticalPadding;
titleBox.width > box.width && (box.width = titleBox.width);
return box
},
getActionCallback: function(point) {
var that = this;
if (that._options.visible) {
return function(act) {
that[act](point.index)
}
} else {
return _common.noop
}
},
getLayoutOptions: function() {
var options = this._options,
boundingRect = this._insideLegendGroup ? this._boundingRect : {
width: 0,
height: 0,
x: 0,
y: 0
};
if (options) {
boundingRect.verticalAlignment = options.verticalAlignment;
boundingRect.horizontalAlignment = options.horizontalAlignment;
if (options.orientation === HORIZONTAL) {
boundingRect.cutLayoutSide = options.verticalAlignment;
boundingRect.cutSide = "vertical"
} else {
if (options.horizontalAlignment === CENTER) {
boundingRect.cutLayoutSide = options.verticalAlignment;
boundingRect.cutSide = "vertical"
} else {
boundingRect.cutLayoutSide = options.horizontalAlignment;
boundingRect.cutSide = "horizontal"
}
}
boundingRect.position = {
horizontal: options.horizontalAlignment,
vertical: options.verticalAlignment
};
return boundingRect
}
return null
},
shift: function(x, y) {
var that = this,
box = {};
if (that._insideLegendGroup) {
that._insideLegendGroup.attr({
translateX: x - that._boundingRect.x,
translateY: y - that._boundingRect.y
})
}
that._title && that._shiftTitle(that._boundingRect.widthWithoutMargins);
that._markersGroup && that._shiftMarkers();
if (that._insideLegendGroup) {
box = that._legendGroup.getBBox()
}
that._x1 = box.x;
that._y1 = box.y;
that._x2 = box.x + box.width;
that._y2 = box.y + box.height;
return that
},
_shiftTitle: function(boxWidth) {
var that = this;
var title = that._title;
var titleBox = title.getCorrectedLayoutOptions();
if (!titleBox || !title.hasText()) {
return
}
var width = boxWidth - (that._background ? 2 * that._options.paddingLeftRight : 0);
var titleOptions = title.getOptions();
var titleY = titleBox.y + titleOptions.margin.top;
var titleX = 0;
if (titleOptions.verticalAlignment === BOTTOM) {
titleY += that._markersGroup.getBBox().height
}
if (titleOptions.horizontalAlignment === RIGHT) {
titleX = width - titleBox.width
} else {
if (titleOptions.horizontalAlignment === CENTER) {
titleX = (width - titleBox.width) / 2
}
}
title.shift(titleX, titleY)
},
_shiftMarkers: function() {
var titleBox = this._title.getLayoutOptions();
var markerBox = this._markersGroup.getBBox();
var titleOptions = this._title.getOptions() || {};
var center = 0;
var y = 0;
if (titleBox.width > markerBox.width && this._options.horizontalAlignment === CENTER) {
center = titleBox.width / 2 - markerBox.width / 2
}
if (titleOptions.verticalAlignment === TOP) {
y = titleBox.height
}
if (0 !== center || 0 !== y) {
this._markersGroup.attr({
translateX: center,
translateY: y
});
this._items.forEach(function(item) {
item.tracker.left += center;
item.tracker.right += center;
item.tracker.top += y;
item.tracker.bottom += y
})
}
},
getPosition: function() {
return this._options.position
},
coordsIn: function(x, y) {
return x >= this._x1 && x <= this._x2 && y >= this._y1 && y <= this._y2
},
getItemByCoord: function(x, y) {
var items = this._items,
legendGroup = this._insideLegendGroup;
x -= legendGroup.attr("translateX");
y -= legendGroup.attr("translateY");
for (var i = 0; i < items.length; i++) {
if (inRect(items[i].tracker, x, y)) {
return items[i].tracker
}
}
return null
},
dispose: function() {
var that = this;
that._title && that._title.dispose();
that._legendGroup = that._insideLegendGroup = that._title = that._renderer = that._options = that._data = that._items = null;
return that
},
layoutOptions: function() {
if (!this.isVisible()) {
return null
}
var pos = this.getLayoutOptions();
return {
horizontalAlignment: this._options.horizontalAlignment,
verticalAlignment: this._options.verticalAlignment,
side: pos.cutSide,
priority: 1,
position: this.getPosition()
}
},
measure: function(size) {
this.draw(size[0], size[1]);
var rect = this.getLayoutOptions();
return [rect.width, rect.height]
},
move: function(rect) {
this.shift(rect[0], rect[1])
},
freeSpace: function() {
this._options._incidentOccurred("W2104");
this.erase()
}
});
exports.plugin = {
name: "legend",
init: function() {
var that = this,
group = this._renderer.g().attr({
"class": this._rootClassPrefix + "-legend"
}).enableLinks().append(that._renderer.root);
that._legend = new exports.Legend({
renderer: that._renderer,
group: group,
widget: this,
itemGroupClass: this._rootClassPrefix + "-item",
titleGroupClass: this._rootClassPrefix + "-title",
textField: "text",
getFormatObject: function(data) {
return {
item: data.item,
text: data.text
}
}
});
that._layout.add(that._legend)
},
extenders: {
_applyTilesAppearance: function() {
var that = this;
this._items.forEach(function(item) {
that._applyLegendItemStyle(item.id, item.getState())
})
},
_buildNodes: function() {
this._createLegendItems()
}
},
members: {
_applyLegendItemStyle: function(id, state) {
var legend = this._legend;
switch (state) {
case "hover":
legend.applyHover(id);
break;
case "selection":
legend.applySelected(id);
break;
default:
legend.resetItem(id)
}
},
_createLegendItems: function() {
if (this._legend.update(this._getLegendData(), this._getOption("legend"), this._themeManager.theme("legend").title)) {
this._requestChange(["LAYOUT"])
}
}
},
dispose: function() {
this._legend.dispose()
},
customize: function(constructor) {
constructor.prototype._proxyData.push(function(x, y) {
if (this._legend.coordsIn(x, y)) {
var item = this._legend.getItemByCoord(x, y);
if (item) {
return {
id: item.id,
type: "legend"
}
}
}
});
constructor.addChange({
code: "LEGEND",
handler: function() {
this._createLegendItems()
},
isThemeDependent: true,
option: "legend",
isOptionChange: true
})
}
};
var __getMarkerCreator = getMarkerCreator;
exports._DEBUG_stubMarkerCreator = function(callback) {
getMarkerCreator = function() {
return callback
}
};
exports._DEBUG_restoreMarkerCreator = function() {
getMarkerCreator = __getMarkerCreator
}
},
/*!*************************************************************!*\
!*** ./artifacts/transpiled/viz/series/points/bar_point.js ***!
\*************************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var extend = __webpack_require__( /*! ../../../core/utils/extend */ 0).extend,
_extend = extend,
_math = Math,
_floor = _math.floor,
_abs = _math.abs,
symbolPoint = __webpack_require__( /*! ./symbol_point */ 120),
CANVAS_POSITION_DEFAULT = "canvas_position_default",
DEFAULT_BAR_TRACKER_SIZE = 9,
CORRECTING_BAR_TRACKER_VALUE = 4,
RIGHT = "right",
LEFT = "left",
TOP = "top",
BOTTOM = "bottom";
module.exports = _extend({}, symbolPoint, {
correctCoordinates: function(correctOptions) {
var that = this;
var correction = _floor(correctOptions.offset - correctOptions.width / 2);
if (that._options.rotated) {
that.height = correctOptions.width;
that.yCorrection = correction;
that.xCorrection = null
} else {
that.width = correctOptions.width;
that.xCorrection = correction;
that.yCorrection = null
}
},
_getGraphicBBox: function() {
return {
x: this.x,
y: this.y,
width: this.width,
height: this.height
}
},
_getLabelConnector: function(location) {
return this._getGraphicBBox(location)
},
_getLabelPosition: function() {
var position, that = this,
initialValue = that.initialValue,
invert = that._getValTranslator().getBusinessRange().invert,
isDiscreteValue = "discrete" === that.series.valueAxisType,
isFullStacked = that.series.isFullStackedSeries(),
notAxisInverted = !isDiscreteValue && (initialValue >= 0 && !invert || initialValue < 0 && invert) || isDiscreteValue && !invert || isFullStacked;
if (!that._options.rotated) {
position = notAxisInverted ? TOP : BOTTOM
} else {
position = notAxisInverted ? RIGHT : LEFT
}
return position
},
_getLabelCoords: function(label) {
var coords, that = this;
if (0 === that.initialValue && that.series.isFullStackedSeries()) {
if (!this._options.rotated) {
coords = that._getLabelCoordOfPosition(label, TOP)
} else {
coords = that._getLabelCoordOfPosition(label, RIGHT)
}
} else {
if ("inside" === label.getLayoutOptions().position) {
coords = that._getLabelCoordOfPosition(label, "inside")
} else {
coords = symbolPoint._getLabelCoords.call(this, label)
}
}
return coords
},
_checkLabelPosition: function(label, coord) {
var that = this,
visibleArea = that._getVisibleArea();
if (that._isPointInVisibleArea(visibleArea, that._getGraphicBBox())) {
return that._moveLabelOnCanvas(coord, visibleArea, label.getBoundingRect())
}
return coord
},
hideInsideLabel: function(label, coord) {
var graphicBBox = this._getGraphicBBox(),
labelBBox = label.getBoundingRect();
if (this._options.resolveLabelsOverlapping) {
if ((coord.y <= graphicBBox.y && coord.y + labelBBox.height >= graphicBBox.y + graphicBBox.height || coord.x <= graphicBBox.x && coord.x + labelBBox.width >= graphicBBox.x + graphicBBox.width) && !(coord.y > graphicBBox.y + graphicBBox.height || coord.y + labelBBox.height < graphicBBox.y || coord.x > graphicBBox.x + graphicBBox.width || coord.x + labelBBox.width < graphicBBox.x)) {
label.draw(false);
return true
}
}
return false
},
_moveLabelOnCanvas: function(coord, visibleArea, labelBBox) {
var x = coord.x,
y = coord.y;
if (visibleArea.minX > x) {
x = visibleArea.minX
}
if (visibleArea.maxX < x + labelBBox.width) {
x = visibleArea.maxX - labelBBox.width
}
if (visibleArea.minY > y) {
y = visibleArea.minY
}
if (visibleArea.maxY < y + labelBBox.height) {
y = visibleArea.maxY - labelBBox.height
}
return {
x: x,
y: y
}
},
_showForZeroValues: function() {
return this._options.label.showForZeroValues || this.initialValue
},
_drawMarker: function(renderer, group, animationEnabled) {
var that = this;
var style = that._getStyle();
var r = that._options.cornerRadius;
var rotated = that._options.rotated;
var _that$getMarkerCoords = that.getMarkerCoords(),
x = _that$getMarkerCoords.x,
y = _that$getMarkerCoords.y,
width = _that$getMarkerCoords.width,
height = _that$getMarkerCoords.height;
if (animationEnabled) {
if (rotated) {
width = 0;
x = that.defaultX
} else {
height = 0;
y = that.defaultY
}
}
that.graphic = renderer.rect(x, y, width, height).attr({
rx: r,
ry: r
}).smartAttr(style).data({
"chart-data-point": that
}).append(group)
},
_getSettingsForTracker: function() {
var that = this,
y = that.y,
height = that.height,
x = that.x,
width = that.width;
if (that._options.rotated) {
if (1 === width) {
width = DEFAULT_BAR_TRACKER_SIZE;
x -= CORRECTING_BAR_TRACKER_VALUE
}
} else {
if (1 === height) {
height = DEFAULT_BAR_TRACKER_SIZE;
y -= CORRECTING_BAR_TRACKER_VALUE
}
}
return {
x: x,
y: y,
width: width,
height: height
}
},
getGraphicSettings: function() {
var graphic = this.graphic;
return {
x: graphic.attr("x"),
y: graphic.attr("y"),
height: graphic.attr("height"),
width: graphic.attr("width")
}
},
_getEdgeTooltipParams: function() {
var isPositive = this.value >= 0;
var xCoord = void 0;
var yCoord = void 0;
var invertedBusinessRange = this._getValTranslator().getBusinessRange().invert;
var x = this.x,
y = this.y,
width = this.width,
height = this.height;
if (this._options.rotated) {
yCoord = y + height / 2;
if (invertedBusinessRange) {
xCoord = isPositive ? x : x + width
} else {
xCoord = isPositive ? x + width : x
}
} else {
xCoord = x + width / 2;
if (invertedBusinessRange) {
yCoord = isPositive ? y + height : y
} else {
yCoord = isPositive ? y : y + height
}
}
return {
x: xCoord,
y: yCoord,
offset: 0
}
},
getTooltipParams: function(location) {
if ("edge" === location) {
return this._getEdgeTooltipParams()
}
var center = this.getCenterCoord();
center.offset = 0;
return center
},
getCenterCoord: function() {
var width = this.width,
height = this.height,
x = this.x,
y = this.y;
return {
x: x + width / 2,
y: y + height / 2
}
},
_truncateCoord: function(coord, minBounce, maxBounce) {
if (null === coord) {
return coord
}
if (coord < minBounce) {
return minBounce
}
if (coord > maxBounce) {
return maxBounce
}
return coord
},
_getErrorBarBaseEdgeLength: function() {
return this._options.rotated ? this.height : this.width
},
_translateErrorBars: function(argVisibleArea) {
symbolPoint._translateErrorBars.call(this);
if (this._errorBarPos < argVisibleArea[0] || this._errorBarPos > argVisibleArea[1]) {
this._errorBarPos = void 0
}
},
_translate: function() {
var arg, val, minVal, that = this,
rotated = that._options.rotated,
valAxis = rotated ? "x" : "y",
argAxis = rotated ? "y" : "x",
valIntervalName = rotated ? "width" : "height",
argIntervalName = rotated ? "height" : "width",
argTranslator = that._getArgTranslator(),
valTranslator = that._getValTranslator(),
argVisibleArea = that.series.getArgumentAxis().getVisibleArea(),
valVisibleArea = that.series.getValueAxis().getVisibleArea();
arg = argTranslator.translate(that.argument);
that[argAxis] = arg = null === arg ? arg : arg + (that[argAxis + "Correction"] || 0);
val = valTranslator.translate(that.value, 1);
minVal = valTranslator.translate(that.minValue);
that["v" + valAxis] = val;
that["v" + argAxis] = arg + that[argIntervalName] / 2;
val = that._truncateCoord(val, valVisibleArea[0], valVisibleArea[1]);
minVal = that._truncateCoord(minVal, valVisibleArea[0], valVisibleArea[1]);
that[valIntervalName] = _abs(val - minVal);
val = val < minVal ? val : minVal;
that._calculateVisibility(rotated ? val : arg, rotated ? arg : val, that.width, that.height);
that[valAxis] = null === val ? val : val + (that[valAxis + "Correction"] || 0);
that["min" + valAxis.toUpperCase()] = null === minVal ? minVal : minVal + (that[valAxis + "Correction"] || 0);
that["default" + valAxis.toUpperCase()] = valTranslator.translate(CANVAS_POSITION_DEFAULT);
that._translateErrorBars(argVisibleArea);
if (that.inVisibleArea && null !== that[argAxis]) {
if (that[argAxis] < argVisibleArea[0]) {
that[argIntervalName] = that[argIntervalName] - (argVisibleArea[0] - that[argAxis]);
that[argAxis] = argVisibleArea[0]
}
if (that[argAxis] + that[argIntervalName] > argVisibleArea[1]) {
that[argIntervalName] = argVisibleArea[1] - that[argAxis]
}
}
},
_updateMarker: function(animationEnabled, style) {
this.graphic.smartAttr(_extend({}, style, !animationEnabled ? this.getMarkerCoords() : {}))
},
getMarkerCoords: function() {
var that = this;
var x = that.x;
var y = that.y;
var width = that.width;
var height = that.height;
var argAxis = that.series.getArgumentAxis();
var rotated = that._options.rotated;
if (argAxis.getAxisPosition) {
var axisOptions = argAxis.getOptions();
var edgeOffset = Math.round(axisOptions.width / 2);
var argAxisPosition = argAxis.getAxisPosition();
if (axisOptions.visible) {
if (!rotated) {
height -= that.minY === that.defaultY && that.minY === argAxisPosition - argAxis.getAxisShift() ? edgeOffset : 0;
height < 0 && (height = 0)
} else {
var isStartFromAxis = that.minX === that.defaultX && that.minX === argAxisPosition - argAxis.getAxisShift();
x += isStartFromAxis ? edgeOffset : 0;
width -= isStartFromAxis ? edgeOffset : 0;
width < 0 && (width = 0)
}
}
}
return {
x: x,
y: y,
width: width,
height: height
}
},
coordsIn: function(x, y) {
var that = this;
return x >= that.x && x <= that.x + that.width && y >= that.y && y <= that.y + that.height
}
})
},
/*!********************************************************!*\
!*** ./artifacts/transpiled/viz/series/line_series.js ***!
\********************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var series = __webpack_require__( /*! ./scatter_series */ 107),
chartScatterSeries = series.chart,
polarScatterSeries = series.polar,
objectUtils = __webpack_require__( /*! ../../core/utils/object */ 47),
extend = __webpack_require__( /*! ../../core/utils/extend */ 0).extend,
each = __webpack_require__( /*! ../../core/utils/iterator */ 3).each,
vizUtils = __webpack_require__( /*! ../core/utils */ 12),
mathUtils = __webpack_require__( /*! ../../core/utils/math */ 30),
normalizeAngle = vizUtils.normalizeAngle,
DISCRETE = "discrete",
_map = vizUtils.map,
_extend = extend,
_each = each;
exports.chart = {};
exports.polar = {};
function clonePoint(point, newX, newY, newAngle) {
var p = objectUtils.clone(point);
p.x = newX;
p.y = newY;
p.angle = newAngle;
return p
}
function getTangentPoint(point, prevPoint, centerPoint, tan, nextStepAngle) {
var correctAngle = point.angle + nextStepAngle,
cosSin = vizUtils.getCosAndSin(correctAngle),
x = centerPoint.x + (point.radius + tan * nextStepAngle) * cosSin.cos,
y = centerPoint.y - (point.radius + tan * nextStepAngle) * cosSin.sin;
return clonePoint(prevPoint, x, y, correctAngle)
}
function obtainCubicBezierTCoef(p, p0, p1, p2, p3) {
var d = p0 - p;
var c = 3 * p1 - 3 * p0;
var b = 3 * p2 - 6 * p1 + 3 * p0;
var a = p3 - 3 * p2 + 3 * p1 - p0;
return mathUtils.solveCubicEquation(a, b, c, d)
}
var lineMethods = {
autoHidePointMarkersEnabled: function() {
return true
},
_applyGroupSettings: function(style, settings, group) {
var that = this;
settings = _extend(settings, style);
that._applyElementsClipRect(settings);
group.attr(settings)
},
_setGroupsSettings: function(animationEnabled) {
var that = this,
style = that._styles.normal;
that._applyGroupSettings(style.elements, {
"class": "dxc-elements"
}, that._elementsGroup);
that._bordersGroup && that._applyGroupSettings(style.border, {
"class": "dxc-borders"
}, that._bordersGroup);
chartScatterSeries._setGroupsSettings.call(that, animationEnabled);
animationEnabled && that._markersGroup && that._markersGroup.attr({
opacity: .001
})
},
_createGroups: function() {
var that = this;
that._createGroup("_elementsGroup", that, that._group);
that._areBordersVisible() && that._createGroup("_bordersGroup", that, that._group);
chartScatterSeries._createGroups.call(that)
},
_areBordersVisible: function() {
return false
},
_getDefaultSegment: function(segment) {
return {
line: _map(segment.line || [], function(pt) {
return pt.getDefaultCoords()
})
}
},
_prepareSegment: function(points) {
return {
line: points
}
},
_parseLineOptions: function(options, defaultColor) {
return {
stroke: options.color || defaultColor,
"stroke-width": options.width,
dashStyle: options.dashStyle || "solid"
}
},
_parseStyle: function(options, defaultColor) {
return {
elements: this._parseLineOptions(options, defaultColor)
}
},
_applyStyle: function(style) {
var that = this;
that._elementsGroup && that._elementsGroup.attr(style.elements);
_each(that._graphics || [], function(_, graphic) {
graphic.line && graphic.line.attr({
"stroke-width": style.elements["stroke-width"]
}).sharp()
})
},
_drawElement: function(segment, group) {
return {
line: this._createMainElement(segment.line, {
"stroke-width": this._styles.normal.elements["stroke-width"]
}).append(group)
}
},
_removeElement: function(element) {
element.line.remove()
},
_updateElement: function(element, segment, animate, animationComplete) {
var params = {
points: segment.line
},
lineElement = element.line;
animate ? lineElement.animate(params, {}, animationComplete) : lineElement.attr(params)
},
_animateComplete: function() {
var that = this;
chartScatterSeries._animateComplete.call(that);
that._markersGroup && that._markersGroup.animate({
opacity: 1
}, {
duration: that._defaultDuration
})
},
_animate: function() {
var that = this,
lastIndex = that._graphics.length - 1;
_each(that._graphics || [], function(i, elem) {
var complete;
if (i === lastIndex) {
complete = function() {
that._animateComplete()
}
}
that._updateElement(elem, that._segments[i], true, complete)
})
},
_drawPoint: function(options) {
chartScatterSeries._drawPoint.call(this, {
point: options.point,
groups: options.groups
})
},
_createMainElement: function(points, settings) {
return this._renderer.path(points, "line").attr(settings).sharp()
},
_sortPoints: function(points, rotated) {
return rotated ? points.sort(function(p1, p2) {
return p2.y - p1.y
}) : points.sort(function(p1, p2) {
return p1.x - p2.x
})
},
_drawSegment: function(points, animationEnabled, segmentCount, lastSegment) {
var that = this,
rotated = that._options.rotated,
forceDefaultSegment = false,
segment = that._prepareSegment(points, rotated, lastSegment);
that._segments.push(segment);
if (!that._graphics[segmentCount]) {
that._graphics[segmentCount] = that._drawElement(animationEnabled ? that._getDefaultSegment(segment) : segment, that._elementsGroup)
} else {
if (!animationEnabled) {
that._updateElement(that._graphics[segmentCount], segment)
} else {
if (forceDefaultSegment) {
that._updateElement(that._graphics[segmentCount], that._getDefaultSegment(segment))
}
}
}
},
_getTrackerSettings: function() {
var that = this,
defaultTrackerWidth = that._defaultTrackerWidth,
strokeWidthFromElements = that._styles.normal.elements["stroke-width"];
return {
"stroke-width": strokeWidthFromElements > defaultTrackerWidth ? strokeWidthFromElements : defaultTrackerWidth,
fill: "none"
}
},
_getMainPointsFromSegment: function(segment) {
return segment.line
},
_drawTrackerElement: function(segment) {
return this._createMainElement(this._getMainPointsFromSegment(segment), this._getTrackerSettings(segment))
},
_updateTrackerElement: function(segment, element) {
var settings = this._getTrackerSettings(segment);
settings.points = this._getMainPointsFromSegment(segment);
element.attr(settings)
},
checkSeriesViewportCoord: function(axis, coord) {
if (0 === this._points.length) {
return false
}
var range = axis.isArgumentAxis ? this.getArgumentRange() : this.getViewport();
var min = axis.getTranslator().translate(range.categories ? range.categories[0] : range.min);
var max = axis.getTranslator().translate(range.categories ? range.categories[range.categories.length - 1] : range.max);
var rotated = this.getOptions().rotated;
var inverted = axis.getOptions().inverted;
return axis.isArgumentAxis && (!rotated && !inverted || rotated && inverted) || !axis.isArgumentAxis && (rotated && !inverted || !rotated && inverted) ? coord >= min && coord <= max : coord >= max && coord <= min
},
getSeriesPairCoord: function(coord, isArgument) {
var that = this;
var oppositeCoord = null;
var nearestPoints = this.getNearestPointsByCoord(coord, isArgument);
var needValueCoord = isArgument && !that._options.rotated || !isArgument && that._options.rotated;
for (var i = 0; i < nearestPoints.length; i++) {
var p = nearestPoints[i];
var k = (p[1].vy - p[0].vy) / (p[1].vx - p[0].vx);
var b = p[0].vy - p[0].vx * k;
var tmpCoord = void 0;
if (p[1].vx - p[0].vx === 0) {
tmpCoord = needValueCoord ? p[0].vy : p[0].vx
} else {
tmpCoord = needValueCoord ? k * coord + b : (coord - b) / k
}
if (this.checkAxisVisibleAreaCoord(!isArgument, tmpCoord)) {
oppositeCoord = tmpCoord;
break
}
}
return oppositeCoord
}
};
var lineSeries = exports.chart.line = _extend({}, chartScatterSeries, lineMethods, {
getPointCenterByArg: function(arg) {
var value = this.getArgumentAxis().getTranslator().translate(arg);
return {
x: value,
y: value
}
}
});
exports.chart.stepline = _extend({}, lineSeries, {
_calculateStepLinePoints: function(points) {
var segment = [];
var coordName = this._options.rotated ? "x" : "y";
_each(points, function(i, pt) {
var point = void 0;
if (!i) {
segment.push(pt);
return
}
var step = segment[segment.length - 1][coordName];
if (step !== pt[coordName]) {
point = objectUtils.clone(pt);
point[coordName] = step;
segment.push(point)
}
segment.push(pt)
});
return segment
},
_prepareSegment: function(points) {
return lineSeries._prepareSegment(this._calculateStepLinePoints(points))
},
getSeriesPairCoord: function(coord, isArgument) {
var oppositeCoord = void 0;
var rotated = this._options.rotated;
var isOpposite = !isArgument && !rotated || isArgument && rotated;
var coordName = !isOpposite ? "vx" : "vy";
var oppositeCoordName = !isOpposite ? "vy" : "vx";
var nearestPoints = this.getNearestPointsByCoord(coord, isArgument);
for (var i = 0; i < nearestPoints.length; i++) {
var p = nearestPoints[i];
var tmpCoord = void 0;
if (isArgument) {
tmpCoord = coord !== p[1][coordName] ? p[0][oppositeCoordName] : p[1][oppositeCoordName]
} else {
tmpCoord = coord === p[0][coordName] ? p[0][oppositeCoordName] : p[1][oppositeCoordName]
}
if (this.checkAxisVisibleAreaCoord(!isArgument, tmpCoord)) {
oppositeCoord = tmpCoord;
break
}
}
return oppositeCoord
}
});
exports.chart.spline = _extend({}, lineSeries, {
_calculateBezierPoints: function(src, rotated) {
var bezierPoints = [],
pointsCopy = src,
checkExtremum = function(otherPointCoord, pointCoord, controlCoord) {
return otherPointCoord > pointCoord && controlCoord > otherPointCoord || otherPointCoord < pointCoord && controlCoord < otherPointCoord ? otherPointCoord : controlCoord
};
if (1 !== pointsCopy.length) {
pointsCopy.forEach(function(curPoint, i) {
var leftControlX, leftControlY, rightControlX, rightControlY, xCur, yCur, x1, x2, y1, y2, curIsExtremum, leftPoint, rightPoint, a, b, c, xc, yc, shift, prevPoint = pointsCopy[i - 1],
nextPoint = pointsCopy[i + 1],
lambda = .5;
if (!i || i === pointsCopy.length - 1) {
bezierPoints.push(curPoint, curPoint);
return
}
xCur = curPoint.x;
yCur = curPoint.y;
x1 = prevPoint.x;
x2 = nextPoint.x;
y1 = prevPoint.y;
y2 = nextPoint.y;
curIsExtremum = !!(!rotated && (yCur <= prevPoint.y && yCur <= nextPoint.y || yCur >= prevPoint.y && yCur >= nextPoint.y) || rotated && (xCur <= prevPoint.x && xCur <= nextPoint.x || xCur >= prevPoint.x && xCur >= nextPoint.x));
if (curIsExtremum) {
if (!rotated) {
rightControlY = leftControlY = yCur;
rightControlX = (xCur + nextPoint.x) / 2;
leftControlX = (xCur + prevPoint.x) / 2
} else {
rightControlX = leftControlX = xCur;
rightControlY = (yCur + nextPoint.y) / 2;
leftControlY = (yCur + prevPoint.y) / 2
}
} else {
a = y2 - y1;
b = x1 - x2;
c = y1 * x2 - x1 * y2;
if (!rotated) {
if (!b) {
bezierPoints.push(curPoint, curPoint, curPoint);
return
}
xc = xCur;
yc = -1 * (a * xc + c) / b;
shift = yc - yCur;
y1 -= shift;
y2 -= shift
} else {
if (!a) {
bezierPoints.push(curPoint, curPoint, curPoint);
return
}
yc = yCur;
xc = -1 * (b * yc + c) / a;
shift = xc - xCur;
x1 -= shift;
x2 -= shift
}
rightControlX = (xCur + lambda * x2) / (1 + lambda);
rightControlY = (yCur + lambda * y2) / (1 + lambda);
leftControlX = (xCur + lambda * x1) / (1 + lambda);
leftControlY = (yCur + lambda * y1) / (1 + lambda)
}
if (!rotated) {
leftControlY = checkExtremum(prevPoint.y, yCur, leftControlY);
rightControlY = checkExtremum(nextPoint.y, yCur, rightControlY)
} else {
leftControlX = checkExtremum(prevPoint.x, xCur, leftControlX);
rightControlX = checkExtremum(nextPoint.x, xCur, rightControlX)
}
leftPoint = clonePoint(curPoint, leftControlX, leftControlY);
rightPoint = clonePoint(curPoint, rightControlX, rightControlY);
bezierPoints.push(leftPoint, curPoint, rightPoint)
})
} else {
bezierPoints.push(pointsCopy[0])
}
return bezierPoints
},
_prepareSegment: function(points, rotated) {
return lineSeries._prepareSegment(this._calculateBezierPoints(points, rotated))
},
_createMainElement: function(points, settings) {
return this._renderer.path(points, "bezier").attr(settings).sharp()
},
getSeriesPairCoord: function(coord, isArgument) {
var that = this;
var oppositeCoord = null;
var isOpposite = !isArgument && !this._options.rotated || isArgument && this._options.rotated;
var coordName = !isOpposite ? "vx" : "vy";
var bezierCoordName = !isOpposite ? "x" : "y";
var oppositeCoordName = !isOpposite ? "vy" : "vx";
var bezierOppositeCoordName = !isOpposite ? "y" : "x";
var axis = !isArgument ? that.getArgumentAxis() : that.getValueAxis();
var visibleArea = axis.getVisibleArea();
var nearestPoints = this.getNearestPointsByCoord(coord, isArgument);
var _loop = function(i) {
var p = nearestPoints[i];
if (1 === p.length) {
visibleArea[0] <= p[0][oppositeCoordName] && visibleArea[1] >= p[0][oppositeCoordName] && (oppositeCoord = p[0][oppositeCoordName])
} else {
var ts = obtainCubicBezierTCoef(coord, p[0][coordName], p[1][bezierCoordName], p[2][bezierCoordName], p[3][coordName]);
ts.forEach(function(t) {
if (t >= 0 && t <= 1) {
var tmpCoord = Math.pow(1 - t, 3) * p[0][oppositeCoordName] + 3 * Math.pow(1 - t, 2) * t * p[1][bezierOppositeCoordName] + 3 * (1 - t) * t * t * p[2][bezierOppositeCoordName] + t * t * t * p[3][oppositeCoordName];
if (visibleArea[0] <= tmpCoord && visibleArea[1] >= tmpCoord) {
oppositeCoord = tmpCoord
}
}
})
}
if (null !== oppositeCoord) {
return "break"
}
};
for (var i = 0; i < nearestPoints.length; i++) {
var _ret = _loop(i);
if ("break" === _ret) {
break
}
}
return oppositeCoord
},
getNearestPointsByCoord: function(coord, isArgument) {
var that = this;
var rotated = that.getOptions().rotated;
var isOpposite = !isArgument && !rotated || isArgument && rotated;
var coordName = isOpposite ? "vy" : "vx";
var points = that.getVisiblePoints();
var allPoints = that.getPoints();
var bezierPoints = that._segments.length > 0 ? that._segments.reduce(function(a, seg) {
return a.concat(seg.line)
}, []) : [];
var nearestPoints = [];
if (that.isVisible() && allPoints.length > 0) {
if (allPoints.length > 1) {
that.findNeighborPointsByCoord(coord, coordName, points.slice(0), allPoints, function(point, nextPoint) {
var index = bezierPoints.indexOf(point);
nearestPoints.push([point, bezierPoints[index + 1], bezierPoints[index + 2], nextPoint])
})
} else {
if (allPoints[0][coordName] === coord) {
nearestPoints.push([allPoints[0]])
}
}
}
return nearestPoints
}
});
exports.polar.line = _extend({}, polarScatterSeries, lineMethods, {
_sortPoints: function(points) {
return points
},
_prepareSegment: function(points, rotated, lastSegment) {
var i, preparedPoints = [],
centerPoint = this.getValueAxis().getCenter();
lastSegment && this._closeSegment(points);
if (this.argumentAxisType !== DISCRETE && this.valueAxisType !== DISCRETE) {
for (i = 1; i < points.length; i++) {
preparedPoints = preparedPoints.concat(this._getTangentPoints(points[i], points[i - 1], centerPoint))
}
if (!preparedPoints.length) {
preparedPoints = points
}
} else {
return lineSeries._prepareSegment.call(this, points)
}
return {
line: preparedPoints
}
},
_getRemainingAngle: function(angle) {
var normAngle = normalizeAngle(angle);
return angle >= 0 ? 360 - normAngle : -normAngle
},
_closeSegment: function(points) {
var point, differenceAngle;
if (this._segments.length) {
point = this._segments[0].line[0]
} else {
point = clonePoint(points[0], points[0].x, points[0].y, points[0].angle)
}
if (points[points.length - 1].angle !== point.angle) {
if (normalizeAngle(Math.round(points[points.length - 1].angle)) === normalizeAngle(Math.round(point.angle))) {
point.angle = points[points.length - 1].angle
} else {
differenceAngle = points[points.length - 1].angle - point.angle;
point.angle = points[points.length - 1].angle + this._getRemainingAngle(differenceAngle)
}
points.push(point)
}
},
_getTangentPoints: function(point, prevPoint, centerPoint) {
var i, tangentPoints = [],
betweenAngle = Math.round(prevPoint.angle - point.angle),
tan = (prevPoint.radius - point.radius) / betweenAngle;
if (0 === betweenAngle) {
tangentPoints = [prevPoint, point]
} else {
if (betweenAngle > 0) {
for (i = betweenAngle; i >= 0; i--) {
tangentPoints.push(getTangentPoint(point, prevPoint, centerPoint, tan, i))
}
} else {
for (i = 0; i >= betweenAngle; i--) {
tangentPoints.push(getTangentPoint(point, prevPoint, centerPoint, tan, betweenAngle - i))
}
}
}
return tangentPoints
}
})
},
/*!****************************************************!*\
!*** ./artifacts/transpiled/viz/axes/base_axis.js ***!
\****************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var _smart_formatter = __webpack_require__( /*! ./smart_formatter */ 413);
var _utils = __webpack_require__( /*! ../core/utils */ 12);
var _utils2 = _interopRequireDefault(_utils);
var _type = __webpack_require__( /*! ../../core/utils/type */ 1);
var _axes_constants = __webpack_require__( /*! ./axes_constants */ 253);
var _axes_constants2 = _interopRequireDefault(_axes_constants);
var _extend = __webpack_require__( /*! ../../core/utils/extend */ 0);
var _array = __webpack_require__( /*! ../../core/utils/array */ 14);
var _format_helper = __webpack_require__( /*! ../../format_helper */ 63);
var _format_helper2 = _interopRequireDefault(_format_helper);
var _parse_utils = __webpack_require__( /*! ../components/parse_utils */ 249);
var _parse_utils2 = _interopRequireDefault(_parse_utils);
var _tick_generator = __webpack_require__( /*! ./tick_generator */ 414);
var _tick_generator2 = _interopRequireDefault(_tick_generator);
var _translator2d = __webpack_require__( /*! ../translators/translator2d */ 254);
var _translator2d2 = _interopRequireDefault(_translator2d);
var _range = __webpack_require__( /*! ../translators/range */ 109);
var _tick = __webpack_require__( /*! ./tick */ 415);
var _math2 = __webpack_require__( /*! ../../core/utils/math */ 30);
var _date = __webpack_require__( /*! ../../core/utils/date */ 22);
var _common = __webpack_require__( /*! ../../core/utils/common */ 4);
var _xy_axes = __webpack_require__( /*! ./xy_axes */ 416);
var _xy_axes2 = _interopRequireDefault(_xy_axes);
var _polar_axes = __webpack_require__( /*! ./polar_axes */ 813);
var _polar_axes2 = _interopRequireDefault(_polar_axes);
var _constant_line = __webpack_require__( /*! ./constant_line */ 814);
var _constant_line2 = _interopRequireDefault(_constant_line);
var _strip = __webpack_require__( /*! ./strip */ 815);
var _strip2 = _interopRequireDefault(_strip);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
}
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
})
} else {
obj[key] = value
}
return obj
}
var convertTicksToValues = _axes_constants2.default.convertTicksToValues;
var patchFontOptions = _utils2.default.patchFontOptions;
var getVizRangeObject = _utils2.default.getVizRangeObject;
var getLog = _utils2.default.getLogExt;
var raiseTo = _utils2.default.raiseToExt;
var _math = Math;
var _abs = _math.abs;
var _max = _math.max;
var _min = _math.min;
var _isArray = Array.isArray;
var DEFAULT_AXIS_LABEL_SPACING = 5;
var MAX_GRID_BORDER_ADHENSION = 4;
var TOP = _axes_constants2.default.top;
var BOTTOM = _axes_constants2.default.bottom;
var LEFT = _axes_constants2.default.left;
var RIGHT = _axes_constants2.default.right;
var CENTER = _axes_constants2.default.center;
var KEEP = "keep";
var SHIFT = "shift";
var RESET = "reset";
var ROTATE = "rotate";
var DEFAULT_AXIS_DIVISION_FACTOR = 50;
var DEFAULT_MINOR_AXIS_DIVISION_FACTOR = 15;
var SCROLL_THRESHOLD = 5;
var MAX_MARGIN_VALUE = .8;
var dateIntervals = {
day: 864e5,
week: 6048e5
};
function getTickGenerator(options, incidentOccurred, skipTickGeneration, rangeIsEmpty, adjustDivisionFactor, _ref) {
var allowNegatives = _ref.allowNegatives,
linearThreshold = _ref.linearThreshold;
return _tick_generator2.default.tickGenerator({
axisType: options.type,
dataType: options.dataType,
logBase: options.logarithmBase,
allowNegatives: allowNegatives,
linearThreshold: linearThreshold,
axisDivisionFactor: adjustDivisionFactor(options.axisDivisionFactor || DEFAULT_AXIS_DIVISION_FACTOR),
minorAxisDivisionFactor: adjustDivisionFactor(options.minorAxisDivisionFactor || DEFAULT_MINOR_AXIS_DIVISION_FACTOR),
numberMultipliers: options.numberMultipliers,
calculateMinors: options.minorTick.visible || options.minorGrid.visible || options.calculateMinors,
allowDecimals: options.allowDecimals,
endOnTick: options.endOnTick,
incidentOccurred: incidentOccurred,
firstDayOfWeek: options.workWeek && options.workWeek[0],
skipTickGeneration: skipTickGeneration,
skipCalculationLimits: options.skipCalculationLimits,
generateExtraTick: options.generateExtraTick,
minTickInterval: options.minTickInterval,
rangeIsEmpty: rangeIsEmpty
})
}
function createMajorTick(axis, renderer, skippedCategory) {
var options = axis.getOptions();
return (0, _tick.tick)(axis, renderer, options.tick, options.grid, skippedCategory, false)
}
function createMinorTick(axis, renderer) {
var options = axis.getOptions();
return (0, _tick.tick)(axis, renderer, options.minorTick, options.minorGrid)
}
function createBoundaryTick(axis, renderer, isFirst) {
var options = axis.getOptions();
return (0, _tick.tick)(axis, renderer, (0, _extend.extend)({}, options.tick, {
visible: options.showCustomBoundaryTicks
}), options.grid, void 0, false, isFirst ? -1 : 1)
}
function callAction(elements, action, actionArgument1, actionArgument2) {
(elements || []).forEach(function(e) {
return e[action](actionArgument1, actionArgument2)
})
}
function initTickCoords(ticks) {
callAction(ticks, "initCoords")
}
function drawTickMarks(ticks, options) {
callAction(ticks, "drawMark", options)
}
function drawGrids(ticks, drawLine) {
callAction(ticks, "drawGrid", drawLine)
}
function updateTicksPosition(ticks, options, animate) {
callAction(ticks, "updateTickPosition", options, animate)
}
function updateGridsPosition(ticks, animate) {
callAction(ticks, "updateGridPosition", animate)
}
var measureLabels = exports.measureLabels = function(items) {
items.forEach(function(item) {
item.labelBBox = item.label ? item.label.getBBox() : {
x: 0,
y: 0,
width: 0,
height: 0
}
})
};
function cleanUpInvalidTicks(ticks) {
var i = ticks.length - 1;
for (i; i >= 0; i--) {
if (!removeInvalidTick(ticks, i)) {
break
}
}
for (i = 0; i < ticks.length; i++) {
if (removeInvalidTick(ticks, i)) {
i--
} else {
break
}
}
}
function removeInvalidTick(ticks, i) {
if (null === ticks[i].coords.x || null === ticks[i].coords.y) {
ticks.splice(i, 1);
return true
}
return false
}
function validateAxisOptions(options) {
var labelOptions = options.label,
position = options.position,
defaultPosition = options.isHorizontal ? BOTTOM : LEFT,
secondaryPosition = options.isHorizontal ? TOP : RIGHT;
if (position !== defaultPosition && position !== secondaryPosition) {
position = defaultPosition
}
if (position === RIGHT && !labelOptions.userAlignment) {
labelOptions.alignment = LEFT
}
options.position = position;
options.hoverMode = options.hoverMode ? options.hoverMode.toLowerCase() : "none";
labelOptions.minSpacing = (0, _type.isDefined)(labelOptions.minSpacing) ? labelOptions.minSpacing : DEFAULT_AXIS_LABEL_SPACING;
options.type && (options.type = options.type.toLowerCase());
options.argumentType && (options.argumentType = options.argumentType.toLowerCase());
options.valueType && (options.valueType = options.valueType.toLowerCase())
}
function getOptimalAngle(boxes, labelOpt) {
var angle = 180 * _math.asin((boxes[0].height + labelOpt.minSpacing) / (boxes[1].x - boxes[0].x)) / _math.PI;
return angle < 45 ? -45 : -90
}
function updateLabels(ticks, step, func) {
ticks.forEach(function(tick, index) {
if (tick.label) {
if (index % step !== 0) {
tick.removeLabel()
} else {
if (func) {
func(tick, index)
}
}
}
})
}
function valueOf(value) {
return value.valueOf()
}
function getZoomBoundValue(optionValue, dataValue) {
if (void 0 === optionValue) {
return dataValue
} else {
if (null === optionValue) {
return
} else {
return optionValue
}
}
}
function configureGenerator(options, axisDivisionFactor, viewPort, screenDelta, minTickInterval) {
var tickGeneratorOptions = (0, _extend.extend)({}, options, {
endOnTick: true,
axisDivisionFactor: axisDivisionFactor,
skipCalculationLimits: true,
generateExtraTick: true,
minTickInterval: minTickInterval
});
return function(tickInterval, skipTickGeneration, min, max, breaks) {
return getTickGenerator(tickGeneratorOptions, _common.noop, skipTickGeneration, viewPort.isEmpty(), function(v) {
return v
}, viewPort)({
min: min,
max: max,
categories: viewPort.categories,
isSpacedMargin: viewPort.isSpacedMargin,
checkMinDataVisibility: viewPort.checkMinDataVisibility,
checkMaxDataVisibility: viewPort.checkMaxDataVisibility
}, screenDelta, tickInterval, (0, _type.isDefined)(tickInterval), void 0, void 0, void 0, breaks)
}
}
function convertVisualRangeObject(visualRange, optionValue) {
return _utils2.default.convertVisualRangeObject(visualRange, !_isArray(optionValue))
}
function getConstantLineSharpDirection(coord, axisCanvas) {
return Math.max(axisCanvas.start, axisCanvas.end) !== coord ? 1 : -1
}
var calculateCanvasMargins = exports.calculateCanvasMargins = function(bBoxes, canvas) {
var cLeft = canvas.left;
var cTop = canvas.top;
var cRight = canvas.width - canvas.right;
var cBottom = canvas.height - canvas.bottom;
return bBoxes.reduce(function(margins, bBox) {
if (!bBox || bBox.isEmpty) {
return margins
}
return {
left: _max(margins.left, cLeft - bBox.x),
top: _max(margins.top, cTop - bBox.y),
right: _max(margins.right, bBox.x + bBox.width - cRight),
bottom: _max(margins.bottom, bBox.y + bBox.height - cBottom)
}
}, {
left: 0,
right: 0,
top: 0,
bottom: 0
})
};
var Axis = exports.Axis = function(renderSettings) {
var that = this;
that._renderer = renderSettings.renderer;
that._incidentOccurred = renderSettings.incidentOccurred;
that._eventTrigger = renderSettings.eventTrigger;
that._stripsGroup = renderSettings.stripsGroup;
that._labelAxesGroup = renderSettings.labelAxesGroup;
that._constantLinesGroup = renderSettings.constantLinesGroup;
that._scaleBreaksGroup = renderSettings.scaleBreaksGroup;
that._axesContainerGroup = renderSettings.axesContainerGroup;
that._gridContainerGroup = renderSettings.gridGroup;
that._axisCssPrefix = renderSettings.widgetClass + "-" + (renderSettings.axisClass ? renderSettings.axisClass + "-" : "");
that._setType(renderSettings.axisType, renderSettings.drawingType);
that._createAxisGroups();
that._translator = that._createTranslator();
that.isArgumentAxis = renderSettings.isArgumentAxis;
that._viewport = {};
that._firstDrawing = true;
that._initRange = {}
};
Axis.prototype = {
constructor: Axis,
_drawAxis: function() {
var options = this._options;
if (!options.visible) {
return
}
this._axisElement = this._createAxisElement();
this._updateAxisElementPosition();
this._axisElement.attr({
"stroke-width": options.width,
stroke: options.color,
"stroke-opacity": options.opacity
}).sharp(this._getSharpParam(true), this.getAxisSharpDirection()).append(this._axisLineGroup)
},
_createPathElement: function(points, attr, sharpDirection) {
return this.sharp(this._renderer.path(points, "line").attr(attr), sharpDirection)
},
sharp: function(svgElement) {
var sharpDirection = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 1;
return svgElement.sharp(this._getSharpParam(), sharpDirection)
},
getAxisSharpDirection: function() {
var position = this._options.position;
return position === TOP || position === LEFT ? 1 : -1
},
getSharpDirectionByCoords: function(coords) {
var canvas = this._getCanvasStartEnd();
var maxCoord = Math.max(canvas.start, canvas.end);
return this.getRadius ? 0 : maxCoord !== coords[this._isHorizontal ? "x" : "y"] ? 1 : -1
},
_getGridLineDrawer: function() {
var that = this;
return function(tick, gridStyle) {
var grid = that._getGridPoints(tick.coords);
if (grid.points) {
return that._createPathElement(grid.points, gridStyle, that.getSharpDirectionByCoords(tick.coords))
}
return null
}
},
_getGridPoints: function(coords) {
var that = this,
isHorizontal = this._isHorizontal,
tickPositionField = isHorizontal ? "x" : "y",
orthogonalPositions = this._orthogonalPositions,
positionFrom = orthogonalPositions.start,
positionTo = orthogonalPositions.end;
var borderOptions = that.borderOptions;
var canvasStart = isHorizontal ? LEFT : TOP,
canvasEnd = isHorizontal ? RIGHT : BOTTOM,
axisCanvas = that.getCanvas(),
canvas = {
left: axisCanvas.left,
right: axisCanvas.width - axisCanvas.right,
top: axisCanvas.top,
bottom: axisCanvas.height - axisCanvas.bottom
},
firstBorderLinePosition = borderOptions.visible && borderOptions[canvasStart] ? canvas[canvasStart] : void 0,
lastBorderLinePosition = borderOptions.visible && borderOptions[canvasEnd] ? canvas[canvasEnd] : void 0,
minDelta = MAX_GRID_BORDER_ADHENSION + firstBorderLinePosition,
maxDelta = lastBorderLinePosition - MAX_GRID_BORDER_ADHENSION;
if (that.areCoordsOutsideAxis(coords) || void 0 === coords[tickPositionField] || coords[tickPositionField] < minDelta || coords[tickPositionField] > maxDelta) {
return {
points: null
}
}
return {
points: isHorizontal ? null !== coords[tickPositionField] ? [coords[tickPositionField], positionFrom, coords[tickPositionField], positionTo] : null : null !== coords[tickPositionField] ? [positionFrom, coords[tickPositionField], positionTo, coords[tickPositionField]] : null
}
},
_getConstantLinePos: function(parsedValue, canvasStart, canvasEnd) {
var value = this._getTranslatedCoord(parsedValue);
if (!(0, _type.isDefined)(value) || value < _min(canvasStart, canvasEnd) || value > _max(canvasStart, canvasEnd)) {
return
}
return value
},
_getConstantLineGraphicAttributes: function(value) {
var positionFrom = this._orthogonalPositions.start,
positionTo = this._orthogonalPositions.end;
return {
points: this._isHorizontal ? [value, positionFrom, value, positionTo] : [positionFrom, value, positionTo, value]
}
},
_createConstantLine: function(value, attr) {
return this._createPathElement(this._getConstantLineGraphicAttributes(value).points, attr, getConstantLineSharpDirection(value, this._getCanvasStartEnd()))
},
_drawConstantLineLabelText: function(text, x, y, _ref2, group) {
var font = _ref2.font,
cssClass = _ref2.cssClass;
return this._renderer.text(text, x, y).css(patchFontOptions((0, _extend.extend)({}, this._options.label.font, font))).attr({
align: "center",
"class": cssClass
}).append(group)
},
_drawConstantLineLabels: function(parsedValue, lineLabelOptions, value, group) {
var coords, that = this,
text = lineLabelOptions.text,
options = that._options,
labelOptions = options.label;
that._checkAlignmentConstantLineLabels(lineLabelOptions);
text = (0, _type.isDefined)(text) ? text : that.formatLabel(parsedValue, labelOptions);
coords = that._getConstantLineLabelsCoords(value, lineLabelOptions);
return that._drawConstantLineLabelText(text, coords.x, coords.y, lineLabelOptions, group)
},
_getStripPos: function(startValue, endValue, canvasStart, canvasEnd, range) {
var start, end, swap, startCategoryIndex, endCategoryIndex, isContinuous = !!(range.minVisible || range.maxVisible),
categories = (range.categories || []).reduce(function(result, cat) {
result.push(cat.valueOf());
return result
}, []),
min = range.minVisible;
if (!isContinuous) {
if ((0, _type.isDefined)(startValue) && (0, _type.isDefined)(endValue)) {
var parsedStartValue = this.parser(startValue);
var parsedEndValue = this.parser(endValue);
startCategoryIndex = (0, _array.inArray)((0, _type.isDefined)(parsedStartValue) ? parsedStartValue.valueOf() : void 0, categories);
endCategoryIndex = (0, _array.inArray)((0, _type.isDefined)(parsedEndValue) ? parsedEndValue.valueOf() : void 0, categories);
if (startCategoryIndex === -1 || endCategoryIndex === -1) {
return {
from: 0,
to: 0
}
}
if (startCategoryIndex > endCategoryIndex) {
swap = endValue;
endValue = startValue;
startValue = swap
}
}
}
if ((0, _type.isDefined)(startValue)) {
startValue = this.validateUnit(startValue, "E2105", "strip");
start = this._getTranslatedCoord(startValue, -1);
if (!(0, _type.isDefined)(start) && isContinuous) {
start = startValue < min ? canvasStart : canvasEnd
}
} else {
start = canvasStart
}
if ((0, _type.isDefined)(endValue)) {
endValue = this.validateUnit(endValue, "E2105", "strip");
end = this._getTranslatedCoord(endValue, 1);
if (!(0, _type.isDefined)(end) && isContinuous) {
end = endValue > min ? canvasEnd : canvasStart
}
} else {
end = canvasEnd
}
return start < end ? {
from: start,
to: end
} : {
from: end,
to: start
}
},
_getStripGraphicAttributes: function(fromPoint, toPoint) {
var x, y, width, height, orthogonalPositions = this._orthogonalPositions,
positionFrom = orthogonalPositions.start,
positionTo = orthogonalPositions.end;
if (this._isHorizontal) {
x = fromPoint;
y = _min(positionFrom, positionTo);
width = toPoint - fromPoint;
height = _abs(positionFrom - positionTo)
} else {
x = _min(positionFrom, positionTo);
y = fromPoint;
width = _abs(positionFrom - positionTo);
height = _abs(fromPoint - toPoint)
}
return {
x: x,
y: y,
width: width,
height: height
}
},
_createStrip: function(attrs) {
return this._renderer.rect(attrs.x, attrs.y, attrs.width, attrs.height)
},
_adjustStripLabels: function() {
var that = this;
this._strips.forEach(function(strip) {
if (strip.label) {
strip.label.attr(that._getAdjustedStripLabelCoords(strip))
}
})
},
_adjustLabelsCoord: function(offset, maxWidth, checkCanvas) {
var that = this;
that._majorTicks.forEach(function(tick) {
if (tick.label) {
tick.updateMultilineTextAlignment();
tick.label.attr(that._getLabelAdjustedCoord(tick, offset + (tick.labelOffset || 0), maxWidth, checkCanvas))
}
})
},
_adjustLabels: function(offset) {
var that = this,
maxSize = that._majorTicks.reduce(function(size, tick) {
if (!tick.label) {
return size
}
var bBox = tick.labelRotationAngle ? _utils2.default.rotateBBox(tick.labelBBox, [tick.labelCoords.x, tick.labelCoords.y], -tick.labelRotationAngle) : tick.labelBBox;
return {
width: _max(size.width || 0, bBox.width),
height: _max(size.height || 0, bBox.height),
offset: _max(size.offset || 0, tick.labelOffset || 0)
}
}, {}),
additionalOffset = that._isHorizontal ? maxSize.height : maxSize.width;
that._adjustLabelsCoord(offset, maxSize.width);
return offset + additionalOffset + (additionalOffset && that._options.label.indentFromAxis) + maxSize.offset
},
_getLabelAdjustedCoord: function(tick, offset, maxWidth) {
offset = offset || 0;
var translateX, translateY, that = this,
options = that._options,
box = _utils2.default.rotateBBox(tick.labelBBox, [tick.labelCoords.x, tick.labelCoords.y], -tick.labelRotationAngle || 0),
position = options.position,
textAlign = tick.labelAlignment || options.label.alignment,
isDiscrete = "discrete" === that._options.type,
isFlatLabel = tick.labelRotationAngle % 90 === 0,
indentFromAxis = options.label.indentFromAxis,
axisPosition = that._axisPosition,
labelCoords = tick.labelCoords,
labelX = labelCoords.x;
if (that._isHorizontal) {
if (position === BOTTOM) {
translateY = axisPosition + indentFromAxis - box.y + offset
} else {
translateY = axisPosition - indentFromAxis - (box.y + box.height) - offset
}
if (textAlign === RIGHT) {
translateX = isDiscrete && isFlatLabel ? tick.coords.x - (box.x + box.width) : labelX - box.x - box.width
} else {
if (textAlign === LEFT) {
translateX = isDiscrete && isFlatLabel ? labelX - box.x - (tick.coords.x - labelX) : labelX - box.x
} else {
translateX = labelX - box.x - box.width / 2
}
}
} else {
translateY = labelCoords.y - box.y - box.height / 2;
if (position === LEFT) {
if (textAlign === LEFT) {
translateX = axisPosition - indentFromAxis - maxWidth - box.x
} else {
if (textAlign === CENTER) {
translateX = axisPosition - indentFromAxis - maxWidth / 2 - box.x - box.width / 2
} else {
translateX = axisPosition - indentFromAxis - box.x - box.width
}
}
translateX -= offset
} else {
if (textAlign === RIGHT) {
translateX = axisPosition + indentFromAxis + maxWidth - box.x - box.width
} else {
if (textAlign === CENTER) {
translateX = axisPosition + indentFromAxis + maxWidth / 2 - box.x - box.width / 2
} else {
translateX = axisPosition + indentFromAxis - box.x
}
}
translateX += offset
}
}
return {
translateX: translateX,
translateY: translateY
}
},
_createAxisConstantLineGroups: function() {
var insideGroup, outsideGroup1, outsideGroup2, that = this,
renderer = that._renderer,
classSelector = that._axisCssPrefix,
constantLinesClass = classSelector + "constant-lines";
insideGroup = renderer.g().attr({
"class": constantLinesClass
});
outsideGroup1 = renderer.g().attr({
"class": constantLinesClass
});
outsideGroup2 = renderer.g().attr({
"class": constantLinesClass
});
return {
inside: insideGroup,
outside1: outsideGroup1,
left: outsideGroup1,
top: outsideGroup1,
outside2: outsideGroup2,
right: outsideGroup2,
bottom: outsideGroup2,
remove: function() {
this.inside.remove();
this.outside1.remove();
this.outside2.remove()
},
clear: function() {
this.inside.clear();
this.outside1.clear();
this.outside2.clear()
}
}
},
_createAxisGroups: function() {
var that = this,
renderer = that._renderer,
classSelector = that._axisCssPrefix;
that._axisGroup = renderer.g().attr({
"class": classSelector + "axis"
});
that._axisStripGroup = renderer.g().attr({
"class": classSelector + "strips"
});
that._axisGridGroup = renderer.g().attr({
"class": classSelector + "grid"
});
that._axisElementsGroup = renderer.g().attr({
"class": classSelector + "elements"
}).append(that._axisGroup);
that._axisLineGroup = renderer.g().attr({
"class": classSelector + "line"
}).append(that._axisGroup);
that._axisTitleGroup = renderer.g().attr({
"class": classSelector + "title"
}).append(that._axisGroup);
that._axisConstantLineGroups = {
above: that._createAxisConstantLineGroups(),
under: that._createAxisConstantLineGroups()
};
that._axisStripLabelGroup = renderer.g().attr({
"class": classSelector + "axis-labels"
})
},
_clearAxisGroups: function() {
var that = this;
that._axisGroup.remove();
that._axisStripGroup.remove();
that._axisStripLabelGroup.remove();
that._axisConstantLineGroups.above.remove();
that._axisConstantLineGroups.under.remove();
that._axisGridGroup.remove();
that._axisTitleGroup.clear();
that._axisElementsGroup.clear();
that._axisLineGroup && that._axisLineGroup.clear();
that._axisStripGroup && that._axisStripGroup.clear();
that._axisGridGroup && that._axisGridGroup.clear();
that._axisConstantLineGroups.above.clear();
that._axisConstantLineGroups.under.clear();
that._axisStripLabelGroup && that._axisStripLabelGroup.clear()
},
_getLabelFormatObject: function(value, labelOptions, range, point, tickInterval, ticks) {
range = range || this._getViewportRange();
var formatObject = {
value: value,
valueText: (0, _smart_formatter.smartFormatter)(value, {
labelOptions: labelOptions,
ticks: ticks || convertTicksToValues(this._majorTicks),
tickInterval: (0, _type.isDefined)(tickInterval) ? tickInterval : this._tickInterval,
dataType: this._options.dataType,
logarithmBase: this._options.logarithmBase,
type: this._options.type,
showTransition: !this._options.marker.visible,
point: point
}) || "",
min: range.minVisible,
max: range.maxVisible
};
if (point) {
formatObject.point = point
}
return formatObject
},
formatLabel: function(value, labelOptions, range, point, tickInterval, ticks) {
var formatObject = this._getLabelFormatObject(value, labelOptions, range, point, tickInterval, ticks);
return (0, _type.isFunction)(labelOptions.customizeText) ? labelOptions.customizeText.call(formatObject, formatObject) : formatObject.valueText
},
formatHint: function(value, labelOptions, range) {
var formatObject = this._getLabelFormatObject(value, labelOptions, range);
return (0, _type.isFunction)(labelOptions.customizeHint) ? labelOptions.customizeHint.call(formatObject, formatObject) : void 0
},
formatRange: function(startValue, endValue, interval) {
return (0, _smart_formatter.formatRange)(startValue, endValue, interval, this.getOptions())
},
_setTickOffset: function() {
var options = this._options,
discreteAxisDivisionMode = options.discreteAxisDivisionMode;
this._tickOffset = +("crossLabels" !== discreteAxisDivisionMode || !discreteAxisDivisionMode)
},
getMargins: function() {
var that = this,
options = that._options,
position = options.position,
placeholderSize = options.placeholderSize,
canvas = that.getCanvas(),
cLeft = canvas.left,
cTop = canvas.top,
cRight = canvas.width - canvas.right,
cBottom = canvas.height - canvas.bottom,
edgeMarginCorrection = _max(options.grid.visible && options.grid.width || 0, options.tick.visible && options.tick.width || 0),
constantLineAboveSeries = that._axisConstantLineGroups.above,
constantLineUnderSeries = that._axisConstantLineGroups.under,
boxes = [that._axisElementsGroup, constantLineAboveSeries.outside1, constantLineAboveSeries.outside2, constantLineUnderSeries.outside1, constantLineUnderSeries.outside2, that._axisLineGroup].map(function(group) {
return group && group.getBBox()
}).concat(function(group) {
var box = group && group.getBBox();
if (!box || box.isEmpty) {
return box
}
if (that._isHorizontal) {
box.x = cLeft;
box.width = cRight - cLeft
} else {
box.y = cTop;
box.height = cBottom - cTop
}
return box
}(that._axisTitleGroup));
var margins = calculateCanvasMargins(boxes, canvas);
margins[position] += options.crosshairMargin;
if (placeholderSize) {
margins[position] = placeholderSize
}
if (edgeMarginCorrection) {
if (that._isHorizontal && canvas.right < edgeMarginCorrection && margins.right < edgeMarginCorrection) {
margins.right = edgeMarginCorrection
}
if (!that._isHorizontal && canvas.bottom < edgeMarginCorrection && margins.bottom < edgeMarginCorrection) {
margins.bottom = edgeMarginCorrection
}
}
return margins
},
validateUnit: function(unit, idError, parameters) {
var that = this;
unit = that.parser(unit);
if (void 0 === unit && idError) {
that._incidentOccurred(idError, [parameters])
}
return unit
},
_setType: function(axisType, drawingType) {
var axisTypeMethods, that = this;
switch (axisType) {
case "xyAxes":
axisTypeMethods = _xy_axes2.default;
break;
case "polarAxes":
axisTypeMethods = _polar_axes2.default
}(0, _extend.extend)(that, axisTypeMethods[drawingType])
},
_getSharpParam: function() {
return true
},
_disposeBreaksGroup: _common.noop,
dispose: function() {
var that = this;
[that._axisElementsGroup, that._axisStripGroup, that._axisGroup].forEach(function(g) {
g.dispose()
});
that._strips = that._title = null;
that._axisStripGroup = that._axisConstantLineGroups = that._axisStripLabelGroup = that._axisBreaksGroup = null;
that._axisLineGroup = that._axisElementsGroup = that._axisGridGroup = null;
that._axisGroup = that._axisTitleGroup = null;
that._axesContainerGroup = that._stripsGroup = that._constantLinesGroup = null;
that._renderer = that._options = that._textOptions = that._textFontStyles = null;
that._translator = null;
that._majorTicks = that._minorTicks = null;
that._disposeBreaksGroup()
},
getOptions: function() {
return this._options
},
setPane: function(pane) {
this.pane = pane;
this._options.pane = pane
},
setTypes: function(type, axisType, typeSelector) {
this._options.type = type || this._options.type;
this._options[typeSelector] = axisType || this._options[typeSelector];
this._updateTranslator()
},
resetTypes: function(typeSelector) {
this._options.type = this._initTypes.type;
this._options[typeSelector] = this._initTypes[typeSelector]
},
getTranslator: function() {
return this._translator
},
updateOptions: function(options) {
var that = this,
labelOpt = options.label;
validateAxisOptions(options);
that._options = options;
options.tick = options.tick || {};
options.minorTick = options.minorTick || {};
options.grid = options.grid || {};
options.minorGrid = options.minorGrid || {};
options.title = options.title || {};
options.marker = options.marker || {};
that._initTypes = {
type: options.type,
argumentType: options.argumentType,
valueType: options.valueType
};
that._setTickOffset();
that._isHorizontal = options.isHorizontal;
that.pane = options.pane;
that.name = options.name;
that.priority = options.priority;
that._hasLabelFormat = "" !== labelOpt.format && (0, _type.isDefined)(labelOpt.format);
that._textOptions = {
opacity: labelOpt.opacity,
align: "center",
"class": labelOpt.cssClass
};
that._textFontStyles = _utils2.default.patchFontOptions(labelOpt.font);
if (options.type === _axes_constants2.default.logarithmic) {
if (options.logarithmBaseError) {
that._incidentOccurred("E2104");
delete options.logarithmBaseError
}
}
that._updateTranslator();
that._createConstantLines();
that._strips = (options.strips || []).map(function(o) {
return (0, _strip2.default)(that, o)
});
that._majorTicks = that._minorTicks = null;
that._firstDrawing = true
},
calculateInterval: function(value, prevValue) {
var options = this._options;
if (!options || options.type !== _axes_constants2.default.logarithmic) {
return _abs(value - prevValue)
}
var _ref3 = new _range.Range(this.getTranslator().getBusinessRange()),
allowNegatives = _ref3.allowNegatives,
linearThreshold = _ref3.linearThreshold;
return _abs(getLog(value, options.logarithmBase, allowNegatives, linearThreshold) - getLog(prevValue, options.logarithmBase, allowNegatives, linearThreshold))
},
_processCanvas: function(canvas) {
return canvas
},
updateCanvas: function(canvas) {
var positions = this._orthogonalPositions = {
start: !this._isHorizontal ? canvas.left : canvas.top,
end: !this._isHorizontal ? canvas.width - canvas.right : canvas.height - canvas.bottom
};
this._canvas = canvas;
positions.center = positions.start + (positions.end - positions.start) / 2;
this._translator.updateCanvas(this._processCanvas(canvas));
this._initAxisPositions()
},
getCanvas: function() {
return this._canvas
},
getAxisShift: function() {
return this._axisShift || 0
},
hideTitle: function() {
var that = this;
if (that._options.title.text) {
that._incidentOccurred("W2105", [that._isHorizontal ? "horizontal" : "vertical"]);
that._axisTitleGroup.clear()
}
},
getTitle: function() {
return this._title
},
hideOuterElements: function() {
var that = this,
options = that._options;
if ((options.label.visible || that._outsideConstantLines.length) && !that._translator.getBusinessRange().isEmpty()) {
that._incidentOccurred("W2106", [that._isHorizontal ? "horizontal" : "vertical"]);
that._axisElementsGroup.clear();
callAction(that._outsideConstantLines, "removeLabel")
}
},
adjustViewport: function(businessRange) {
var that = this;
var options = that._options;
var isDiscrete = options.type === _axes_constants2.default.discrete;
var categories = that._seriesData && that._seriesData.categories || [];
var wholeRange = that.adjustRange(getVizRangeObject(options.wholeRange));
var visualRange = that.getViewport() || {};
var result = new _range.Range(businessRange);
that._addConstantLinesToRange(result, "minVisible", "maxVisible");
var minDefined = (0, _type.isDefined)(visualRange.startValue);
var maxDefined = (0, _type.isDefined)(visualRange.endValue);
if (!isDiscrete) {
minDefined = minDefined && (!(0, _type.isDefined)(wholeRange.endValue) || visualRange.startValue < wholeRange.endValue);
maxDefined = maxDefined && (!(0, _type.isDefined)(wholeRange.startValue) || visualRange.endValue > wholeRange.startValue)
}
var minVisible = minDefined ? visualRange.startValue : result.minVisible;
var maxVisible = maxDefined ? visualRange.endValue : result.maxVisible;
if (!isDiscrete) {
result.min = (0, _type.isDefined)(wholeRange.startValue) ? wholeRange.startValue : result.min;
result.max = (0, _type.isDefined)(wholeRange.endValue) ? wholeRange.endValue : result.max
} else {
var categoriesInfo = _utils2.default.getCategoriesInfo(categories, wholeRange.startValue, wholeRange.endValue);
categories = categoriesInfo.categories;
result.categories = categories
}
var adjustedVisualRange = _utils2.default.adjustVisualRange({
axisType: options.type,
dataType: options.dataType,
base: options.logarithmBase
}, {
startValue: minDefined ? visualRange.startValue : void 0,
endValue: maxDefined ? visualRange.endValue : void 0,
length: visualRange.length
}, {
categories: categories,
min: wholeRange.startValue,
max: wholeRange.endValue
}, {
categories: categories,
min: minVisible,
max: maxVisible
});
result.minVisible = adjustedVisualRange.startValue;
result.maxVisible = adjustedVisualRange.endValue;
!(0, _type.isDefined)(result.min) && (result.min = result.minVisible);
!(0, _type.isDefined)(result.max) && (result.max = result.maxVisible);
result.addRange({});
return result
},
adjustRange: function(range) {
range = range || {};
var isDiscrete = this._options.type === _axes_constants2.default.discrete;
var isLogarithmic = this._options.type === _axes_constants2.default.logarithmic;
var disabledNegatives = false === this._options.allowNegatives;
if (isLogarithmic) {
range.startValue = disabledNegatives && range.startValue <= 0 ? null : range.startValue;
range.endValue = disabledNegatives && range.endValue <= 0 ? null : range.endValue
}
if (!isDiscrete && (0, _type.isDefined)(range.startValue) && (0, _type.isDefined)(range.endValue) && range.startValue > range.endValue) {
var tmp = range.endValue;
range.endValue = range.startValue;
range.startValue = tmp
}
return range
},
_getVisualRangeUpdateMode: function(viewport, newRange, oppositeValue) {
var value = this._options.visualRangeUpdateMode;
var translator = this._translator;
var range = this._seriesData;
if (this.isArgumentAxis) {
if ([SHIFT, KEEP, RESET].indexOf(value) === -1) {
if (range.axisType === _axes_constants2.default.discrete) {
var categories = range.categories;
var newCategories = newRange.categories;
var visualRange = this.visualRange();
if (categories && newCategories && categories.length && newCategories.map(function(c) {
return c.valueOf()
}).join(",").indexOf(categories.map(function(c) {
return c.valueOf()
}).join(",")) !== -1 && (visualRange.startValue.valueOf() !== categories[0].valueOf() || visualRange.endValue.valueOf() !== categories[categories.length - 1].valueOf())) {
value = KEEP
} else {
value = RESET
}
} else {
var minPoint = translator.translate(range.min);
var minVisiblePoint = translator.translate(viewport.startValue);
var maxPoint = translator.translate(range.max);
var maxVisiblePoint = translator.translate(viewport.endValue);
if (minPoint === minVisiblePoint && maxPoint === maxVisiblePoint) {
value = RESET
} else {
if (minPoint !== minVisiblePoint && maxPoint === maxVisiblePoint) {
value = SHIFT
} else {
value = KEEP
}
}
}
}
} else {
if ([KEEP, RESET].indexOf(value) === -1) {
if (oppositeValue === KEEP) {
value = KEEP
} else {
value = RESET
}
}
}
return value
},
_handleBusinessRangeChanged: function(oppositeVisualRangeUpdateMode, axisReinitialized, newRange) {
var that = this;
var visualRange = this.visualRange();
if (axisReinitialized || that._translator.getBusinessRange().isEmpty()) {
return
}
var visualRangeUpdateMode = that._lastVisualRangeUpdateMode = that._getVisualRangeUpdateMode(visualRange, newRange, oppositeVisualRangeUpdateMode);
if (!that.isArgumentAxis) {
var viewport = that.getViewport();
if (!(0, _type.isDefined)(viewport.startValue) && !(0, _type.isDefined)(viewport.endValue) && !(0, _type.isDefined)(viewport.length)) {
visualRangeUpdateMode = RESET
}
}
that._prevDataWasEmpty && (visualRangeUpdateMode = KEEP);
if (visualRangeUpdateMode === KEEP) {
that._setVisualRange([visualRange.startValue, visualRange.endValue])
}
if (visualRangeUpdateMode === RESET) {
that._setVisualRange([null, null])
}
if (visualRangeUpdateMode === SHIFT) {
that._setVisualRange({
length: that.getVisualRangeLength()
})
}
},
getVisualRangeLength: function(range) {
var currentBusinessRange = range || this._translator.getBusinessRange();
var type = this._options.type;
var length = void 0;
if (type === _axes_constants2.default.logarithmic) {
length = (0, _math2.adjust)(this.calculateInterval(currentBusinessRange.maxVisible, currentBusinessRange.minVisible))
} else {
if (type === _axes_constants2.default.discrete) {
var categoriesInfo = _utils2.default.getCategoriesInfo(currentBusinessRange.categories, currentBusinessRange.minVisible, currentBusinessRange.maxVisible);
length = categoriesInfo.categories.length
} else {
length = currentBusinessRange.maxVisible - currentBusinessRange.minVisible
}
}
return length
},
getVisualRangeCenter: function(range) {
var businessRange = this._translator.getBusinessRange();
var currentBusinessRange = range || businessRange;
var _options = this._options,
type = _options.type,
logarithmBase = _options.logarithmBase;
var center = void 0;
if (!(0, _type.isDefined)(currentBusinessRange.minVisible) || !(0, _type.isDefined)(currentBusinessRange.maxVisible)) {
return
}
if (type === _axes_constants2.default.logarithmic) {
var allowNegatives = currentBusinessRange.allowNegatives,
linearThreshold = currentBusinessRange.linearThreshold,
minVisible = currentBusinessRange.minVisible,
maxVisible = currentBusinessRange.maxVisible;
center = raiseTo((0, _math2.adjust)(getLog(maxVisible, logarithmBase, allowNegatives, linearThreshold) + getLog(minVisible, logarithmBase, allowNegatives, linearThreshold)) / 2, logarithmBase, allowNegatives, linearThreshold)
} else {
if (type === _axes_constants2.default.discrete) {
var categoriesInfo = _utils2.default.getCategoriesInfo(currentBusinessRange.categories, currentBusinessRange.minVisible, currentBusinessRange.maxVisible);
var index = Math.ceil(categoriesInfo.categories.length / 2) - 1;
center = businessRange.categories.indexOf(categoriesInfo.categories[index])
} else {
center = (currentBusinessRange.maxVisible.valueOf() + currentBusinessRange.minVisible.valueOf()) / 2
}
}
return center
},
setBusinessRange: function(range, axisReinitialized, oppositeVisualRangeUpdateMode, argCategories) {
var that = this;
var options = that._options;
var isDiscrete = options.type === _axes_constants2.default.discrete;
that._handleBusinessRangeChanged(oppositeVisualRangeUpdateMode, axisReinitialized, range);
that._seriesData = new _range.Range(range);
var dataIsEmpty = that._seriesData.isEmpty();
that._prevDataWasEmpty = dataIsEmpty;
that._seriesData.addRange({
categories: options.categories,
dataType: options.dataType,
axisType: options.type,
base: options.logarithmBase,
invert: options.inverted
});
if (options.type === _axes_constants2.default.logarithmic) {
that._seriesData.addRange({
allowNegatives: void 0 !== options.allowNegatives ? options.allowNegatives : range.min <= 0
});
if (!isNaN(options.linearThreshold)) {
that._seriesData.linearThreshold = options.linearThreshold
}
}
if (!isDiscrete) {
if (!(0, _type.isDefined)(that._seriesData.min) && !(0, _type.isDefined)(that._seriesData.max)) {
var visualRange = that.getViewport();
visualRange && that._seriesData.addRange({
min: visualRange.startValue,
max: visualRange.endValue
})
}
var synchronizedValue = options.synchronizedValue;
if ((0, _type.isDefined)(synchronizedValue)) {
that._seriesData.addRange({
min: synchronizedValue,
max: synchronizedValue
})
}
}
that._seriesData.minVisible = void 0 === that._seriesData.minVisible ? that._seriesData.min : that._seriesData.minVisible;
that._seriesData.maxVisible = void 0 === that._seriesData.maxVisible ? that._seriesData.max : that._seriesData.maxVisible;
if (!that.isArgumentAxis && options.showZero) {
that._seriesData.correctValueZeroLevel()
}
that._seriesData.sortCategories(that.getCategoriesSorter(argCategories));
that._seriesData.breaks = that._breaks = that._getScaleBreaks(options, that._seriesData, that._series, that.isArgumentAxis);
that._translator.updateBusinessRange(that.adjustViewport(that._seriesData))
},
_addConstantLinesToRange: function(dataRange, minValueField, maxValueField) {
this._outsideConstantLines.concat(this._insideConstantLines || []).forEach(function(cl) {
if (cl.options.extendAxis) {
var _dataRange$addRange;
var value = cl.getParsedValue();
dataRange.addRange((_dataRange$addRange = {}, _defineProperty(_dataRange$addRange, minValueField, value), _defineProperty(_dataRange$addRange, maxValueField, value), _dataRange$addRange))
}
})
},
setGroupSeries: function(series) {
this._series = series
},
getLabelsPosition: function() {
var that = this,
options = that._options,
position = options.position,
labelShift = options.label.indentFromAxis + (that._axisShift || 0) + that._constantLabelOffset,
axisPosition = that._axisPosition;
return position === TOP || position === LEFT ? axisPosition - labelShift : axisPosition + labelShift
},
getFormattedValue: function(value, options, point) {
var labelOptions = this._options.label;
return (0, _type.isDefined)(value) ? this.formatLabel(value, (0, _extend.extend)(true, {}, labelOptions, options), void 0, point) : null
},
_getBoundaryTicks: function(majors, viewPort) {
var that = this,
length = majors.length,
options = that._options,
customBounds = options.customBoundTicks,
min = viewPort.minVisible,
max = viewPort.maxVisible,
addMinMax = options.showCustomBoundaryTicks ? that._boundaryTicksVisibility : {},
boundaryTicks = [];
if (options.type === _axes_constants2.default.discrete) {
if (that._tickOffset && 0 !== majors.length) {
boundaryTicks = [majors[0], majors[majors.length - 1]]
}
} else {
if (customBounds) {
if (addMinMax.min && (0, _type.isDefined)(customBounds[0])) {
boundaryTicks.push(customBounds[0])
}
if (addMinMax.max && (0, _type.isDefined)(customBounds[1])) {
boundaryTicks.push(customBounds[1])
}
} else {
if (addMinMax.min && (0 === length || majors[0] > min)) {
boundaryTicks.push(min)
}
if (addMinMax.max && (0 === length || majors[length - 1] < max)) {
boundaryTicks.push(max)
}
}
}
return boundaryTicks
},
setPercentLabelFormat: function() {
if (!this._hasLabelFormat) {
this._options.label.format = "percent"
}
},
resetAutoLabelFormat: function() {
if (!this._hasLabelFormat) {
delete this._options.label.format
}
},
getMultipleAxesSpacing: function() {
return this._options.multipleAxesSpacing || 0
},
getTicksValues: function() {
return {
majorTicksValues: convertTicksToValues(this._majorTicks),
minorTicksValues: convertTicksToValues(this._minorTicks)
}
},
setTicks: function(ticks) {
var majors = ticks.majorTicks || [];
this._majorTicks = majors.map(createMajorTick(this, this._renderer, this._getSkippedCategory(majors)));
this._minorTicks = (ticks.minorTicks || []).map(createMinorTick(this, this._renderer));
this._isSynchronized = true
},
_adjustDivisionFactor: function(val) {
return val
},
_getTicks: function(viewPort, incidentOccurred, skipTickGeneration) {
var that = this,
options = that._options,
customTicks = options.customTicks,
customMinorTicks = options.customMinorTicks;
return getTickGenerator(options, incidentOccurred || that._incidentOccurred, skipTickGeneration, that._translator.getBusinessRange().isEmpty(), that._adjustDivisionFactor.bind(that), viewPort)({
min: viewPort.minVisible,
max: viewPort.maxVisible,
categories: viewPort.categories,
isSpacedMargin: viewPort.isSpacedMargin,
checkMinDataVisibility: viewPort.checkMinDataVisibility,
checkMaxDataVisibility: viewPort.checkMaxDataVisibility
}, that._getScreenDelta(), options.tickInterval, "ignore" === options.label.overlappingBehavior || options.forceUserTickInterval, {
majors: customTicks,
minors: customMinorTicks
}, options.minorTickInterval, options.minorTickCount, that._breaks)
},
_createTicksAndLabelFormat: function(range, incidentOccurred) {
var ticks, options = this._options;
ticks = this._getTicks(range, incidentOccurred, false);
if (!range.isEmpty() && options.type === _axes_constants2.default.discrete && "datetime" === options.dataType && !this._hasLabelFormat && ticks.ticks.length) {
options.label.format = _format_helper2.default.getDateFormatByTicks(ticks.ticks)
}
return ticks
},
getAggregationInfo: function(useAllAggregatedPoints, range) {
var that = this,
options = that._options,
marginOptions = that._marginOptions,
businessRange = new _range.Range(that.getTranslator().getBusinessRange()).addRange(range),
visualRange = that.getViewport(),
minVisible = visualRange && (0, _type.isDefined)(visualRange.startValue) ? visualRange.startValue : businessRange.minVisible,
maxVisible = visualRange && (0, _type.isDefined)(visualRange.endValue) ? visualRange.endValue : businessRange.maxVisible,
ticks = [];
if (options.type === _axes_constants2.default.discrete && options.aggregateByCategory) {
return {
aggregateByCategory: true
}
}
var aggregationInterval = options.aggregationInterval;
var aggregationGroupWidth = options.aggregationGroupWidth;
if (!aggregationGroupWidth && marginOptions) {
if (marginOptions.checkInterval) {
aggregationGroupWidth = options.axisDivisionFactor
}
if (marginOptions.sizePointNormalState) {
aggregationGroupWidth = Math.min(marginOptions.sizePointNormalState, options.axisDivisionFactor)
}
}
var minInterval = !options.aggregationGroupWidth && !aggregationInterval && range.interval;
var generateTicks = configureGenerator(options, aggregationGroupWidth, businessRange, that._getScreenDelta(), minInterval);
var tickInterval = generateTicks(aggregationInterval, true, minVisible, maxVisible, that._breaks).tickInterval;
if (options.type !== _axes_constants2.default.discrete) {
var min = useAllAggregatedPoints ? businessRange.min : minVisible;
var max = useAllAggregatedPoints ? businessRange.max : maxVisible;
if ((0, _type.isDefined)(min) && (0, _type.isDefined)(max)) {
var add = _utils2.default.getAddFunction({
base: options.logarithmBase,
axisType: options.type,
dataType: options.dataType
}, false);
var start = min;
var end = max;
if (!useAllAggregatedPoints) {
var maxMinDistance = Math.max(that.calculateInterval(max, min), "datetime" === options.dataType ? (0, _date.dateToMilliseconds)(tickInterval) : tickInterval);
start = add(min, maxMinDistance, -1);
end = add(max, maxMinDistance)
}
start = start < businessRange.min ? businessRange.min : start;
end = end > businessRange.max ? businessRange.max : end;
var breaks = that._getScaleBreaks(options, {
minVisible: start,
maxVisible: end
}, that._series, that.isArgumentAxis);
ticks = generateTicks(tickInterval, false, start, end, breaks).ticks
}
}
that._aggregationInterval = tickInterval;
return {
interval: tickInterval,
ticks: ticks
}
},
createTicks: function(canvas) {
var ticks, boundaryTicks, range, that = this,
renderer = that._renderer,
options = that._options;
if (!canvas) {
return
}
that._isSynchronized = false;
that.updateCanvas(canvas);
that._estimatedTickInterval = that._getTicks(that.adjustViewport(this._seriesData), _common.noop, true).tickInterval;
range = that._getViewportRange();
var margins = this._calculateValueMargins();
range.addRange({
minVisible: margins.minValue,
maxVisible: margins.maxValue,
isSpacedMargin: margins.isSpacedMargin,
checkMinDataVisibility: !this.isArgumentAxis && margins.checkInterval && !(0, _type.isDefined)(options.min) && margins.minValue.valueOf() > 0,
checkMaxDataVisibility: !this.isArgumentAxis && margins.checkInterval && !(0, _type.isDefined)(options.max) && margins.maxValue.valueOf() < 0
});
ticks = that._createTicksAndLabelFormat(range);
boundaryTicks = that._getBoundaryTicks(ticks.ticks, that._getViewportRange());
if (options.showCustomBoundaryTicks && boundaryTicks.length) {
that._boundaryTicks = [boundaryTicks[0]].map(createBoundaryTick(that, renderer, true));
if (boundaryTicks.length > 1) {
that._boundaryTicks = that._boundaryTicks.concat([boundaryTicks[1]].map(createBoundaryTick(that, renderer, false)))
}
} else {
that._boundaryTicks = []
}
var minors = (ticks.minorTicks || []).filter(function(minor) {
return !boundaryTicks.some(function(boundary) {
return valueOf(boundary) === valueOf(minor)
})
});
that._tickInterval = ticks.tickInterval;
that._minorTickInterval = ticks.minorTickInterval;
var oldMajorTicks = that._majorTicks || [];
var majorTicksByValues = oldMajorTicks.reduce(function(r, t) {
r[t.value.valueOf()] = t;
return r
}, {});
var sameType = (0, _type.type)(ticks.ticks[0]) === (0, _type.type)(oldMajorTicks[0] && oldMajorTicks[0].value);
var skippedCategory = that._getSkippedCategory(ticks.ticks);
var majorTicks = ticks.ticks.map(function(v) {
var tick = majorTicksByValues[v.valueOf()];
if (tick && sameType) {
delete majorTicksByValues[v.valueOf()];
tick.setSkippedCategory(skippedCategory);
return tick
} else {
return createMajorTick(that, renderer, skippedCategory)(v)
}
});
that._majorTicks = majorTicks;
var oldMinorTicks = that._minorTicks || [];
that._minorTicks = minors.map(function(v, i) {
var minorTick = oldMinorTicks[i];
if (minorTick) {
minorTick.updateValue(v);
return minorTick
}
return createMinorTick(that, renderer)(v)
});
that._ticksToRemove = Object.keys(majorTicksByValues).map(function(k) {
return majorTicksByValues[k]
}).concat(oldMinorTicks.slice(that._minorTicks.length, oldMinorTicks.length));
that._correctedBreaks = ticks.breaks;
that._reinitTranslator(that._getViewportRange())
},
_reinitTranslator: function(range) {
var that = this,
translator = that._translator;
if (that._correctedBreaks) {
range.breaks = that._correctedBreaks
}
if (that._isSynchronized) {
return
}
translator.updateBusinessRange(that.adjustViewport(range))
},
_getViewportRange: function() {
return this.adjustViewport(this._seriesData)
},
setMarginOptions: function(options) {
this._marginOptions = options
},
getMarginOptions: function() {
return (0, _type.isDefined)(this._marginOptions) ? this._marginOptions : {}
},
allowToExtendVisualRange: function(isEnd) {
var wholeRange = this.adjustRange(getVizRangeObject(this._options.wholeRange));
var bound = isEnd ? wholeRange.endValue : wholeRange.startValue;
return !this.isArgumentAxis || !(0, _type.isDefined)(bound) && this.isExtremePosition(isEnd)
},
_calculateRangeInterval: function(interval) {
var isDateTime = "datetime" === this._options.dataType,
minArgs = [],
addToArgs = function(value) {
(0, _type.isDefined)(value) && minArgs.push(isDateTime ? (0, _date.dateToMilliseconds)(value) : value)
};
addToArgs(this._tickInterval);
addToArgs(this._estimatedTickInterval);
(0, _type.isDefined)(interval) && minArgs.push(interval);
addToArgs(this._aggregationInterval);
return this._calculateWorkWeekInterval(_min.apply(this, minArgs))
},
_calculateWorkWeekInterval: function(businessInterval) {
var options = this._options;
if ("datetime" === options.dataType && options.workdaysOnly && businessInterval) {
var workWeek = options.workWeek.length * dateIntervals.day;
var weekend = dateIntervals.week - workWeek;
if (workWeek !== businessInterval && weekend < businessInterval) {
var weekendsCount = Math.ceil(businessInterval / dateIntervals.week);
businessInterval = weekend >= businessInterval ? dateIntervals.day : businessInterval - weekend * weekendsCount
} else {
if (weekend >= businessInterval && businessInterval > dateIntervals.day) {
businessInterval = dateIntervals.day
}
}
}
return businessInterval
},
_calculateValueMargins: function(ticks) {
this._resetMargins();
var that = this;
var margins = that.getMarginOptions();
var marginSize = (margins.size || 0) / 2;
var options = that._options;
var dataRange = this._getViewportRange();
var viewPort = this.getViewport();
var screenDelta = that._getScreenDelta();
var isDiscrete = (options.type || "").indexOf(_axes_constants2.default.discrete) !== -1;
var valueMarginsEnabled = options.valueMarginsEnabled && !isDiscrete;
var translator = that._translator;
var minValueMargin = options.minValueMargin;
var maxValueMargin = options.maxValueMargin;
var minPadding = 0;
var maxPadding = 0;
var interval = 0;
var rangeInterval = void 0;
if (dataRange.stubData || !screenDelta) {
return {
startPadding: 0,
endPadding: 0
}
}
function getConvertIntervalCoefficient(intervalInPx) {
var ratioOfCanvasRange = translator.ratioOfCanvasRange();
return ratioOfCanvasRange / (ratioOfCanvasRange * screenDelta / (intervalInPx + screenDelta))
}
if (that.isArgumentAxis && margins.checkInterval) {
rangeInterval = that._calculateRangeInterval(dataRange.interval);
var pxInterval = translator.getInterval(rangeInterval);
if (isFinite(pxInterval)) {
interval = Math.ceil(pxInterval / (2 * getConvertIntervalCoefficient(pxInterval)))
} else {
rangeInterval = 0
}
}
var minPercentPadding = void 0;
var maxPercentPadding = void 0;
var maxPaddingValue = screenDelta * MAX_MARGIN_VALUE / 2;
if (valueMarginsEnabled) {
if ((0, _type.isDefined)(minValueMargin)) {
minPercentPadding = isFinite(minValueMargin) ? minValueMargin : 0
} else {
minPadding = Math.max(marginSize, interval);
minPadding = Math.min(maxPaddingValue, minPadding)
}
if ((0, _type.isDefined)(maxValueMargin)) {
maxPercentPadding = isFinite(maxValueMargin) ? maxValueMargin : 0
} else {
maxPadding = Math.max(marginSize, interval);
maxPadding = Math.min(maxPaddingValue, maxPadding)
}
}
var percentStick = margins.percentStick && !this.isArgumentAxis;
if (percentStick) {
if (1 === _abs(dataRange.max)) {
maxPadding = 0
}
if (1 === _abs(dataRange.min)) {
minPadding = 0
}
}
var canvasStartEnd = that._getCanvasStartEnd();
var commonMargin = 1 + (minPercentPadding || 0) + (maxPercentPadding || 0);
var screenDeltaWithMargins = (screenDelta - minPadding - maxPadding) / commonMargin || screenDelta;
if (void 0 !== minPercentPadding || void 0 !== maxPercentPadding) {
if (void 0 !== minPercentPadding) {
minPadding = screenDeltaWithMargins * minPercentPadding
}
if (void 0 !== maxPercentPadding) {
maxPadding = screenDeltaWithMargins * maxPercentPadding
}
}
var minValue = void 0;
var maxValue = void 0;
if (options.type !== _axes_constants2.default.discrete && ticks && ticks.length > 1 && !options.skipViewportExtending && !viewPort.action && false !== options.endOnTick) {
var length = ticks.length;
var firstTickPosition = translator.translate(ticks[0].value);
var lastTickPosition = translator.translate(ticks[length - 1].value);
var invertMultiplier = firstTickPosition > lastTickPosition ? -1 : 1;
var minTickPadding = _max(invertMultiplier * (canvasStartEnd.start - firstTickPosition), 0);
var maxTickPadding = _max(invertMultiplier * (lastTickPosition - canvasStartEnd.end), 0);
if (minTickPadding > minPadding || maxTickPadding > maxPadding) {
var commonPadding = maxTickPadding + minTickPadding;
var coeff = getConvertIntervalCoefficient(commonPadding);
if (minTickPadding >= minPadding) {
minValue = ticks[0].value
}
if (maxTickPadding >= maxPadding) {
maxValue = ticks[length - 1].value
}
minPadding = _max(minTickPadding, minPadding) / coeff;
maxPadding = _max(maxTickPadding, maxPadding) / coeff
}
}
minPercentPadding = void 0 === minPercentPadding ? minPadding / screenDeltaWithMargins : minPercentPadding;
maxPercentPadding = void 0 === maxPercentPadding ? maxPadding / screenDeltaWithMargins : maxPercentPadding;
if (!isDiscrete) {
if (this._translator.isInverted()) {
minValue = (0, _type.isDefined)(minValue) ? minValue : translator.from(canvasStartEnd.start + screenDelta * minPercentPadding, -1);
maxValue = (0, _type.isDefined)(maxValue) ? maxValue : translator.from(canvasStartEnd.end - screenDelta * maxPercentPadding, 1)
} else {
minValue = (0, _type.isDefined)(minValue) ? minValue : translator.from(canvasStartEnd.start - screenDelta * minPercentPadding, -1);
maxValue = (0, _type.isDefined)(maxValue) ? maxValue : translator.from(canvasStartEnd.end + screenDelta * maxPercentPadding, 1)
}
}
function correctZeroLevel(minPoint, maxPoint) {
var minExpectedPadding = _abs(canvasStartEnd.start - minPoint);
var maxExpectedPadding = _abs(canvasStartEnd.end - maxPoint);
var coeff = getConvertIntervalCoefficient(minExpectedPadding + maxExpectedPadding);
minPadding = minExpectedPadding / coeff;
maxPadding = maxExpectedPadding / coeff
}
if (!that.isArgumentAxis) {
if (minValue * dataRange.min <= 0 && minValue * dataRange.minVisible <= 0) {
correctZeroLevel(translator.translate(0), translator.translate(maxValue));
minValue = 0
}
if (maxValue * dataRange.max <= 0 && maxValue * dataRange.maxVisible <= 0) {
correctZeroLevel(translator.translate(minValue), translator.translate(0));
maxValue = 0
}
}
return {
startPadding: this._translator.isInverted() ? maxPadding : minPadding,
endPadding: this._translator.isInverted() ? minPadding : maxPadding,
minValue: minValue,
maxValue: maxValue,
interval: rangeInterval,
isSpacedMargin: minPadding === maxPadding && 0 !== minPadding
}
},
applyMargins: function() {
if (this._isSynchronized) {
return
}
var margins = this._calculateValueMargins(this._majorTicks);
var canvas = (0, _extend.extend)({}, this._canvas, {
startPadding: margins.startPadding,
endPadding: margins.endPadding
});
this._translator.updateCanvas(this._processCanvas(canvas));
if (isFinite(margins.interval)) {
var br = this._translator.getBusinessRange();
br.addRange({
interval: margins.interval
});
this._translator.updateBusinessRange(br)
}
},
_resetMargins: function() {
this._reinitTranslator(this._getViewportRange());
if (this._canvas) {
this._translator.updateCanvas(this._processCanvas(this._canvas))
}
},
_createConstantLines: function() {
var _this = this;
var constantLines = (this._options.constantLines || []).map(function(o) {
return (0, _constant_line2.default)(_this, o)
});
this._outsideConstantLines = constantLines.filter(function(l) {
return "outside" === l.labelPosition
});
this._insideConstantLines = constantLines.filter(function(l) {
return "inside" === l.labelPosition
})
},
draw: function(canvas, borderOptions) {
var that = this;
var options = this._options;
that.borderOptions = borderOptions || {
visible: false
};
that._resetMargins();
that.createTicks(canvas);
that.applyMargins();
that._clearAxisGroups();
initTickCoords(that._majorTicks);
initTickCoords(that._minorTicks);
initTickCoords(that._boundaryTicks);
that._axisGroup.append(that._axesContainerGroup);
that._drawAxis();
that._drawTitle();
drawTickMarks(that._majorTicks, options.tick);
drawTickMarks(that._minorTicks, options.minorTick);
drawTickMarks(that._boundaryTicks, options.tick);
var drawGridLine = that._getGridLineDrawer();
drawGrids(that._majorTicks, drawGridLine);
drawGrids(that._minorTicks, drawGridLine);
callAction(that._majorTicks, "drawLabel", that._getViewportRange());
that._majorTicks.forEach(function(tick) {
tick.labelRotationAngle = 0;
tick.labelAlignment = void 0;
tick.labelOffset = 0
});
callAction(that._outsideConstantLines.concat(that._insideConstantLines), "draw");
callAction(that._strips, "draw");
that._dateMarkers = that._drawDateMarkers() || [];
that._labelAxesGroup && that._axisStripLabelGroup.append(that._labelAxesGroup);
that._gridContainerGroup && that._axisGridGroup.append(that._gridContainerGroup);
that._stripsGroup && that._axisStripGroup.append(that._stripsGroup);
if (that._constantLinesGroup) {
that._axisConstantLineGroups.above.inside.append(that._constantLinesGroup.above);
that._axisConstantLineGroups.above.outside1.append(that._constantLinesGroup.above);
that._axisConstantLineGroups.above.outside2.append(that._constantLinesGroup.above);
that._axisConstantLineGroups.under.inside.append(that._constantLinesGroup.under);
that._axisConstantLineGroups.under.outside1.append(that._constantLinesGroup.under);
that._axisConstantLineGroups.under.outside2.append(that._constantLinesGroup.under)
}
that._measureTitle();
measureLabels(that._majorTicks);
var textWidth = void 0;
var textHeight = void 0;
var convertedTickInterval = void 0;
var tickInterval = that._tickInterval;
if ((0, _type.isDefined)(tickInterval)) {
convertedTickInterval = that.getTranslator().getInterval("datetime" === options.dataType ? (0, _date.dateToMilliseconds)(tickInterval) : tickInterval)
}
if (that._isHorizontal) {
textWidth = convertedTickInterval;
textHeight = options.placeholderSize
} else {
textWidth = options.placeholderSize;
textHeight = convertedTickInterval
}
var displayMode = that._validateDisplayMode(options.label.displayMode);
var overlappingMode = that._validateOverlappingMode(options.label.overlappingBehavior, displayMode);
var wordWrapMode = options.label.wordWrap || "none";
var overflowMode = options.label.textOverflow || "none";
if (("none" !== wordWrapMode || "none" !== overflowMode) && displayMode !== ROTATE && overlappingMode !== ROTATE && "auto" !== overlappingMode) {
var correctByWidth = false;
var correctByHeight = false;
if (textWidth) {
if (that._majorTicks.some(function(tick) {
return tick.labelBBox.width > textWidth
})) {
correctByWidth = true
}
}
if (textHeight) {
if (that._majorTicks.some(function(tick) {
return tick.labelBBox.height > textHeight
})) {
correctByHeight = true
}
}
if (correctByWidth || correctByHeight) {
that._majorTicks.forEach(function(tick) {
tick.label && tick.label.setMaxSize(textWidth, textHeight, options.label)
});
measureLabels(that._majorTicks)
}
}
measureLabels(that._outsideConstantLines);
measureLabels(that._insideConstantLines);
measureLabels(that._strips);
measureLabels(that._dateMarkers);
that._adjustConstantLineLabels(that._insideConstantLines);
that._adjustStripLabels();
var offset = that._constantLabelOffset = that._adjustConstantLineLabels(that._outsideConstantLines);
if (!that._translator.getBusinessRange().isEmpty()) {
that._setLabelsPlacement();
offset = that._adjustLabels(offset)
}
offset = that._adjustDateMarkers(offset);
that._adjustTitle(offset)
},
_measureTitle: _common.noop,
animate: function() {
callAction(this._majorTicks, "animateLabels")
},
updateSize: function(canvas, animate) {
var updateTitle = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : true;
var that = this;
that.updateCanvas(canvas);
if (updateTitle) {
that._checkTitleOverflow();
that._measureTitle();
that._updateTitleCoords()
}
that._reinitTranslator(that._getViewportRange());
that.applyMargins();
var animationEnabled = !that._firstDrawing && animate;
var options = this._options;
initTickCoords(that._majorTicks);
initTickCoords(that._minorTicks);
initTickCoords(that._boundaryTicks);
cleanUpInvalidTicks(that._majorTicks);
cleanUpInvalidTicks(that._minorTicks);
cleanUpInvalidTicks(that._boundaryTicks);
if (this._axisElement) {
that._updateAxisElementPosition()
}
updateTicksPosition(that._majorTicks, options.tick, animationEnabled);
updateTicksPosition(that._minorTicks, options.minorTick, animationEnabled);
updateTicksPosition(that._boundaryTicks, options.tick);
callAction(that._majorTicks, "updateLabelPosition", animationEnabled);
that._outsideConstantLines.concat(that._insideConstantLines || []).forEach(function(l) {
return l.updatePosition(animationEnabled)
});
callAction(that._strips, "updatePosition", animationEnabled);
updateGridsPosition(that._majorTicks, animationEnabled);
updateGridsPosition(that._minorTicks, animationEnabled);
if (animationEnabled) {
callAction(that._ticksToRemove || [], "fadeOutElements")
}
that.prepareAnimation();
that._ticksToRemove = null;
if (!that._translator.getBusinessRange().isEmpty()) {
that._firstDrawing = false
}
},
prepareAnimation: function() {
var that = this;
var action = "saveCoords";
callAction(that._majorTicks, action);
callAction(that._minorTicks, action);
callAction(that._insideConstantLines, action);
callAction(that._outsideConstantLines, action);
callAction(that._strips, action)
},
applyClipRects: function(elementsClipID, canvasClipID) {
this._axisGroup.attr({
"clip-path": canvasClipID
});
this._axisStripGroup.attr({
"clip-path": elementsClipID
})
},
_mergeViewportOptions: function() {
var that = this;
var options = that._options;
var visualRange = {};
var visualRangeOptionValue = options._customVisualRange;
if (((0, _type.isDefined)(options.max) || (0, _type.isDefined)(options.min)) && !(0, _type.isDefined)(visualRangeOptionValue.startValue) && !(0, _type.isDefined)(visualRangeOptionValue.endValue) && !(0, _type.isDefined)(visualRangeOptionValue.length)) {
visualRange = {
startValue: options.min,
endValue: options.max
}
} else {
visualRange = visualRangeOptionValue
}
that._setVisualRange(visualRange)
},
_validateVisualRange: function(visualRange) {
var range = getVizRangeObject(visualRange);
if (void 0 !== range.startValue) {
range.startValue = this.validateUnit(range.startValue)
}
if (void 0 !== range.endValue) {
range.endValue = this.validateUnit(range.endValue)
}
return convertVisualRangeObject(range, visualRange)
},
_validateOptions: function(options) {
var that = this;
if (void 0 !== options.min) {
options.min = that.validateUnit(options.min, "E2106")
}
if (void 0 !== options.max) {
options.max = that.validateUnit(options.max, "E2106")
}
options.wholeRange = that._validateVisualRange(options.wholeRange);
options.visualRange = options._customVisualRange = that._validateVisualRange(options._customVisualRange);
that._mergeViewportOptions()
},
validate: function() {
var that = this;
var options = that._options;
var dataType = that.isArgumentAxis ? options.argumentType : options.valueType;
var parser = dataType ? _parse_utils2.default.getParser(dataType) : function(unit) {
return unit
};
that.parser = parser;
options.dataType = dataType;
that._validateOptions(options)
},
resetVisualRange: function(isSilent) {
this._seriesData.minVisible = this._seriesData.min;
this._seriesData.maxVisible = this._seriesData.max;
this.handleZooming([null, null], {
start: !!isSilent,
end: !!isSilent
})
},
_setVisualRange: function(visualRange, allowPartialUpdate) {
var range = this.adjustRange(_utils2.default.getVizRangeObject(visualRange));
if (allowPartialUpdate) {
(0, _type.isDefined)(range.startValue) && (this._viewport.startValue = range.startValue);
(0, _type.isDefined)(range.endValue) && (this._viewport.endValue = range.endValue)
} else {
this._viewport = range
}
},
_applyZooming: function(visualRange, allowPartialUpdate) {
var that = this;
that._resetVisualRangeOption();
that._setVisualRange(visualRange, allowPartialUpdate);
var viewPort = that.getViewport();
that._breaks = that._getScaleBreaks(that._options, {
minVisible: viewPort.startValue,
maxVisible: viewPort.endValue
}, that._series, that.isArgumentAxis);
that._translator.updateBusinessRange(that._getViewportRange())
},
getZoomStartEventArg: function(event, actionType) {
return {
axis: this,
range: this.visualRange(),
cancel: false,
event: event,
actionType: actionType
}
},
getZoomEndEventArg: function(previousRange, event, actionType, zoomFactor, shift) {
var newRange = this.visualRange();
return {
axis: this,
previousRange: previousRange,
range: newRange,
cancel: false,
event: event,
actionType: actionType,
zoomFactor: zoomFactor,
shift: shift,
rangeStart: newRange.startValue,
rangeEnd: newRange.endValue
}
},
getZoomBounds: function() {
var wholeRange = _utils2.default.getVizRangeObject(this._options.wholeRange);
var range = this.getTranslator().getBusinessRange();
var secondPriorityRange = {
startValue: getZoomBoundValue(this._initRange.startValue, range.min),
endValue: getZoomBoundValue(this._initRange.endValue, range.max)
};
return {
startValue: getZoomBoundValue(wholeRange.startValue, secondPriorityRange.startValue),
endValue: getZoomBoundValue(wholeRange.endValue, secondPriorityRange.endValue)
}
},
setInitRange: function() {
this._initRange = {};
if (0 === Object.keys(this._options.wholeRange || {}).length) {
this._initRange = this.getZoomBounds()
}
},
_resetVisualRangeOption: function() {
this._options._customVisualRange = {}
},
setCustomVisualRange: function(range) {
this._options._customVisualRange = range
},
visualRange: function visualRange() {
var that = this;
var args = arguments;
var visualRange = void 0;
if (0 === args.length) {
var adjustedRange = that._getAdjustedBusinessRange();
var startValue = adjustedRange.minVisible;
var endValue = adjustedRange.maxVisible;
if (that._options.type === _axes_constants2.default.discrete) {
startValue = (0, _type.isDefined)(startValue) ? startValue : adjustedRange.categories[0];
endValue = (0, _type.isDefined)(endValue) ? endValue : adjustedRange.categories[adjustedRange.categories.length - 1];
return {
startValue: startValue,
endValue: endValue,
categories: _utils2.default.getCategoriesInfo(adjustedRange.categories, startValue, endValue).categories
}
}
return {
startValue: startValue,
endValue: endValue
}
} else {
if (_isArray(args[0])) {
visualRange = args[0]
} else {
if ((0, _type.isPlainObject)(args[0])) {
visualRange = (0, _extend.extend)({}, args[0])
} else {
visualRange = [args[0], args[1]]
}
}
}
var zoomResults = that.handleZooming(visualRange, args[1]);
if (!zoomResults.isPrevented) {
that._visualRange(that, zoomResults)
}
},
handleZooming: function(visualRange, preventEvents, domEvent, action) {
var that = this;
preventEvents = preventEvents || {};
if ((0, _type.isDefined)(visualRange)) {
visualRange = that._validateVisualRange(visualRange);
visualRange.action = action
}
var zoomStartEvent = that.getZoomStartEventArg(domEvent, action);
var previousRange = zoomStartEvent.range;
!preventEvents.start && that._eventTrigger("zoomStart", zoomStartEvent);
var zoomResults = {
isPrevented: zoomStartEvent.cancel,
skipEventRising: preventEvents.skipEventRising,
range: visualRange || zoomStartEvent.range
};
if (!zoomStartEvent.cancel) {
(0, _type.isDefined)(visualRange) && that._applyZooming(visualRange, preventEvents.allowPartialUpdate);
if (!(0, _type.isDefined)(that._storedZoomEndParams)) {
that._storedZoomEndParams = {
startRange: previousRange,
type: this.getOptions().type
}
}
that._storedZoomEndParams.event = domEvent;
that._storedZoomEndParams.action = action;
that._storedZoomEndParams.prevent = !!preventEvents.end
}
return zoomResults
},
handleZoomEnd: function() {
var that = this;
if ((0, _type.isDefined)(that._storedZoomEndParams) && !that._storedZoomEndParams.prevent) {
var previousRange = that._storedZoomEndParams.startRange;
var domEvent = that._storedZoomEndParams.event;
var action = that._storedZoomEndParams.action;
var previousBusinessRange = {
minVisible: previousRange.startValue,
maxVisible: previousRange.endValue,
categories: previousRange.categories
};
var typeIsNotChanged = that.getOptions().type === that._storedZoomEndParams.type;
var shift = typeIsNotChanged ? (0, _math2.adjust)(that.getVisualRangeCenter() - that.getVisualRangeCenter(previousBusinessRange)) : NaN;
var zoomFactor = typeIsNotChanged ? +(Math.round(that.getVisualRangeLength(previousBusinessRange) / that.getVisualRangeLength() + "e+2") + "e-2") : NaN;
var zoomEndEvent = that.getZoomEndEventArg(previousRange, domEvent, action, zoomFactor, shift);
zoomEndEvent.cancel = that.isZoomingLowerLimitOvercome(1 === zoomFactor ? "pan" : "zoom", zoomFactor);
that._eventTrigger("zoomEnd", zoomEndEvent);
if (zoomEndEvent.cancel) {
that.restorePreviousVisualRange(previousRange)
}
that._storedZoomEndParams = null
}
},
restorePreviousVisualRange: function(previousRange) {
var that = this;
that._storedZoomEndParams = null;
that._applyZooming(previousRange);
that._visualRange(that, previousRange)
},
isZoomingLowerLimitOvercome: function(actionType, zoomFactor, range) {
var that = this;
var options = that._options;
var minZoom = options.minVisualRangeLength;
var isOvercoming = "zoom" === actionType && zoomFactor >= 1;
var businessRange = that._translator.getBusinessRange();
var visualRange = void 0;
if ((0, _type.isDefined)(range)) {
visualRange = that.adjustRange(_utils2.default.getVizRangeObject(range));
visualRange = {
minVisible: visualRange.startValue,
maxVisible: visualRange.endValue,
categories: businessRange.categories
}
}
var visualRangeLength = that.getVisualRangeLength(visualRange);
if ("discrete" !== options.type) {
if ((0, _type.isDefined)(minZoom)) {
if ("datetime" === options.dataType && !(0, _type.isNumeric)(minZoom)) {
minZoom = (0, _date.dateToMilliseconds)(minZoom)
}
isOvercoming &= minZoom >= visualRangeLength
} else {
var canvasLength = that._translator.canvasLength;
var fullRange = {
minVisible: businessRange.min,
maxVisible: businessRange.max,
categories: businessRange.categories
};
isOvercoming &= that.getVisualRangeLength(fullRange) / canvasLength >= visualRangeLength
}
} else {
!(0, _type.isDefined)(minZoom) && (minZoom = 1);
isOvercoming &= (0, _type.isDefined)(range) && that.getVisualRangeLength() === minZoom && visualRangeLength <= minZoom
}
return !!isOvercoming
},
dataVisualRangeIsReduced: function() {
var minDataValue = void 0;
var maxDataValue = void 0;
var translator = this.getTranslator();
if ("discrete" === this._options.type) {
var categories = translator.getBusinessRange().categories;
minDataValue = categories[0];
maxDataValue = categories[categories.length - 1]
} else {
var seriesData = this._seriesData;
minDataValue = seriesData.min;
maxDataValue = seriesData.max
}
if (!(0, _type.isDefined)(minDataValue) || !(0, _type.isDefined)(maxDataValue)) {
return false
}
var startPoint = translator.translate(minDataValue);
var endPoint = translator.translate(maxDataValue);
var edges = [Math.min(startPoint, endPoint), Math.max(startPoint, endPoint)];
var visualRange = this.visualRange();
var visualRangeStartPoint = translator.translate(visualRange.startValue);
var visualRangeEndPoint = translator.translate(visualRange.endValue);
return visualRangeStartPoint > edges[0] && visualRangeStartPoint < edges[1] || visualRangeEndPoint > edges[0] && visualRangeEndPoint < edges[1] || visualRangeStartPoint === visualRangeEndPoint && edges[0] !== edges[1]
},
isExtremePosition: function(isMax) {
var extremeDataValue = void 0;
var seriesData = void 0;
if ("discrete" === this._options.type) {
seriesData = this._translator.getBusinessRange();
extremeDataValue = isMax ? seriesData.categories[seriesData.categories.length - 1] : seriesData.categories[0]
} else {
seriesData = this.getZoomBounds();
extremeDataValue = isMax ? seriesData.endValue : seriesData.startValue
}
var translator = this.getTranslator();
var extremePoint = translator.translate(extremeDataValue);
var visualRange = this.visualRange();
var visualRangePoint = isMax ? translator.translate(visualRange.endValue) : translator.translate(visualRange.startValue);
return _abs(visualRangePoint - extremePoint) < SCROLL_THRESHOLD
},
getViewport: function() {
return this._viewport
},
getFullTicks: function() {
var majors = this._majorTicks || [];
if (this._options.type === _axes_constants2.default.discrete) {
return convertTicksToValues(majors)
} else {
return convertTicksToValues(majors.concat(this._minorTicks, this._boundaryTicks)).sort(function(a, b) {
return valueOf(a) - valueOf(b)
})
}
},
measureLabels: function(canvas, withIndents) {
var ticks, maxText, text, box, tickInterval, that = this,
options = that._options,
widthAxis = options.visible ? options.width : 0,
indent = withIndents ? options.label.indentFromAxis + .5 * options.tick.length : 0,
viewportRange = that._getViewportRange();
if (viewportRange.isEmpty() || !options.label.visible || !that._axisElementsGroup) {
return {
height: widthAxis,
width: widthAxis,
x: 0,
y: 0
}
}
if (that._majorTicks) {
ticks = convertTicksToValues(that._majorTicks)
} else {
this.updateCanvas(canvas);
ticks = that._createTicksAndLabelFormat(viewportRange, _common.noop);
tickInterval = ticks.tickInterval;
ticks = ticks.ticks
}
maxText = ticks.reduce(function(prevLabel, tick, index) {
var label = that.formatLabel(tick, options.label, viewportRange, void 0, tickInterval, ticks);
if (prevLabel.length < label.length) {
return label
} else {
return prevLabel
}
}, that.formatLabel(ticks[0], options.label, viewportRange, void 0, tickInterval, ticks));
text = that._renderer.text(maxText, 0, 0).css(that._textFontStyles).attr(that._textOptions).append(that._renderer.root);
box = text.getBBox();
text.remove();
return {
x: box.x,
y: box.y,
width: box.width + indent,
height: box.height + indent
}
},
_setLabelsPlacement: function() {
if (!this._options.label.visible) {
return
}
var notRecastStep, step, that = this,
labelOpt = that._options.label,
displayMode = that._validateDisplayMode(labelOpt.displayMode),
overlappingMode = that._validateOverlappingMode(labelOpt.overlappingBehavior, displayMode),
ignoreOverlapping = "none" === overlappingMode || "ignore" === overlappingMode,
behavior = {
rotationAngle: labelOpt.rotationAngle,
staggeringSpacing: labelOpt.staggeringSpacing
},
boxes = that._majorTicks.map(function(tick) {
return tick.labelBBox
});
step = that._getStep(boxes);
switch (displayMode) {
case ROTATE:
if (ignoreOverlapping) {
notRecastStep = true;
step = 1
}
that._applyLabelMode(displayMode, step, boxes, labelOpt, notRecastStep);
break;
case "stagger":
if (ignoreOverlapping) {
step = 2
}
that._applyLabelMode(displayMode, _max(step, 2), boxes, labelOpt);
break;
default:
that._applyLabelOverlapping(boxes, overlappingMode, step, behavior)
}
},
_applyLabelOverlapping: function(boxes, mode, step, behavior) {
var that = this,
labelOpt = that._options.label,
majorTicks = that._majorTicks;
if ("none" === mode || "ignore" === mode) {
return
}
var checkLabels = function(box, index, array) {
if (0 === index) {
return false
}
return _axes_constants2.default.areLabelsOverlap(box, array[index - 1], labelOpt.minSpacing, labelOpt.alignment)
};
if (step > 1 && boxes.some(checkLabels)) {
that._applyLabelMode(mode, step, boxes, behavior)
}
that._checkBoundedLabelsOverlapping(majorTicks, boxes, mode)
},
_applyLabelMode: function(mode, step, boxes, behavior, notRecastStep) {
var labelHeight, alignment, func, that = this,
majorTicks = that._majorTicks,
labelOpt = that._options.label,
angle = behavior.rotationAngle;
switch (mode) {
case ROTATE:
if (!labelOpt.userAlignment) {
alignment = angle < 0 ? RIGHT : LEFT;
if (angle % 90 === 0) {
alignment = CENTER
}
}
step = notRecastStep ? step : that._getStep(boxes, angle);
func = function(tick) {
tick.label.rotate(angle);
tick.labelRotationAngle = angle;
alignment && (tick.labelAlignment = alignment)
};
updateLabels(majorTicks, step, func);
break;
case "stagger":
labelHeight = that._getMaxLabelHeight(boxes, behavior.staggeringSpacing);
func = function(tick, index) {
if (index / (step - 1) % 2 !== 0) {
tick.labelOffset = labelHeight
}
};
updateLabels(majorTicks, step - 1, func);
break;
case "auto":
case "_auto":
if (2 === step) {
that._applyLabelMode("stagger", step, boxes, behavior)
} else {
that._applyLabelMode(ROTATE, step, boxes, {
rotationAngle: getOptimalAngle(boxes, labelOpt)
})
}
break;
default:
updateLabels(majorTicks, step)
}
},
getMarkerTrackers: _common.noop,
_drawDateMarkers: _common.noop,
_adjustDateMarkers: _common.noop,
coordsIn: _common.noop,
areCoordsOutsideAxis: _common.noop,
_getSkippedCategory: _common.noop,
_initAxisPositions: _common.noop,
_drawTitle: _common.noop,
_updateTitleCoords: _common.noop,
_adjustConstantLineLabels: _common.noop,
_createTranslator: function() {
return new _translator2d2.default.Translator2D({}, {}, {})
},
_updateTranslator: function() {
var translator = this._translator;
translator.update(translator.getBusinessRange(), this._canvas || {}, this._getTranslatorOptions())
},
_getTranslatorOptions: function() {
var options = this._options;
return {
isHorizontal: this._isHorizontal,
shiftZeroValue: !this.isArgumentAxis,
interval: options.semiDiscreteInterval,
stick: this._getStick(),
breaksSize: options.breakStyle ? options.breakStyle.width : 0
}
},
getVisibleArea: function() {
var canvas = this._getCanvasStartEnd();
return [canvas.start, canvas.end].sort(function(a, b) {
return a - b
})
},
_getCanvasStartEnd: function() {
var isHorizontal = this._isHorizontal,
canvas = this._canvas || {},
invert = this._translator.getBusinessRange().invert,
coords = isHorizontal ? [canvas.left, canvas.width - canvas.right] : [canvas.height - canvas.bottom, canvas.top];
invert && coords.reverse();
return {
start: coords[0],
end: coords[1]
}
},
_getScreenDelta: function() {
var that = this,
canvas = that._getCanvasStartEnd(),
breaks = that._breaks,
breaksLength = breaks ? breaks.length : 0,
screenDelta = _abs(canvas.start - canvas.end);
return screenDelta - (breaksLength ? breaks[breaksLength - 1].cumulativeWidth : 0)
},
_getScaleBreaks: function() {
return []
},
_adjustTitle: _common.noop,
_checkTitleOverflow: _common.noop,
getSpiderTicks: _common.noop,
setSpiderTicks: _common.noop,
_checkBoundedLabelsOverlapping: _common.noop,
drawScaleBreaks: _common.noop,
_visualRange: _common.noop,
_rotateConstantLine: _common.noop,
applyVisualRangeSetter: function(visualRangeSetter) {
this._visualRange = visualRangeSetter
},
getCategoriesSorter: function(argCategories) {
var sort = void 0;
if (this.isArgumentAxis) {
sort = argCategories
} else {
var categoriesSortingMethod = this._options.categoriesSortingMethod;
sort = (0, _type.isDefined)(categoriesSortingMethod) ? categoriesSortingMethod : this._options.categories
}
return sort
},
_getAdjustedBusinessRange: function() {
return this.adjustViewport(this._translator.getBusinessRange())
},
_getTickMarkPoints: _common.noop,
_validateOverlappingMode: _common.noop,
_getStep: _common.noop,
_validateDisplayMode: _common.noop,
shift: _common.noop
}
},
/*!***************************************************!*\
!*** ./artifacts/transpiled/viz/gauges/common.js ***!
\***************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var dxBaseGauge = __webpack_require__( /*! ./base_gauge */ 147).dxBaseGauge,
typeUtils = __webpack_require__( /*! ../../core/utils/type */ 1),
each = __webpack_require__( /*! ../../core/utils/iterator */ 3).each,
extend = __webpack_require__( /*! ../../core/utils/extend */ 0).extend,
_isDefined = typeUtils.isDefined,
_isArray = Array.isArray,
_isNumber = typeUtils.isNumeric,
axisModule = __webpack_require__( /*! ../axes/base_axis */ 205),
_map = __webpack_require__( /*! ../core/utils */ 12).map,
_normalizeEnum = __webpack_require__( /*! ../core/utils */ 12).normalizeEnum,
_compareArrays = __webpack_require__( /*! ./base_gauge */ 147).compareArrays,
_isFinite = isFinite,
_Number = Number,
_min = Math.min,
_max = Math.max,
_extend = extend,
_each = each,
_noop = __webpack_require__( /*! ../../core/utils/common */ 4).noop,
SHIFT_ANGLE = 90,
OPTION_VALUE = "value",
OPTION_SUBVALUES = "subvalues",
DEFAULT_MINOR_AXIS_DIVISION_FACTOR = 5,
DEFAULT_NUMBER_MULTIPLIERS = [1, 2, 5];
function processValue(value, fallbackValue) {
if (null === value) {
return value
}
return _isFinite(value) ? _Number(value) : fallbackValue
}
function parseArrayOfNumbers(arg) {
return _isArray(arg) ? arg : _isNumber(arg) ? [arg] : null
}
exports.dxGauge = dxBaseGauge.inherit({
_initCore: function() {
var that = this,
renderer = that._renderer;
that._setupValue(that.option(OPTION_VALUE));
that.__subvalues = parseArrayOfNumbers(that.option(OPTION_SUBVALUES));
that._setupSubvalues(that.__subvalues);
selectMode(that);
that.callBase.apply(that, arguments);
that._rangeContainer = new that._factory.RangeContainer({
renderer: renderer,
container: renderer.root,
translator: that._translator,
themeManager: that._themeManager
});
that._initScale()
},
_fontFields: ["scale.label.font", "valueIndicators.rangebar.text.font", "valueIndicators.textcloud.text.font", "indicator.text.font"],
_initScale: function() {
var that = this;
that._scaleGroup = that._renderer.g().attr({
"class": "dxg-scale"
}).linkOn(that._renderer.root, "scale");
that._scale = new axisModule.Axis({
incidentOccurred: that._incidentOccurred,
renderer: that._renderer,
axesContainerGroup: that._scaleGroup,
axisType: that._scaleTypes.type,
drawingType: that._scaleTypes.drawingType,
widgetClass: "dxg"
})
},
_disposeCore: function() {
var that = this;
that.callBase.apply(that, arguments);
that._scale.dispose();
that._scaleGroup.linkOff();
that._rangeContainer.dispose();
that._disposeValueIndicators();
that._scale = that._scaleGroup = that._rangeContainer = null
},
_disposeValueIndicators: function() {
var that = this;
that._valueIndicator && that._valueIndicator.dispose();
that._subvalueIndicatorsSet && that._subvalueIndicatorsSet.dispose();
that._valueIndicator = that._subvalueIndicatorsSet = null
},
_setupDomainCore: function() {
var that = this,
scaleOption = that.option("scale") || {},
startValue = that.option("startValue"),
endValue = that.option("endValue");
startValue = _isNumber(startValue) ? _Number(startValue) : _isNumber(scaleOption.startValue) ? _Number(scaleOption.startValue) : 0;
endValue = _isNumber(endValue) ? _Number(endValue) : _isNumber(scaleOption.endValue) ? _Number(scaleOption.endValue) : 100;
that._baseValue = startValue < endValue ? startValue : endValue;
that._translator.setDomain(startValue, endValue)
},
_cleanContent: function() {
var that = this;
that._rangeContainer.clean();
that._cleanValueIndicators()
},
_measureScale: function(scaleOptions) {
var textParams, layoutValue, result, coefs, innerCoef, outerCoef, that = this,
majorTick = scaleOptions.tick,
majorTickEnabled = majorTick.visible && majorTick.length > 0 && majorTick.width > 0,
minorTick = scaleOptions.minorTick,
minorTickEnabled = minorTick.visible && minorTick.length > 0 && minorTick.width > 0,
label = scaleOptions.label,
indentFromTick = Number(label.indentFromTick);
if (!majorTickEnabled && !minorTickEnabled && !label.visible) {
return {}
}
textParams = that._scale.measureLabels(extend({}, that._canvas));
layoutValue = that._getScaleLayoutValue();
result = {
min: layoutValue,
max: layoutValue
};
coefs = that._getTicksCoefficients(scaleOptions);
innerCoef = coefs.inner;
outerCoef = coefs.outer;
if (majorTickEnabled) {
result.min = _min(result.min, layoutValue - innerCoef * majorTick.length);
result.max = _max(result.max, layoutValue + outerCoef * majorTick.length)
}
if (minorTickEnabled) {
result.min = _min(result.min, layoutValue - innerCoef * minorTick.length);
result.max = _max(result.max, layoutValue + outerCoef * minorTick.length)
}
label.visible && that._correctScaleIndents(result, indentFromTick, textParams);
return result
},
_renderContent: function() {
var elements, that = this,
scaleOptions = that._prepareScaleSettings();
that._rangeContainer.render(_extend(that._getOption("rangeContainer"), {
vertical: that._area.vertical
}));
that._renderScale(scaleOptions);
elements = _map([that._rangeContainer].concat(that._prepareValueIndicators()), function(element) {
return element && element.enabled ? element : null
});
that._applyMainLayout(elements, that._measureScale(scaleOptions));
_each(elements, function(_, element) {
element.resize(that._getElementLayout(element.getOffset()))
});
that._shiftScale(that._getElementLayout(0), scaleOptions);
that._beginValueChanging();
that._updateActiveElements();
that._endValueChanging()
},
_prepareScaleSettings: function() {
var that = this,
userOptions = that.option("scale"),
scaleOptions = extend(true, {}, that._themeManager.theme("scale"), userOptions);
scaleOptions.label.indentFromAxis = 0;
scaleOptions.isHorizontal = !that._area.vertical;
scaleOptions.forceUserTickInterval |= _isDefined(userOptions) && _isDefined(userOptions.tickInterval) && !_isDefined(userOptions.scaleDivisionFactor);
scaleOptions.axisDivisionFactor = scaleOptions.scaleDivisionFactor || that._gridSpacingFactor;
scaleOptions.minorAxisDivisionFactor = scaleOptions.minorScaleDivisionFactor || DEFAULT_MINOR_AXIS_DIVISION_FACTOR;
scaleOptions.numberMultipliers = DEFAULT_NUMBER_MULTIPLIERS;
scaleOptions.tickOrientation = that._getTicksOrientation(scaleOptions);
if (scaleOptions.label.useRangeColors) {
scaleOptions.label.customizeColor = function() {
return that._rangeContainer.getColorForValue(this.value)
}
}
return scaleOptions
},
_renderScale: function(scaleOptions) {
var that = this,
bounds = that._translator.getDomain(),
startValue = bounds[0],
endValue = bounds[1],
angles = that._translator.getCodomain(),
invert = startValue > endValue,
min = _min(startValue, endValue),
max = _max(startValue, endValue);
scaleOptions.min = min;
scaleOptions.max = max;
scaleOptions.startAngle = SHIFT_ANGLE - angles[0];
scaleOptions.endAngle = SHIFT_ANGLE - angles[1];
scaleOptions.skipViewportExtending = true;
that._scale.updateOptions(scaleOptions);
that._scale.setBusinessRange({
axisType: "continuous",
dataType: "numeric",
min: min,
max: max,
invert: invert
});
that._updateScaleTickIndent(scaleOptions);
that._scaleGroup.linkAppend();
that._scale.draw(extend({}, that._canvas))
},
_updateIndicatorSettings: function(settings) {
var that = this;
settings.currentValue = settings.baseValue = _isFinite(that._translator.translate(settings.baseValue)) ? _Number(settings.baseValue) : that._baseValue;
settings.vertical = that._area.vertical;
if (settings.text && !settings.text.format) {
settings.text.format = that._defaultFormatOptions
}
},
_prepareIndicatorSettings: function(options, defaultTypeField) {
var that = this,
theme = that._themeManager.theme("valueIndicators"),
type = _normalizeEnum(options.type || that._themeManager.theme(defaultTypeField)),
settings = _extend(true, {}, theme._default, theme[type], options);
settings.type = type;
settings.animation = that._animationSettings;
settings.containerBackgroundColor = that._containerBackgroundColor;
that._updateIndicatorSettings(settings);
return settings
},
_cleanValueIndicators: function() {
this._valueIndicator && this._valueIndicator.clean();
this._subvalueIndicatorsSet && this._subvalueIndicatorsSet.clean()
},
_prepareValueIndicators: function() {
var that = this;
that._prepareValueIndicator();
null !== that.__subvalues && that._prepareSubvalueIndicators();
return [that._valueIndicator, that._subvalueIndicatorsSet]
},
_updateActiveElements: function() {
this._updateValueIndicator();
this._updateSubvalueIndicators()
},
_prepareValueIndicator: function() {
var that = this,
target = that._valueIndicator,
settings = that._prepareIndicatorSettings(that.option("valueIndicator") || {}, "valueIndicatorType");
if (target && target.type !== settings.type) {
target.dispose();
target = null
}
if (!target) {
target = that._valueIndicator = that._createIndicator(settings.type, that._renderer.root, "dxg-value-indicator", "value-indicator")
}
target.render(settings)
},
_createSubvalueIndicatorsSet: function() {
var that = this,
root = that._renderer.root;
return new ValueIndicatorsSet({
createIndicator: function(type, i) {
return that._createIndicator(type, root, "dxg-subvalue-indicator", "subvalue-indicator", i)
},
createPalette: function(palette) {
return that._themeManager.createPalette(palette)
}
})
},
_prepareSubvalueIndicators: function() {
var isRecreate, dummy, that = this,
target = that._subvalueIndicatorsSet,
settings = that._prepareIndicatorSettings(that.option("subvalueIndicator") || {}, "subvalueIndicatorType");
if (!target) {
target = that._subvalueIndicatorsSet = that._createSubvalueIndicatorsSet()
}
isRecreate = settings.type !== target.type;
target.type = settings.type;
dummy = that._createIndicator(settings.type, that._renderer.root);
if (dummy) {
dummy.dispose();
target.render(settings, isRecreate)
}
},
_setupValue: function(value) {
this.__value = processValue(value, this.__value)
},
_setupSubvalues: function(subvalues) {
var i, ii, list, vals = void 0 === subvalues ? this.__subvalues : parseArrayOfNumbers(subvalues);
if (null === vals) {
return
}
for (i = 0, ii = vals.length, list = []; i < ii; ++i) {
list.push(processValue(vals[i], this.__subvalues[i]))
}
this.__subvalues = list
},
_updateValueIndicator: function() {
var that = this;
that._valueIndicator && that._valueIndicator.value(that.__value, that._noAnimation)
},
_updateSubvalueIndicators: function() {
var that = this;
that._subvalueIndicatorsSet && that._subvalueIndicatorsSet.values(that.__subvalues, that._noAnimation)
},
value: function(arg) {
if (void 0 !== arg) {
this._changeValue(arg);
return this
}
return this.__value
},
subvalues: function(arg) {
if (void 0 !== arg) {
this._changeSubvalues(arg);
return this
}
return null !== this.__subvalues ? this.__subvalues.slice() : void 0
},
_changeValue: function(value) {
var that = this;
that._setupValue(value);
that._beginValueChanging();
that._updateValueIndicator();
if (that.__value !== that.option(OPTION_VALUE)) {
that.option(OPTION_VALUE, that.__value)
}
that._endValueChanging()
},
_changeSubvalues: function(subvalues) {
var that = this;
if (null !== that.__subvalues) {
that._setupSubvalues(subvalues);
that._beginValueChanging();
that._updateSubvalueIndicators();
that._endValueChanging()
} else {
that.__subvalues = parseArrayOfNumbers(subvalues);
that._setContentSize();
that._renderContent()
}
if (!_compareArrays(that.__subvalues, that.option(OPTION_SUBVALUES))) {
that.option(OPTION_SUBVALUES, that.__subvalues)
}
},
_optionChangesMap: {
scale: "DOMAIN",
rangeContainer: "MOSTLY_TOTAL",
valueIndicator: "MOSTLY_TOTAL",
subvalueIndicator: "MOSTLY_TOTAL",
containerBackgroundColor: "MOSTLY_TOTAL",
value: "VALUE",
subvalues: "SUBVALUES",
valueIndicators: "MOSTLY_TOTAL"
},
_customChangesOrder: ["VALUE", "SUBVALUES"],
_change_VALUE: function() {
this._changeValue(this.option(OPTION_VALUE))
},
_change_SUBVALUES: function() {
this._changeSubvalues(this.option(OPTION_SUBVALUES))
},
_applyMainLayout: null,
_getElementLayout: null,
_createIndicator: function(type, owner, className, trackerType, trackerIndex, _strict) {
var that = this,
indicator = that._factory.createIndicator({
renderer: that._renderer,
translator: that._translator,
owner: owner,
tracker: that._tracker,
className: className
}, type, _strict);
if (indicator) {
indicator.type = type;
indicator._trackerInfo = {
type: trackerType,
index: trackerIndex
}
}
return indicator
},
_getApproximateScreenRange: null
});
function valueGetter(arg) {
return arg ? arg.value : null
}
function setupValues(that, fieldName, optionItems) {
var currentValues = that[fieldName],
newValues = _isArray(optionItems) ? _map(optionItems, valueGetter) : [],
i = 0,
ii = newValues.length,
list = [];
for (; i < ii; ++i) {
list.push(processValue(newValues[i], currentValues[i]))
}
that[fieldName] = list
}
function selectMode(gauge) {
if (void 0 === gauge.option(OPTION_VALUE) && void 0 === gauge.option(OPTION_SUBVALUES)) {
if (void 0 !== gauge.option("valueIndicators")) {
disableDefaultMode(gauge);
selectHardMode(gauge)
}
}
}
function disableDefaultMode(that) {
that.value = that.subvalues = _noop;
that._setupValue = that._setupSubvalues = that._updateValueIndicator = that._updateSubvalueIndicators = null
}
function selectHardMode(that) {
that._indicatorValues = [];
setupValues(that, "_indicatorValues", that.option("valueIndicators"));
that._valueIndicators = [];
var _applyMostlyTotalChange = that._applyMostlyTotalChange;
that._applyMostlyTotalChange = function() {
setupValues(this, "_indicatorValues", this.option("valueIndicators"));
_applyMostlyTotalChange.call(this)
};
that._updateActiveElements = updateActiveElements_hardMode;
that._prepareValueIndicators = prepareValueIndicators_hardMode;
that._disposeValueIndicators = disposeValueIndicators_hardMode;
that._cleanValueIndicators = cleanValueIndicators_hardMode;
that.indicatorValue = indicatorValue_hardMode
}
function updateActiveElements_hardMode() {
var that = this;
_each(that._valueIndicators, function(_, valueIndicator) {
valueIndicator.value(that._indicatorValues[valueIndicator.index], that._noAnimation)
})
}
function prepareValueIndicators_hardMode() {
var ii, that = this,
valueIndicators = that._valueIndicators || [],
userOptions = that.option("valueIndicators"),
optionList = [],
i = 0;
for (ii = _isArray(userOptions) ? userOptions.length : 0; i < ii; ++i) {
optionList.push(userOptions[i])
}
for (ii = valueIndicators.length; i < ii; ++i) {
optionList.push(null)
}
var newValueIndicators = [];
_each(optionList, function(i, userSettings) {
var valueIndicator = valueIndicators[i];
if (!userSettings) {
valueIndicator && valueIndicator.dispose();
return
}
var settings = that._prepareIndicatorSettings(userSettings, "valueIndicatorType");
if (valueIndicator && valueIndicator.type !== settings.type) {
valueIndicator.dispose();
valueIndicator = null
}
if (!valueIndicator) {
valueIndicator = that._createIndicator(settings.type, that._renderer.root, "dxg-value-indicator", "value-indicator", i, true)
}
if (valueIndicator) {
valueIndicator.index = i;
valueIndicator.render(settings);
newValueIndicators.push(valueIndicator)
}
});
that._valueIndicators = newValueIndicators;
return that._valueIndicators
}
function disposeValueIndicators_hardMode() {
_each(this._valueIndicators, function(_, valueIndicator) {
valueIndicator.dispose()
});
this._valueIndicators = null
}
function cleanValueIndicators_hardMode() {
_each(this._valueIndicators, function(_, valueIndicator) {
valueIndicator.clean()
})
}
function indicatorValue_hardMode(index, value) {
return accessPointerValue(this, this._valueIndicators, this._indicatorValues, index, value)
}
function accessPointerValue(that, pointers, values, index, value) {
if (void 0 !== value) {
if (void 0 !== values[index]) {
values[index] = processValue(value, values[index]);
pointers[index] && pointers[index].value(values[index])
}
return that
} else {
return values[index]
}
}
function ValueIndicatorsSet(parameters) {
this._parameters = parameters;
this._indicators = []
}
ValueIndicatorsSet.prototype = {
constructor: ValueIndicatorsSet,
dispose: function() {
var that = this;
_each(that._indicators, function(_, indicator) {
indicator.dispose()
});
that._parameters = that._options = that._indicators = that._colorPalette = that._palette = null;
return that
},
clean: function() {
var that = this;
that._sample && that._sample.clean().dispose();
_each(that._indicators, function(_, indicator) {
indicator.clean()
});
that._sample = that._options = that._palette = null;
return that
},
render: function(options, isRecreate) {
var that = this;
that._options = options;
that._sample = that._parameters.createIndicator(that.type);
that._sample.render(options);
that.enabled = that._sample.enabled;
that._palette = _isDefined(options.palette) ? that._parameters.createPalette(options.palette) : null;
if (that.enabled) {
that._generatePalette(that._indicators.length);
that._indicators = _map(that._indicators, function(indicator, i) {
if (isRecreate) {
indicator.dispose();
indicator = that._parameters.createIndicator(that.type, i)
}
indicator.render(that._getIndicatorOptions(i));
return indicator
})
}
return that
},
getOffset: function() {
return this._sample.getOffset()
},
resize: function(layout) {
var that = this;
that._layout = layout;
_each(that._indicators, function(_, indicator) {
indicator.resize(layout)
});
return that
},
measure: function(layout) {
return this._sample.measure(layout)
},
_getIndicatorOptions: function(index) {
var result = this._options;
if (this._colorPalette) {
result = _extend({}, result, {
color: this._colorPalette[index]
})
}
return result
},
_generatePalette: function(count) {
var that = this,
colors = null;
if (that._palette) {
that._palette.reset();
colors = that._palette.generateColors(count, {
repeat: true
})
}
that._colorPalette = colors
},
_adjustIndicatorsCount: function(count) {
var i, ii, indicator, that = this,
indicators = that._indicators,
indicatorsLen = indicators.length;
if (indicatorsLen > count) {
for (i = count, ii = indicatorsLen; i < ii; ++i) {
indicators[i].clean().dispose()
}
that._indicators = indicators.slice(0, count);
that._generatePalette(indicators.length)
} else {
if (indicatorsLen < count) {
that._generatePalette(count);
for (i = indicatorsLen, ii = count; i < ii; ++i) {
indicator = that._parameters.createIndicator(that.type, i);
indicator.render(that._getIndicatorOptions(i)).resize(that._layout);
indicators.push(indicator)
}
}
}
},
values: function(arg, _noAnimation) {
var that = this;
if (!that.enabled) {
return
}
if (void 0 !== arg) {
if (!_isArray(arg)) {
arg = _isFinite(arg) ? [Number(arg)] : null
}
if (arg) {
that._adjustIndicatorsCount(arg.length);
_each(that._indicators, function(i, indicator) {
indicator.value(arg[i], _noAnimation)
})
}
return that
}
return _map(that._indicators, function(indicator) {
return indicator.value()
})
}
};
exports.createIndicatorCreator = function(indicators) {
return function(parameters, type, _strict) {
var indicatorType = indicators[_normalizeEnum(type)] || !_strict && indicators._default;
return indicatorType ? new indicatorType(parameters) : null
}
}
},
/*!***********************************************************!*\
!*** ./artifacts/transpiled/viz/range_selector/common.js ***!
\***********************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var _format = __webpack_require__( /*! ../axes/smart_formatter */ 413).smartFormatter,
isFunction = __webpack_require__( /*! ../../core/utils/type */ 1).isFunction,
HEIGHT_COMPACT_MODE = 24,
POINTER_SIZE = 4,
EMPTY_SLIDER_MARKER_TEXT = ". . .";
var utils = {
trackerSettings: {
fill: "grey",
stroke: "grey",
opacity: 1e-4
},
animationSettings: {
duration: 250
}
};
var consts = {
emptySliderMarkerText: EMPTY_SLIDER_MARKER_TEXT,
pointerSize: POINTER_SIZE
};
var formatValue = function(value, formatOptions, tickIntervalsInfo, valueType, type, logarithmBase) {
var formatObject = {
value: value,
valueText: _format(value, {
labelOptions: formatOptions,
ticks: tickIntervalsInfo ? tickIntervalsInfo.ticks : [],
tickInterval: tickIntervalsInfo ? tickIntervalsInfo.tickInterval : void 0,
dataType: valueType,
type: type,
logarithmBase: logarithmBase
})
};
return String(isFunction(formatOptions.customizeText) ? formatOptions.customizeText.call(formatObject, formatObject) : formatObject.valueText)
};
exports.utils = utils;
exports.consts = consts;
exports.formatValue = formatValue;
exports.HEIGHT_COMPACT_MODE = HEIGHT_COMPACT_MODE
},
/*!*****************************************************!*\
!*** ./artifacts/transpiled/exporter/file_saver.js ***!
\*****************************************************/
/*! dynamic exports provided */
/*! all exports used */
function(module, exports, __webpack_require__) {
var _renderer = __webpack_require__( /*! ../core/renderer */ 2);
var _renderer2 = _interopRequireDefault(_renderer);
var _dom_adapter = __webpack_require__( /*! ../core/dom_adapter */ 13);
var _dom_adapter2 = _interopRequireDefault(_dom_adapter);
var _window = __webpack_require__( /*! ../core/utils/window */ 7);
var _window2 = _interopRequireDefault(_window);
var _events_engine = __webpack_require__( /*! ../events/core/events_engine */ 5);
var _events_engine2 = _interopRequireDefault(_events_engine);
var _ui = __webpack_require__( /*! ../ui/widget/ui.errors */ 19);
var _ui2 = _interopRequireDefault(_ui);
var _type = __webpack_require__( /*! ../core/utils/type */ 1);
var _type2 = _interopRequireDefault(_type);
var _console = __webpack_require__( /*! ../core/utils/console */ 65);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
}
}
var window = _window2.default.getWindow();
var navigator = _window2.default.getNavigator();
var FILE_EXTESIONS = {
EXCEL: "xlsx",
CSS: "css",
PNG: "png",
JPEG: "jpeg",
GIF: "gif",
SVG: "svg",
PDF: "pdf"
};
var MIME_TYPES = exports.MIME_TYPES = {
CSS: "text/css",
EXCEL: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
PNG: "image/png",
JPEG: "image/jpeg",
GIF: "image/gif",
SVG: "image/svg+xml",
PDF: "application/pdf"
};
exports.fileSaver = {
_revokeObjectURLTimeout: 3e4,
_getDataUri: function(format, data) {
return "data:" + MIME_TYPES[format] + ";base64," + data
},
_linkDownloader: function(fileName, href) {
var exportLinkElement = _dom_adapter2.default.createElement("a");
exportLinkElement.download = fileName;
exportLinkElement.href = href;
exportLinkElement.target = "_blank";
return exportLinkElement
},
_formDownloader: function(proxyUrl, fileName, contentType, data) {
var formAttributes = {
method: "post",
action: proxyUrl,
enctype: "multipart/form-data"
},
exportForm = (0, _renderer2.default)("