123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886 |
- 'use strict';
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: BI Dashboard
- *| (C) Copyright IBM Corp. 2017
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['underscore', '../../../lib/@waca/core-client/js/core-client/ui/core/Class', '../../../lib/@waca/upgrades/UpgradeBase'], function (_, Class, UpgradeBase) {
- //NOSONAR
- var _commonPropertiesMap = {
- elementColor: 'defaultPaletteIndex',
- colorPalette: 'contColorPalette',
- legendPosition: 'widget.legend.position'
- };
- var _unChangedCommonProperties = ['colorPalette', 'queryRefresh', 'legendTitleColor', 'legendBodyColor', 'axisLineColor', 'axisGridLineColor', 'elementsLabelColor', 'axisLabelColor', 'axisTitleFontColor', 'axisTitleFont', 'axisLabelFont', 'elementsStyleFont', 'legendTitleFont', 'legendBodyFont'];
- var _visMapping = {
- JQGrid: 'JQGrid',
- crosstab: 'crosstab',
- dataPlayer: 'dataPlayer',
- /*hierarchy visualizations*/
- list: 'list',
- hierarchy2: 'list',
- hierarchy3: 'list',
- /*hierarchy*/
- /*legacy maps*/
- map1measure: 'com.ibm.vis.rave2polygonmap',
- map2measure: 'com.ibm.vis.rave2polygonmap',
- map3measure: 'com.ibm.vis.rave2polygonmap',
- /*legacy maps*/
- RAVE2_bubble: 'com.ibm.vis.ravebubble',
- RAVE2_clusteredcolumn: 'com.ibm.vis.rave2bundlecolumn',
- RAVE2_clusteredbar: 'com.ibm.vis.rave2bundlebar',
- RAVE2_compositeSmoothOneDataSet: 'com.ibm.vis.rave2bundlecomposite',
- RAVE2_dial: 'com.ibm.vis.rave2bundleradialbar',
- RAVE2_multipleDialCategoryLabel: 'com.ibm.vis.rave2bundleradialbar',
- RAVE2_heatmap: 'com.ibm.vis.rave2heat',
- RAVE2_packedBubble: 'com.ibm.vis.rave2bundlepackedbubble',
- RAVE2_pie: 'com.ibm.vis.rave2bundlepie',
- RAVE2_point: 'com.ibm.vis.rave2point',
- RAVE2_scatter: 'com.ibm.vis.ravescatter',
- RAVE2_smoothArea: 'com.ibm.vis.rave2bundlearea',
- RAVE2_smoothline: 'com.ibm.vis.rave2line',
- RAVE2_stackedcolumn: 'com.ibm.vis.rave2bundlestackedcolumn',
- RAVE2_stackedbar: 'com.ibm.vis.rave2bundlestackedbar',
- RAVE2_tiledmap: 'com.ibm.vis.rave2bundletiledmap',
- RAVE2_wordcloud: 'com.ibm.vis.rave2bundlewordcloud',
- summary: 'summary',
- /*treemaps*/
- treeMap1Cat1MeasureChart: 'com.ibm.vis.rave2bundletreemap',
- treeMap1Cat2MeasureChart: 'com.ibm.vis.rave2bundletreemap',
- treeMap2Cat1MeasureChart: 'com.ibm.vis.rave2bundletreemap',
- treeMap2Cat2MeasureChart: 'com.ibm.vis.rave2bundletreemap',
- treeMap3Cat1MeasureChart: 'com.ibm.vis.rave2bundletreemap',
- treeMap3Cat2MeasureChart: 'com.ibm.vis.rave2bundletreemap'
- /*treemaps*/
- };
- var _widgetTypeMapping = {
- data: 'live'
- };
- var _slotNameMapping = {
- 'com.ibm.vis.ravebubble': {
- label: 'categories'
- },
- 'com.ibm.vis.ravescatter': {
- label: 'categories'
- },
- 'com.ibm.vis.rave2bundlearea': {
- x: 'categories',
- color: 'series',
- y: 'values'
- },
- 'com.ibm.vis.rave2bundlebar': {
- x: 'categories',
- y: 'values'
- },
- 'com.ibm.vis.rave2bundlestackedbar': {
- x: 'categories',
- y: 'values'
- },
- 'com.ibm.vis.rave2bundlecolumn': {
- x: 'categories',
- y: 'values'
- },
- 'com.ibm.vis.rave2bundlestackedcolumn': {
- x: 'categories',
- y: 'values'
- },
- 'com.ibm.vis.rave2bundlecomposite': {
- x: 'categories',
- y: 'columnValue',
- yLine: 'lineValue'
- },
- 'com.ibm.vis.rave2line': {
- x: 'categories',
- color: 'series',
- y: 'values'
- },
- 'com.ibm.vis.rave2point': {
- x: 'categories',
- color: 'series',
- y: 'values'
- },
- 'com.ibm.vis.rave2bundlepie': {
- color: 'categories',
- value: 'values'
- },
- 'com.ibm.vis.rave2bundleradialbar': {
- label: 'categories',
- color: 'color',
- value: 'values',
- category: 'repeatHorizontal'
- },
- 'com.ibm.vis.rave2bundletreemap': {
- values: 'size',
- 'level': 'categories'
- },
- 'com.ibm.vis.rave2heat': {
- x: 'series',
- y: 'categories'
- },
- 'com.ibm.vis.rave2bundletiledmap': {
- /*map*/
- featureId: 'locations',
- featureIdRefinement: 'locations',
- value: 'locationColor',
- /*legacy map*/
- categories: 'locations',
- values: 'locationColor',
- size: 'pointSize',
- sizeHeat: 'pointColor'
- },
- 'com.ibm.vis.rave2polygonmap': {
- sizeHeat: 'pointColor'
- },
- 'com.ibm.vis.rave2bundlepackedbubble': {
- label: 'categories'
- },
- 'com.ibm.vis.rave2bundlewordcloud': {
- label: 'categories'
- },
- 'crosstab': {
- column_level: 'column_level1',
- row_level: 'row_level1',
- values: 'values'
- },
- 'dataPlayer': {
- categories: 'category'
- },
- 'list': {
- level: 'level1',
- _default: 'level1'
- },
- 'JQGrid': {
- grid_cols: 'grid_cols'
- },
- 'summary': {}
- };
- var _slotTypeMapping = {
- category: 'categorical'
- };
- var defaultSlotIdMap = {
- 'summary': function summary() /* model, item */{
- return 'values';
- },
- 'RAVE2_clusteredbar': function RAVE2_clusteredbar(model, item) {
- return this._getSlotNameForBarColumnLine(model, item, 'y', 'x');
- },
- 'RAVE2_clusteredcolumn': function RAVE2_clusteredcolumn(model, item) {
- return this._getSlotNameForBarColumnLine(model, item, 'x', 'y');
- },
- 'RAVE2_smoothline': function RAVE2_smoothline(model, item) {
- return this._getSlotNameForBarColumnLine(model, item, 'x', 'y');
- },
- 'list': function list() {
- return 'level';
- },
- 'RAVE2_compositeSmoothOneDataSet': function RAVE2_compositeSmoothOneDataSet(model, item) {
- var slotName;
- if (item.sourceCategory === 'measure' || item.type === 'fact') {
- var lineValueAssigned = _.find(model.slotmapping.slots, function (slot) {
- return slot.name === 'lineValue';
- });
- slotName = lineValueAssigned ? 'y' : 'yLine';
- } else {
- slotName = 'x';
- }
- return slotName;
- },
- 'RAVE2_scatter': function RAVE2_scatter(model) {
- var slotName;
- if (!_.find(model.slotmapping.slots, function (slot) {
- return slot.name === 'categories';
- })) {
- slotName = 'label';
- } else if (!_.find(model.slotmapping.slots, function (slot) {
- return slot.name === 'color';
- })) {
- slotName = 'color';
- } else if (!_.find(model.slotmapping.slots, function (slot) {
- return slot.name === 'x';
- })) {
- slotName = 'x';
- } else {
- slotName = 'y';
- }
- return slotName;
- },
- 'JQGrid': function JQGrid() /* model, item */{
- return 'grid_cols';
- },
- 'RAVE2_tiledmap': function RAVE2_tiledmap(model, item) {
- var slotName;
- if (item.type === 'attribute') {
- if (!_.find(model.slotmapping.slots, function (slot) {
- return slot.name === 'locations';
- })) {
- slotName = 'locations';
- } else if (this._hasOnlyOneLocationsSlot(model.slotmapping.slots)) {
- // this could be the featureIdRefinement, map it to 'locations' too
- slotName = 'locations';
- }
- }
- if (!slotName) {
- if (!_.find(model.slotmapping.slots, function (slot) {
- return slot.name === 'locationColor';
- })) {
- slotName = 'locationColor';
- } else if (!_.find(model.slotmapping.slots, function (slot) {
- return slot.name === 'pointSize';
- })) {
- slotName = 'pointSize';
- } else {
- slotName = 'pointColor';
- }
- }
- return slotName;
- }
- };
- var Upgrade = Class.extend([UpgradeBase], {
- init: function init() {
- this.VERSION = 1004;
- },
- /**
- * Perform upgrade
- *
- * @param {object} spec - spec to perform upgrade on
- *
- * @return {Promise} Promise to be resolved when upgrade performed
- */
- up: function up(spec) {
- if (!spec.dataSources) {
- spec.dataSources = {
- sources: [],
- version: '1.0'
- };
- this._upgradeWidgets(spec);
- }
- return Promise.resolve(spec);
- },
- _upgradeWidgets: function _upgradeWidgets(spec) {
- try {
- _.each(spec.widgets, function (model) {
- if (_visMapping[model.visId]) {
- var dataSourceId = this._addWidgetDataSource(spec, model);
- model.data = {
- dataViews: []
- };
- this._upgradeProperties(model);
- this._upgradeSlotMapping(dataSourceId, model);
- model.type = _widgetTypeMapping[model.type];
- model.visId = model.archetype = _visMapping[model.visId];
- // remove old properties
- delete model.dataSet;
- delete model.mapping;
- }
- }.bind(this));
- } catch (error) {
- throw error;
- }
- },
- _addWidgetDataSource: function _addWidgetDataSource(spec, model) {
- if (!model.dataSet) {
- return undefined;
- }
- var dataSourceJSON = _.find(spec.dataSources.sources, function (source) {
- return source.assetId === model.dataSet.id;
- });
- if (!dataSourceJSON) {
- var dataSourceId = _.uniqueId('model');
- dataSourceJSON = {
- id: dataSourceId,
- assetId: model.dataSet.id,
- name: model.dataSet.name,
- type: model.dataSet.type,
- shaping: {}
- };
- spec.dataSources.sources.push(dataSourceJSON);
- }
- return dataSourceJSON.id;
- },
- _upgradeSlotMapping: function _upgradeSlotMapping(dataSourceId, model) {
- model.slotmapping = {
- slots: []
- };
- var numberOfValues = 0;
- if (model.visId === 'RAVE2_scatter' && _.isArray(model.mapping) && model.mapping.length === 2) {
- this._scatterPlotSpecialCase(model);
- }
- _.each(_.sortBy(model.mapping, 'slotId'), function (item) {
- var dataItemId = this._addDataItem(dataSourceId, model, item);
- var slotId = item.slotId || _slotNameMapping[_visMapping[model.visId]]._default;
- if (!slotId) {
- slotId = this._assignDefaultSlotId(model, item);
- }
- if (/^y[0-9]*$/.test(slotId)) {
- numberOfValues++;
- }
- slotId = slotId.replace(/[0-9]/g, '');
- var mappedSlotName = _slotNameMapping[_visMapping[model.visId]][slotId] ? _slotNameMapping[_visMapping[model.visId]][slotId] : item.slotId;
- var existingSlot = _.find(model.slotmapping.slots, function (slot) {
- return slot.name === mappedSlotName;
- });
- if (existingSlot) {
- existingSlot.dataItems.push(dataItemId);
- } else {
- model.slotmapping.slots.push(this._createSlot(mappedSlotName ? mappedSlotName : item.label, _slotTypeMapping[item.slotType] ? _slotTypeMapping[item.slotType] : item.slotType, dataItemId, item));
- }
- }.bind(this));
- if (numberOfValues > 1) {
- this._addMultiMeasuresItemAndSlot(model, numberOfValues);
- }
- },
- _scatterPlotSpecialCase: function _scatterPlotSpecialCase(model) {
- var mapping = model.mapping;
- if (mapping && mapping.length === 2) {
- if (this._isXYAndOrdinal(mapping[0]) && this._isXYAndOrdinal(mapping[1])) {
- var xSlot = _.find(mapping, function (map) {
- return map.slotId === 'x';
- });
- mapping.unshift({
- 'columnId': xSlot.columnId,
- 'label': xSlot.label,
- 'slotId': 'label',
- 'slotType': 'category'
- });
- }
- }
- },
- _isXYAndOrdinal: function _isXYAndOrdinal(mapItem) {
- return (mapItem.slotId === 'x' || mapItem.slotId === 'y') && mapItem.slotType === 'ordinal';
- },
- _upgradeMappingFormat: function _upgradeMappingFormat(dataItem, mappingItem) {
- if (!_.isEmpty(mappingItem.formatSpec)) {
- dataItem.format = {
- 'id': mappingItem.formatSpec.selectedFormat,
- 'formatSpec': mappingItem.formatSpec
- };
- }
- },
- _addDataItem: function _addDataItem(dataSourceId, model, item) {
- // find the dataView
- var dataView = _.find(model.data.dataViews, function (dataView) {
- return dataView.modelRef === dataSourceId;
- });
- if (!dataView) {
- dataView = {
- modelRef: dataSourceId,
- dataItems: []
- };
- model.data.dataViews.push(dataView);
- }
- var dataItem = {
- id: _.uniqueId('dataItem'),
- itemId: item.columnId,
- itemLabel: item.label
- };
- if (item.aggregationType) {
- dataItem.aggregate = item.aggregationType;
- }
- this._upgradeMappingFormat(dataItem, item);
- dataView.dataItems.push(dataItem);
- if (item.order) {
- dataItem.selection = [{
- operation: 'order',
- sort: {
- type: item.order,
- priority: 0,
- by: 'caption'
- }
- }];
- }
- if (item.limit) {
- if (!dataItem.selection) {
- dataItem.selection = [];
- }
- var selectionItem = {};
- selectionItem.operation = 'keep';
- var topBottom = {
- type: item.limit.op + 'count',
- value: item.limit.val
- };
- if (_.isObject(item.limit.rank)) {
- topBottom.rank = true;
- }
- selectionItem.topBottom = topBottom;
- if (item.limit.fact) {
- selectionItem.context = [{
- itemId: item.limit.fact
- }];
- }
- dataItem.selection.push(selectionItem);
- }
- return dataItem.id;
- },
- /*This is a temporary method until support is put in to the visualization recommender, where it we determine default slots for items if none are specified*/
- _assignDefaultSlotId: function _assignDefaultSlotId(model, item) {
- var slotName;
- if (model.visId in defaultSlotIdMap) {
- slotName = defaultSlotIdMap[model.visId].call(this, model, item);
- if (slotName) {
- item.slotId = slotName;
- }
- }
- return slotName;
- },
- _hasOnlyOneLocationsSlot: function _hasOnlyOneLocationsSlot(slotMapping) {
- var nbLocations = 0;
- for (var i = 0; i < slotMapping.length; ++i) {
- if (slotMapping[i].type === 'locations') {
- nbLocations++;
- }
- }
- return nbLocations === 1;
- },
- //better name would be nice
- _getSlotNameForBarColumnLine: function _getSlotNameForBarColumnLine(model, item, x, y) {
- var slotName;
- if (item.sourceCategory === 'measure' || item.type === 'fact') {
- slotName = y;
- } else if (!_.find(model.mapping, function (i) {
- return i.slotId === x;
- })) {
- slotName = x;
- } else {
- slotName = 'color';
- }
- return slotName;
- },
- _createSlot: function _createSlot(name, type, dataItemId, originalItem) {
- var slot = {
- dataItems: [dataItemId],
- type: type,
- name: name
- };
- if (originalItem.graphic) {
- slot.dataItemSettings = [{
- graphic: _.clone(originalItem.graphic),
- shapeDropEnabled: originalItem.shapeDropEnabled
- }];
- }
- return slot;
- },
- _addMultiMeasuresItemAndSlot: function _addMultiMeasuresItemAndSlot(widgetModel, numberOfValues) {
- var multiMeasureSlotName = this._getMultiMeasureSlotName(widgetModel);
- if (multiMeasureSlotName) {
- var multiMeasureDataItem = {
- 'id': '_multiMeasuresSeries',
- 'itemId': '_multiMeasuresSeries',
- 'itemLabel': 'Measures group (' + numberOfValues + ')'
- };
- widgetModel.data.dataViews[0].dataItems.push(multiMeasureDataItem);
- var multiMeasureSlot = _.find(widgetModel.slotmapping.slots, function (slot) {
- return slot.name === multiMeasureSlotName;
- });
- if (multiMeasureSlot) {
- multiMeasureSlot.dataItems.unshift('_multiMeasuresSeries');
- } else {
- widgetModel.slotmapping.slots.push({
- dataItems: ['_multiMeasuresSeries'],
- name: multiMeasureSlotName,
- type: 'any'
- });
- }
- }
- },
- _upgradeWordCloudProperties: function _upgradeWordCloudProperties(model, properties) {
- var hideLegend = this._findProperty('hideLegend', model.properties);
- if (!hideLegend) {
- var sizeSlot = _.find(model.mapping, function (item) {
- return item.slotId === 'size';
- });
- var colorSlot = _.find(model.mapping, function (item) {
- return item.slotId === 'color';
- });
- if (sizeSlot && !colorSlot) {
- properties.push({
- id: 'widget.legend.display',
- value: false
- });
- }
- }
- },
- _getMultiMeasureSlotName: function _getMultiMeasureSlotName(widgetModel) {
- switch (_visMapping[widgetModel.visId]) {
- case 'com.ibm.vis.rave2bundlebar':
- case 'com.ibm.vis.rave2bundlestackedbar':
- case 'com.ibm.vis.rave2bundlecolumn':
- case 'com.ibm.vis.rave2bundlestackedcolumn':
- {
- return 'color';
- }
- case 'com.ibm.vis.rave2bundlearea':
- case 'com.ibm.vis.rave2point':
- case 'com.ibm.vis.rave2line':
- {
- return 'series';
- }
- default:
- return null;
- }
- },
- _upgradeProperties: function _upgradeProperties(model) {
- var properties = [];
- switch (model.visId) {
- case 'RAVE2_wordcloud':
- {
- this._upgradeWordCloudProperties(model, properties);
- break;
- }
- case 'RAVE2_clusteredcolumn':
- case 'RAVE2_clusteredbar':
- case 'RAVE2_stackedcolumn':
- case 'RAVE2_stackedbar':
- {
- this._upgradeBarProperties(model, properties);
- break;
- }
- case 'RAVE2_smoothline':
- {
- this._upgradeLineProperties(model, properties, false /* zeroOriginValue */);
- break;
- }
- case 'RAVE2_smoothArea':
- {
- this._upgradeLineProperties(model, properties, true /* zeroOriginValue */);
- this._upgradeAutoSort(model, 'color', 'asc'); // R6: Auto(ascending), R7: Auto(none)
- break;
- }
- case 'RAVE2_point':
- {
- this._upgradePointProperties(model, properties);
- break;
- }
- case 'RAVE2_compositeSmoothOneDataSet':
- {
- this._upgradeCompositeProperties(model, properties);
- break;
- }
- case 'RAVE2_pie':
- {
- this._upgradePieProperties(model, properties);
- break;
- }
- case 'RAVE2_bubble':
- case 'RAVE2_scatter':
- {
- this._upgradeBubbleProperties(model, properties);
- break;
- }
- case 'summary':
- {
- this._upgradeSummaryProperties(model, properties);
- break;
- }
- case 'JQGrid':
- case 'crosstab':
- {
- this._upgradeTableAndCrosstabProperties(model, properties);
- }
- break;
- default:
- // log that we didn't match a visId
- break;
- }
- this._copyCommonProperties(model, properties);
- this._upgradeTitleProperty(model);
- model.properties = properties;
- },
- _upgradeTitleProperty: function _upgradeTitleProperty(model) {
- // If the previous report has a title (i.e. name) defined, then enable the showTitle property.
- if (model && model.name && model.name !== '') {
- model.showTitle = true;
- }
- },
- _upgradeCompositeProperties: function _upgradeCompositeProperties(model, properties) {
- var interpolation = this._findProperty('interpolation', model.properties);
- properties.push({
- id: 'lines.smooth',
- value: interpolation ? interpolation.value : false
- });
- var elementColor = this._findProperty('elementColor', model.properties);
- if (elementColor) {
- properties.push({
- id: 'defaultPaletteIndex',
- value: elementColor.value
- });
- }
- var lineSymbol = this._findProperty('lineWithPoints.symbol', model.properties);
- if (lineSymbol) {
- properties.push({
- id: 'lineWithPoints.symbol',
- value: this._upgradeSymbolShapeValue(lineSymbol.value)
- });
- }
- this._copyPropertiesUnmodified(['lineColor'], model, properties);
- this._setZeroOriginPropertyToValueByDefault(properties, false /* zeroOriginValue */);
- },
- _upgradeBarProperties: function _upgradeBarProperties(model, properties) {
- properties.push({
- id: 'stacked',
- value: model.visId.indexOf('stacked') !== -1 ? true : false
- });
- this._setZeroOriginPropertyToValueByDefault(properties, true /* zeroOriginValue */);
- },
- _upgradeSymbolShapeValue: function _upgradeSymbolShapeValue(value) {
- if (value === 'rectangle') {
- return 'horizontal-rectangle';
- } else if (value === 'triangle') {
- return 'triangle-up';
- } else if (value === 'poly') {
- return 'circle'; // There is no longer a polygon in R7
- }
- return value;
- },
- _upgradePointProperties: function _upgradePointProperties(model, properties) {
- properties.push({
- id: 'lines.visible',
- value: false
- });
- var symbolShape = this._findProperty('symbolShape', model.properties);
- if (symbolShape) {
- properties.push({
- id: 'lineWithPoints.symbol',
- value: this._upgradeSymbolShapeValue(symbolShape.value)
- });
- }
- },
- _upgradeLineProperties: function _upgradeLineProperties(model, properties, zeroOriginValue) {
- var interpolation = this._findProperty('interpolation', model.properties);
- properties.push({
- id: 'lines.smooth',
- value: interpolation ? interpolation.value : true
- });
- properties.push({
- id: 'markers.visible',
- value: true
- });
- properties.push({
- id: 'lines.visible',
- value: true
- });
- var hideAxisLabels = this._findProperty('hideAxisTitleLabels', model.properties);
- if (hideAxisLabels) {
- properties.push({
- id: 'valueAxis.labels.visible',
- value: !hideAxisLabels.value
- });
- }
- var shape = this._findProperty('lineWithPoints.symbol', model.properties);
- properties.push({
- id: 'lineWithPoints.symbol',
- value: shape ? this._upgradeSymbolShapeValue(shape.value) : 'circle'
- });
- this._setZeroOriginPropertyToValueByDefault(properties, zeroOriginValue);
- },
- _upgradePieProperties: function _upgradePieProperties(model, properties) {
- var donutRadius = this._findProperty('donutRadius', model.properties);
- if (donutRadius) {
- properties.push(donutRadius);
- }
- properties.push({
- id: 'pie.has.hole',
- value: donutRadius && donutRadius.value !== 1 ? true : false
- });
- this._copyPropertiesUnmodified(['labelLocation'], model, properties);
- },
- _upgradeBubbleProperties: function _upgradeBubbleProperties(model, properties) {
- var symbolShape = this._findProperty('symbolShape', model.properties);
- if (symbolShape) {
- properties.push({
- id: 'symbolShape',
- value: this._upgradeSymbolShapeValue(symbolShape.value)
- });
- }
- },
- _upgradeSummaryProperties: function _upgradeSummaryProperties(model, properties) {
- this._copyPropertiesUnmodified(['showItemLabel', 'valueColor', 'fillDirection'], model, properties);
- },
- _copyPropertiesUnmodified: function _copyPropertiesUnmodified(propArray, model, properties) {
- _.each(propArray, function (propName) {
- var property = this._findProperty(propName, model.properties);
- if (property) {
- properties.push(property);
- }
- }.bind(this));
- },
- _upgradeTableAndCrosstabProperties: function _upgradeTableAndCrosstabProperties(model, properties) {
- this._copyPropertiesUnmodified(['hideSummaries'], model, properties);
- },
- _copyCommonProperties: function _copyCommonProperties(model, properties) {
- if (model.properties) {
- this._copyPropertiesUnmodified(_unChangedCommonProperties, model, properties);
- _.each(_commonPropertiesMap, function (mappedValue, originalValue) {
- var savedProperty = this._findProperty(originalValue, model.properties);
- if (savedProperty) {
- properties.push({
- id: mappedValue,
- value: savedProperty.value
- });
- }
- }.bind(this));
- //hideLegend will no longer be used. There is now a widget.legend.display
- // If we hid the legend make sure legend display is now false, otherwise
- // let it stay as default (true)
- var hideLegend = this._findProperty('hideLegend', model.properties);
- if (hideLegend && hideLegend.value) {
- properties.push({
- id: 'widget.legend.display',
- value: false
- });
- }
- // Set Legend Position if need be
- var legendPosition = this._findProperty('legend.position', model.properties);
- if (legendPosition) {
- var legendPositionValue = legendPosition.value === 'none' ? 'auto' : legendPosition.value;
- properties.push({
- id: 'widget.legend.position',
- value: legendPositionValue
- });
- }
- var hideAxisTitleLabels = this._findProperty('hideAxisTitleLabels', model.properties);
- if (hideAxisTitleLabels && hideAxisTitleLabels.value === true) {
- properties.push({
- id: 'titles.visible',
- value: false
- });
- }
- var hideTreeMapLeafLabels = this._findProperty('hideTreeMapLeafLabels', model.properties);
- if (hideTreeMapLeafLabels && hideTreeMapLeafLabels.value === false) {
- properties.push({
- id: 'leaf.labels.visible',
- value: true
- });
- }
- }
- },
- _setZeroOriginPropertyToValueByDefault: function _setZeroOriginPropertyToValueByDefault(properties, toValue) {
- // valueAxis.zeroOrigin is a new property in WACA that is enabled by default.
- // We need to disable it by default for all previous
- properties.push({
- id: 'valueAxis.zeroOrigin',
- value: toValue
- });
- },
- _findProperty: function _findProperty(id, properties) {
- return _.find(properties, function (property) {
- return property.id === id;
- });
- },
- down: function down(spec) {
- return Promise.resolve(spec);
- },
- _specHasWidgets: function _specHasWidgets(spec) {
- if (!spec.widgets) {
- return false;
- }
- return Object.keys(spec.widgets).length > 0;
- },
- _upgradeAutoSort: function _upgradeAutoSort(model, slotId, order) {
- var item = _.find(model.mapping, function (item) {
- return item.slotId === slotId && !item.order;
- });
- if (item) {
- item.order = order;
- }
- }
- });
- return new Upgrade();
- });
- //# sourceMappingURL=waca.js.map
|