123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855 |
- /*
- IBM Confidential
- OCO Source Materials
- IBM Cognos Products: irot
- (C) Copyright IBM Corp. 2003, 2016
- The source code for this program is not published or otherwise divested of its trade secrets, irrespective of what has been deposited with the U.S. Copyright Office.
- */
- define([], function() {
- var G_Rave1Adapter = {};
- /*
- * Custom adapter settings
- * checkSupportedConfig
- *
- *
- * Init status codes
- * checkSupportedConfigErrorCode
- *
- */
- G_Rave1Adapter.Initialize = function(v_sAdapterId, v_sAdapterLocationFull, v_oAdapterSettings)
- {
- if (!this.m_oDeferredInitialize)
- {
- this.m_oDeferredInitialize = Q.defer();
-
- this.m_oBundleLibrary = {};
- this.m_oVisDataDefinition = {};
-
- var v_sAdapterLocation = v_sAdapterLocationFull.substr(0, v_sAdapterLocationFull.lastIndexOf("/"));
-
- // Included for the RAVE charting engine. If a RAVE chart is not used, the server will put empty files in the MHT
- // dojo is included first so that we can overwrite their definitions and not them overwriting ours
- // Need to define the configuration as a module
- define("dojo/_base/config", {
- async : true,
- afterOnLoad: true,
- locale : 'en-us',
- gfxRenderer : 'canvas,silverlight',
- blankGif : 'hal/imagesirot/blank.gif'
- });
-
- var v_oConfig =
- {
- waitSeconds : 60,
- paths :
- {
- "dojo" : v_sAdapterLocation + "/rave/dojo",
- "dojox" : v_sAdapterLocation + "/rave/dojox",
- "com" : v_sAdapterLocation + "/rave/com"
- }
- };
-
- this.M_bIsIE = ( ( ( navigator.userAgent.toLowerCase().search(/trident\/([0-9]+\.[0-9]+)/) != -1 ) ? parseFloat( RegExp.$1 ) : 0 ) >= 7.0 );
- var v_fnOnDojoLoaded = ( this.M_bIsIE ? this.f_onDojoLoadedIE : this.f_onDojoLoaded ).bind( this, v_sAdapterId, v_sAdapterLocation, v_oAdapterSettings );
- require( v_oConfig, ["dojo/dojo"], v_fnOnDojoLoaded );
- }
-
- return this.m_oDeferredInitialize.promise;
- };
- G_Rave1Adapter.f_onDojoLoadedIE = function(v_sAdapterId, v_sAdapterLocation, v_oAdapterSettings)
- {
- var fn = this.f_onDojoLoaded.bind( this, v_sAdapterId, v_sAdapterLocation, v_oAdapterSettings );
- // This block is required in IE to force dojo to the use the ActiveX XMLHttpRequest instead of the builtin XmlHttpRequest object.
- // The builtin XmlHttpRequest will return security errors for any files loaded from an MHT file when the MHT file is access through an HTTP url.
- require(["dojo/has", "dojo/sniff"], function(has) {
- has.add('activex', true, false, true);
- has.add('dojo-force-activex-xhr', true, false, true);
- has.add('native-xhr', false, false, true);
- has.add('native-xhr2', false, false, true);
- fn();
- });
- };
- G_Rave1Adapter.f_onDojoLoaded = function(v_sAdapterId, v_sAdapterLocation, v_oAdapterSettings)
- {
- // Load RAVE and it's dependencies using dojo
- require(["dojo/dojo-core-layer"], function() {
- require(["com/ibm/vis/main"], function() {
- //once we have the rave layer loaded, we can use all rave modules
- require(["com/ibm/init/ready", "com/ibm/vis/widget/VisControl", "com/ibm/vis/widget/Environment", "com/ibm/vis/interaction/HighlightRepresentation", "com/ibm/vis/interaction/ChangeEffect", "com/ibm/vis/template/Template", "com/ibm/vis/interaction/SceneItemTypes"], function(v_fnReady, v_fnVisControl, v_fnVisEnvironment, v_fnVisHighlightRepresentation, v_fnVisChangeEffect, v_fnVisTemplate, v_fnSceneItemTypes) {
- //ready function is needed to ensure the rave system is properly loaded
- v_fnReady(function() {
- this.m_oRaveEnv = {
- M_fnVisControl : v_fnVisControl,
- M_fnVisHighlightRepresentation : v_fnVisHighlightRepresentation,
- M_fnVisChangeEffect : v_fnVisChangeEffect,
- M_fnVisTemplate : v_fnVisTemplate,
- M_fnSceneItemTypes : v_fnSceneItemTypes
- };
- /*
- *
- * Environment.checkBrowserSupportedConfiguration()
- *
- * This is a browser sniffing API and checks if the current browser environment
- * is compatible with RAVE. It returns an Integer. The possible value of this
- * returned Integer is predefined and mapped to the specific environment setting.
- *
- * returnCode = 0 : Supported environment for RAVE
- *
- * All other return codes mean that the environment is not supported by RAVE.
- * [Requirement taken from the Acceptance Tests of the RTC Story #29082]
- * returnCode = 1 : Silverlight version 5 onwards not available on Internet Explorer
- * returnCode = 2 : Internet Explorer version prior to IE7 is found
- * returnCode = 3 : Firefox version prior to 3.6 is found
- * returnCode = 4 : Opera browser found
- * returnCode = 5 : Internet Explorer 9 in Quirks Mode without silverlight version >=5
- * returnCode = 6 : Internet Explorer 10 in IE5 Quirks mode
- */
- if (v_oAdapterSettings && v_oAdapterSettings.custom && v_oAdapterSettings.custom.checkSupportedConfig)
- {
- var v_iErrorCode = v_fnVisEnvironment.checkBrowserSupportedConfiguration();
- //Only look for SV errors. ARs need to work in IE5 Quirks mode in IE 10 in AR Preview
- if ( v_iErrorCode == 1 || v_iErrorCode == 5)
- {
- this.m_oDeferredInitialize.reject({checkSupportedConfigErrorCode : v_iErrorCode});
- return;
- }
- }
- this.m_oDeferredInitialize.resolve(true);
- }.bind(this));
- }.bind(this));
- }.bind(this));
- }.bind(this));
- };
- G_Rave1Adapter.Destroy = function()
- {
- };
- // cannot use the AMD text loader as it does not work on IE (access denied errors) when dealing with MHT files or file URL.
- G_Rave1Adapter.f_loadTextFile = function( v_sLocation )
- {
- var v_sAgent = navigator.userAgent.toLowerCase();
- var v_fIEVersion = ( v_sAgent.search(/trident\/([0-9]+\.[0-9]+)/) != -1 ) ? parseFloat( RegExp.$1 ) : 0;
- var v_bIsIE = (v_fIEVersion >= 7.0);
- var v_bIsFirefox = ( v_sAgent.match( /firefox|minefield|shiretoko|namoroka/ ) != null );
- var v_oRequest = v_bIsIE ? new ActiveXObject( "MSXML2.XMLHTTP.3.0" ) : new XMLHttpRequest();
- try
- {
- v_oRequest.open( "GET", v_sLocation, false );
- if ( v_bIsFirefox )
- {
- v_oRequest.overrideMimeType( "text/plain; charset=utf-8" );
- }
- v_oRequest.send( null );
- }
- catch ( e )
- {
- // can't localize this message because it may be string file we are loading.
- alert( "Failed to load file:" + v_sLocation );
- return "";
- }
- return ( v_oRequest.status == 404 ) ? "" : v_oRequest.responseText;
- };
- G_Rave1Adapter.LoadVisChartType = function(v_sBundleId, v_sBundleLocation, v_fnOnVisBundleLoaded)
- {
- if (this.m_oBundleLibrary[v_sBundleId])
- {
- v_fnOnVisBundleLoaded(v_sBundleId);
- return;
- }
- var v_sUrl = v_sBundleLocation;
-
- // cannot use the AMD text loader as it does not work on IE (access denied errors) when dealing with MHT files or file URL.
- var v_sVisJSON = this.f_loadTextFile(v_sUrl);
- var v_oVisJSON = dojo.fromJson(v_sVisJSON);
- var v_oBundle = this.m_oBundleLibrary[v_sBundleId] = {};
- v_oBundle.M_sBundleId = v_sBundleId;
- v_oBundle.M_oVisJSON = v_oVisJSON;
- v_oBundle.M_sVisJSON = v_sVisJSON;
- v_fnOnVisBundleLoaded(v_sBundleId);
- };
- G_Rave1Adapter.CreateVis = function(v_sBundleId)
- {
- return new C_Rave1Viz(this.m_oRaveEnv, this.m_oBundleLibrary[v_sBundleId]);
- };
- G_Rave1Adapter.GetVisDataDefinition = function(v_sBundleId)
- {
- var v_oVisJSON = this.m_oBundleLibrary[v_sBundleId].M_oVisJSON;
- if (!v_oVisJSON)
- {
- return null;
- }
- if (!v_oVisJSON.data)
- {
- return {};
- }
- var v_oDef = this.m_oVisDataDefinition[v_sBundleId];
- if (v_oDef)
- {
- return v_oDef;
- }
- // This should probably be generated from the chart type definition and not the visJSON
- v_oDef = {};
- v_oDef.dataSets = [];
- v_oDef.M_oSlotDataSet = {};
- for (var v_iData = 0; v_iData < v_oVisJSON.data.length; ++v_iData)
- {
- var v_oDataSet = v_oVisJSON.data[v_iData];
- var v_oDataDef = {};
- v_oDef.dataSets.push(v_oDataDef);
- v_oDataDef.id = v_oDataSet.id;
- v_oDataDef.slots = [];
- if ( v_oDataSet.fields )
- {
- for (var i = 0; i < v_oDataSet.fields.length; ++i)
- {
- var v_oField = v_oDataSet.fields[i];
- var v_oFieldDef = {};
- v_oDataDef.slots.push(v_oFieldDef);
- v_oFieldDef.id = v_oField.id;
- v_oFieldDef.type = v_oField.categories ? "category" : "value";
- v_oDef.M_oSlotDataSet[v_oField.id] = v_oDataSet.id;
- }
- }
- }
- this.m_oVisDataDefinition[v_sBundleId] = v_oDef;
- return v_oDef;
- };
- //=======================================
- var C_Rave1Viz = function(v_oRaveEnv, v_oBundle)
- {
- this.m_oRaveEnv = v_oRaveEnv;
- // Each instance of Viz should keep a local copy of JSON from boundle.
- // Otherwise, the later setData would polute the template which is shared by other instants.
- this.m_oVisJSONBundle = dojo.clone(v_oBundle.M_oVisJSON);
-
- this.m_oVisJSON = null;
- this.m_sErrorMessage = "";
-
- var v_oVisDef = G_Rave1Adapter.GetVisDataDefinition(v_oBundle.M_sBundleId);
- this.m_oSlotDataSet = v_oVisDef.M_oSlotDataSet;
- };
- /*
- * Custom vis settings
- * properties,
- * validateJSON
- *
- */
- C_Rave1Viz.prototype.Initialize = function(v_elContainerDiv, v_oVisSettings, v_fnOnInitializeComplete)
- {
- this.m_elContainerDiv = v_elContainerDiv;
- // RAVE is loaded, load the visualization
- this.m_oVisControl = new this.m_oRaveEnv.M_fnVisControl();
- v_elContainerDiv.appendChild( this.m_oVisControl.domNode );
- // hide the focus rect on IE
- if ( G_Rave1Adapter.M_bIsIE )
- {
- this.m_oVisControl.domNode.hideFocus = true;
- }
- this.m_oVisControl.startup().then(dojo.hitch(this, this.f_onRaveStartupAsync, v_oVisSettings, v_fnOnInitializeComplete));
- };
- C_Rave1Viz.prototype.Destroy = function()
- {
- if (this.m_oVisControl)
- {
- this.m_oVisControl.destroy();
- this.m_oVisControl = null;
- }
- };
- /*
- * v_fnOnDrawComplete(v_oDrawStatus)
- * v_oDrawStatus = {
- * error
- * }
- */
- C_Rave1Viz.prototype.Draw = function(v_fnOnDrawComplete)
- {
- if (this.m_sErrorMessage)
- {
- this.DrawBlank();
- v_fnOnDrawComplete({ error : this.m_sErrorMessage });
- return;
- }
- try
- {
- if ( this.m_bDrawWithTransition )
- {
- this.m_oVisControl.setSpecWithTransition(this.m_oVisJSON, 1);
- }
- else
- {
- this.m_oVisControl.setSpec(this.m_oVisJSON);
- }
- }
- catch( e )
- {
- this.DrawBlank();
- var v_sMessage = "";
- if (e.getMessage || e.getErrorDescription)
- {
- v_sMessage = (e.getMessage && e.getMessage()) ? e.getMessage() : "";
- if (v_sMessage == "")
- {
- v_sMessage = (e.getErrorDescription && e.getErrorDescription()) ? e.getErrorDescription() : "";
- }
- }
- v_fnOnDrawComplete({ error : v_sMessage });
- return;
- }
- if ( !this.m_bDrawWithTransition )
- {
- v_fnOnDrawComplete();
- }
- this.m_fnOnDrawComplete = v_fnOnDrawComplete;
- };
- C_Rave1Viz.prototype.DrawHighlights = function(v_aSelectionVisElements, v_aHoverVisElements)
- {
- var v_aSelections = (v_aSelectionVisElements && v_aSelectionVisElements.length) ? this.f_getSceneItemsFromVisElements(v_aSelectionVisElements) : null;
- var v_aHovers = (v_aHoverVisElements && v_aHoverVisElements.length) ? this.f_getSceneItemsFromVisElements(v_aHoverVisElements) : null;
- var o = this.m_oVisControl.interactivity().makeHighlightState();
- if (v_aSelections)
- {
- o.setMultiple( v_aSelections, this.k_iHighlight_Selection );
- }
- if (v_aHovers)
- {
- o.setMultiple( v_aHovers, this.k_iHighlight_Hover );
- }
- o.apply();
- };
- C_Rave1Viz.prototype.DrawBlank = function()
- {
- var v_oBlank = {
- "grammar": [
- ]
- };
- if (this.m_oVisSettings.properties.width && this.m_oVisSettings.properties.height)
- {
- v_oBlank.size = {
- width : this.m_oVisSettings.properties.width,
- height : this.m_oVisSettings.properties.height
- };
- }
- try
- {
- this.m_oVisControl.setSpec(v_oBlank);
- }
- catch(e)
- {
- }
- };
- C_Rave1Viz.prototype.SetData = function(v_idxDataSet, v_oDataSetChanges)
- {
- var v_oDataSet = this.m_oVisJSON.data[v_idxDataSet];
- v_oDataSet.rows = v_oDataSetChanges.rows || [];
- if (v_oDataSetChanges.fields)
- {
- for (var i = 0; i < v_oDataSetChanges.fields.length; ++i)
- {
- var v_oField = v_oDataSetChanges.fields[i];
- var v_oTargetField = v_oDataSet.fields[i];
- var v_aProps = ["label", "min", "max", "categories"];
- for (var ip = 0; ip < v_aProps.length; ++ip)
- {
- var s = v_aProps[ip];
- v_oTargetField[s] = v_oField[s];
- }
- }
- }
- };
- C_Rave1Viz.prototype.GetVisElementsAtPoint = function(v_iClientX, v_iClientY)
- {
- return this.f_createVisElementsForSceneItems(this.m_oVisControl.interactivity().getItemsAtPoint( v_iClientX, v_iClientY ));
- };
- C_Rave1Viz.prototype.GetVisElementsAtTouchPoint = function(v_iClientX, v_iClientY)
- {
- // I believe that the accounting for scroll position is because on an iPad sometimes the body can be scrolled, which does not happen on desktop
- var x = v_iClientX + document.body.scrollLeft;
- var y = v_iClientY + document.body.scrollTop;
- var v_oVisElement = this.GetVisElementsAtPoint( x, y );
- if ( v_oVisElement )
- {
- return v_oVisElement;
- }
- for ( var v_iRadius = 3; v_iRadius <= 12; v_iRadius += 3 )
- {
- var v_oVisElement = this.f_getVisElementInCircle( x, y, v_iRadius );
- if ( v_oVisElement )
- {
- //G_Debug.F_Print( "f_getVisElementInCircle(" + v_iRadius + ")" );
- return v_oVisElement;
- }
- }
-
- return [];
- };
- C_Rave1Viz.prototype.f_getVisElementInCircle = function( x, y, v_iRadius )
- {
- var v_aXs = [];
- var v_aYs= [];
- var v_aRadians = [0.0, 0.25 * Math.PI, 0.5 * Math.PI, 0.75 * Math.PI, Math.PI, 1.25 * Math.PI, 1.5 * Math.PI, 1.75 * Math.PI];
- for ( var i = 0; i < v_aRadians.length; i++ )
- {
- v_aXs.push( x + Math.round( v_iRadius * Math.cos( v_aRadians[i] ) ) );
- v_aYs.push( y + Math.round( v_iRadius * Math.sin( v_aRadians[i] ) ) );
- }
- return this.f_createVisElementsForSceneItems(this.m_oVisControl.interactivity().getItemsInPolygon(v_aXs, v_aYs));
- };
- C_Rave1Viz.prototype.GetVisElementsForRows = function(v_idxDataSet, v_aRows)
- {
- var v_aSceneItems = this.m_oVisControl.interactivity().getItemsMatchingAnyRows(v_aRows);
- var v_aFilteredSceneItems = [];
- for ( var v_iSi = 0; v_iSi < v_aSceneItems.length; v_iSi++ )
- {
- var v_oSceneItem = v_aSceneItems[v_iSi];
- if (v_oSceneItem.getDataIndex() == v_idxDataSet)
- {
- var v_aSceneItemRows = v_oSceneItem.getRows();
- var v_bAdd = true;
- for (var i = 0; i < v_aSceneItemRows.length; ++i)
- {
- if (v_aRows.indexOf(v_aSceneItemRows[i]) == -1)
- {
- v_bAdd = false;
- break;
- }
- }
- if (v_bAdd)
- {
- v_aFilteredSceneItems.push(v_oSceneItem);
- }
- }
- }
- return this.f_createVisElementsForSceneItems(v_aFilteredSceneItems);
- };
- C_Rave1Viz.prototype.SetValueSlotFormatter = function(v_fnNumberFormatter)
- {
- this.m_oVisControl.setNumberFormatter({ formatNumber : this.f_numberFormatterCallback.bind(this, v_fnNumberFormatter) });
- };
- C_Rave1Viz.prototype.f_numberFormatterCallback = function(v_fnNumberFormatter, value, rowIndex, fieldId, min, max, unit, visId)
- {
- return v_fnNumberFormatter(value, rowIndex, fieldId, this.m_oSlotDataSet[fieldId]);
- };
- C_Rave1Viz.prototype.GetCurrentVisualizationState = function()
- {
- return JSON.stringify(this.m_oVisJSON, null, "\t");
- };
- C_Rave1Viz.prototype.SetAccessibilityDescription = function(v_sDescription)
- {
- this.m_oVisJSON.description = v_sDescription;
- };
- C_Rave1Viz.prototype.ApplySettings = function(v_oVisSettings)
- {
- this.m_oVisSettings = v_oVisSettings;
- this.m_oVisControl.setSpecificationValidation(Boolean(this.m_oVisSettings.custom ? this.m_oVisSettings.custom.validateJSON : false));
- this.f_resolveParameters();
- if (v_oVisSettings.properties.width || v_oVisSettings.properties.height)
- {
- if (!this.m_oVisJSON.size)
- {
- this.m_oVisJSON.size = {};
- }
- this.m_oVisJSON.size.width = v_oVisSettings.properties.width;
- this.m_oVisJSON.size.height = v_oVisSettings.properties.height;
- // Explicitly setting the size avoids RAVE bugs with resizing in Silverlight
- this.m_oVisControl.domNode.style.width = this.m_oVisJSON.size.width;
- this.m_oVisControl.domNode.style.height = this.m_oVisJSON.size.height;
- }
- this.m_bDrawWithTransition = false;
- var v_sAnimationEffect = v_oVisSettings.properties.animationEffect;
- if (v_sAnimationEffect && v_sAnimationEffect != "none")
- {
- this.m_bDrawWithTransition = true;
- var v_oEffects = this.m_oVisControl.interactivity().getChangeEffects();
- var v_oEffect;
- switch (v_sAnimationEffect)
- {
- case "transition":
- v_oEffect = v_oEffects.makeTransitionEffect( 500 );
- v_oEffect.setFadeOutDuration(0.0, 1.0);
- v_oEffect.setMorphDuration(0.0, 1.0);
- v_oEffect.setFadeInDuration(0.0, 1.0);
- break;
- case "fadeIn":
- v_oEffect = v_oEffects.makeFadeInEffect( 500 );
- break;
- case "flyIn":
- v_oEffect = v_oEffects.makeFlyInEffect( 500 );
- break;
- case "grow":
- v_oEffect = v_oEffects.makeGrowEffect( 500 );
- break;
- case "reveal":
- v_oEffect = v_oEffects.makeRevealEffect( 500 );
- break;
- default:
- // unknow animation effect, ignore
- this.m_bDrawWithTransition = false;
- if (console && console.log) { console.log("Unknown animationEffect ignored: " + v_sAnimationEffect); }
- break;
- }
- v_oEffect.setTarget( this.m_oRaveEnv.M_fnVisChangeEffect.ELEMENT );
- v_oEffects.setChangeEffect( v_oEffect, 1 );
- // set up rave event handler so we can draw selections after animation effects
- this.update = dojo.hitch(this, this.f_onRaveEvent);
- this.m_oVisControl.addListener("EffectEndEvent", this);
- }
- // Setup highlights for selection and hovering
- var v_oSelectionHighlight =
- {
- fill : "rgba(242,188,102,0.4)",
- outline : "#F2BC66",
- stroke : { width : "1.75pt" }
- };
- /*
- var v_oSelectionHighlight =
- {
- fill : "rgba(255,255,255,0.6)",
- outline : "rgba(255,255,255,0.6)",
- stroke : { width : "1.75pt" }
- };
- */
- var v_oHoverHighlight =
- {
- fill : "rgba(247,225,188,0.4)",
- outline : "#F2BC66",
- stroke : { width : "1.75pt" }
- };
- var v_oInteractivity = this.m_oVisControl.interactivity();
- v_oInteractivity.setHighlightRepresentation(this.k_iHighlight_Selection, new this.m_oRaveEnv.M_fnVisHighlightRepresentation( v_oSelectionHighlight ));
- v_oInteractivity.setHighlightRepresentation(this.k_iHighlight_Hover, new this.m_oRaveEnv.M_fnVisHighlightRepresentation( v_oHoverHighlight ));
- };
- /**
- * @type Boolean Returns false if there was an error while applying the parameters
- */
- C_Rave1Viz.prototype.f_resolveParameters = function()
- {
- var v_sVersion = this.m_oVisJSONBundle.version;
- if (!v_sVersion || parseFloat(v_sVersion) < 5.0)
- {
- if (this.m_oVisJSON == null)
- {
- this.m_oVisJSON = dojo.clone(this.m_oVisJSONBundle);
- }
- return;
- }
- //Logged https://rtc-rave.ottawa.ibm.com:9451/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/16859
- //Add JSON interface to template constructor and return value of resolve method
- var v_sOriginalJSON = this.m_sVisJSON;
- var v_bResolvedTemplate = false;
- var v_oResolvedJSON = "";
- try
- {
- //The object passed to createTemplateFromJSON will be modified
- var v_oClone = dojo.clone( this.m_oVisJSONBundle );
- var v_oTemplate = this.m_oRaveEnv.M_fnVisTemplate.createTemplateFromJSON( v_oClone );
- if (v_oTemplate.hasParameters())
- {
- //Logged https://rtc-rave.ottawa.ibm.com:9451/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/16928
- //RAVE should return an object of type Array directly
- var v_aParams = v_oTemplate.getParameters().toArray();
- for (var i = 0; i < v_aParams.length; i++)
- {
- var v_oParam = v_aParams[i];
- var v_sParamId = v_oParam.getId();
- if (typeof this.m_oVisSettings.properties[v_sParamId] != "undefined")
- {
- v_oTemplate.setParameterValue(v_sParamId, this.m_oVisSettings.properties[v_sParamId]);
- }
- }
- if (v_oTemplate.canBeResolved())
- {
- v_oResolvedJSON = v_oTemplate.resolveToJSON();
- v_bResolvedTemplate = true;
- }
- }
- }
- catch(e)
- {
- var v_sMessage = "";
- if (e.getMessage || e.getErrorDescription)
- {
- v_sMessage = (e.getMessage && e.getMessage()) ? e.getMessage() : "";
- if (v_sMessage == "")
- {
- v_sMessage = (e.getErrorDescription && e.getErrorDescription()) ? e.getErrorDescription() : "";
- }
- }
- this.m_sErrorMessage = v_sMessage;
- }
- if (v_bResolvedTemplate)
- {
- try {
- // The new JSON is the one after resolved, here we need to keep the data.
- if (this.m_oVisJSON != null)
- {
- var v_oData = this.m_oVisJSON.data;
- this.m_oVisJSON = v_oResolvedJSON;
- this.m_oVisJSON.data = v_oData;
- }
- else
- {
- this.m_oVisJSON = v_oResolvedJSON;
- }
- }
- catch(e)
- {
- this.m_sErrorMessage = e.message ? e.message : " ";
- }
- }
- else if (this.m_oVisJSON == null)
- {
- this.m_oVisJSON = dojo.clone(this.m_oVisJSONBundle);
- }
- };
- C_Rave1Viz.prototype.f_onRaveStartupAsync = function(v_oVisSettings, v_fnOnInitializeComplete)
- {
- // The dojo 'then' introduces a try/catch block. This setTimeout prevent that block from interfering with subsequent exceptions.
- // The setTimeout should be removed if the defered dojo code is removed.
- setTimeout( dojo.hitch(this, this.f_onRaveStartup, v_oVisSettings, v_fnOnInitializeComplete), 0 );
- };
- C_Rave1Viz.prototype.k_iHighlight_Selection = 0;
- C_Rave1Viz.prototype.k_iHighlight_Hover = 1;
- C_Rave1Viz.prototype.f_onRaveStartup = function(v_oVisSettings, v_fnOnInitializeComplete)
- {
- this.ApplySettings(v_oVisSettings);
- v_fnOnInitializeComplete();
- };
- C_Rave1Viz.prototype.f_onRaveEvent = function(v_oEvent, v_oController)
- {
- if (this.m_fnOnDrawComplete && v_oEvent.getEventGroup() == "EffectEndEvent")
- {
- var v_fnOnDrawComplete = this.m_fnOnDrawComplete;
- this.m_fnOnDrawComplete = null;
- v_fnOnDrawComplete();
- }
- };
- C_Rave1Viz.prototype.f_getSceneItemsFromVisElements = function(v_aVisElements)
- {
- var a = [];
- for (var i = 0; i < v_aVisElements.length; ++i)
- {
- a.push(v_aVisElements[i].m_oSceneItem);
- }
- return a;
- };
- C_Rave1Viz.prototype.f_createVisElementsForSceneItems = function(v_aSceneItems)
- {
- var a = [];
- for (var i = 0; i < v_aSceneItems.length; ++i)
- {
- a.push(new C_Rave1VizElement(v_aSceneItems[i], this.m_oRaveEnv));
- }
- return a;
- };
- C_Rave1Viz.prototype.IsEqualVisElement = function(v_oVisElement1, v_oVisElement2)
- {
- if (v_oVisElement1 && v_oVisElement2)
- {
- return (v_oVisElement1.m_oSceneItem == v_oVisElement2.m_oSceneItem);
- }
- // return true if both are null
- return (v_oVisElement1 == v_oVisElement2);
- };
- //==================================================================================
- var C_Rave1VizElement = function(v_oSceneItem, v_oRaveEnv)
- {
- this.m_oSceneItem = v_oSceneItem;
- this.m_oRaveEnv = v_oRaveEnv;
- };
- C_Rave1VizElement.prototype.GetType = function()
- {
- if (!this.m_sType)
- {
- var v_sType = this.m_oSceneItem.getType();
- var v_sSubType = this.m_oSceneItem.subType();
- if (v_sType == this.m_oRaveEnv.M_fnSceneItemTypes.TYPE_ELEMENT && v_sSubType != this.m_oRaveEnv.M_fnSceneItemTypes.SUBTYPE_LABEL)
- {
- this.m_sType = "intersection";
- }
- else
- {
- this.m_sType = "category";
- }
- }
- return this.m_sType;
- };
- C_Rave1VizElement.prototype.GetDataSetIdx = function()
- {
- return this.m_oSceneItem.getDataIndex();
- };
- C_Rave1VizElement.prototype.GetRows = function()
- {
- return this.m_oSceneItem.getRowsWithoutAugmentedRows();
- };
- C_Rave1VizElement.prototype.GetFields = function()
- {
- // TBD
- };
- C_Rave1VizElement.prototype.GetColor = function()
- {
- var v_oColor = this.f_getColorFromSceneItem(this.m_oSceneItem);
- if (!v_oColor)
- {
- var v_aChildren = this.m_oSceneItem.getHitChildren();
-
- if (v_aChildren)
- {
- for (var i = 0; !v_oColor && (i < v_aChildren.length); ++i)
- {
- v_oColor = this.f_getColorFromSceneItem(v_aChildren[i]);
- }
- }
- }
- if (v_oColor != null)
- {
- var v_oJSColor = {};
- var v_aColors = v_oColor.getRGBA();
- if (v_aColors.length >= 3)
- {
- v_oJSColor.r = v_aColors[0];
- v_oJSColor.g = v_aColors[1];
- v_oJSColor.b = v_aColors[2];
- return v_oJSColor;
- }
- }
- return v_oColor;
- };
- C_Rave1VizElement.prototype.f_getColorFromSceneItem = function(v_oSceneItem)
- {
- var v_oStyle = v_oSceneItem.getSceneNode().getRenderStyleInfo();
- // get the fill; if non-null, try first the gradient, then the solid
- var v_oFill = v_oStyle.getFillProperty();
- if (v_oFill != null)
- {
- var v_aColors = v_oFill.getGradientColors(); // returns an array of colors
- if (v_aColors != null && v_aColors.length >= 1)
- {
- return v_aColors[0];
- }
- var v_oSolid = v_oFill.getSolid(); // returns a single color
- if (v_oSolid != null)
- {
- return v_oSolid;
- }
- }
- // fill didn't work, try the outline
- var v_oOutline = v_oStyle.getOutlineProperty();
- if (v_oOutline != null)
- {
- return v_oOutline;
- }
- return null;
- };
- return G_Rave1Adapter;
- });
|