;(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['rave', 'rave-library', 'rave-utilities', 'rave-legends', 'mapboxgl'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('rave'), require('rave-library'), require('rave-utilities'), require('rave-legends'), require('mapboxgl'));
} else {
root.raveLibraryTiledmapV2 = factory(root.rave, root.raveLibrary, root.raveUtilities, root.raveLegends, root.mapboxgl);
}
}(this, function(rave, raveLibrary, raveUtilities, raveLegends, mapboxgl) {
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o A component that renders the background to the chart. The {@link #this.type()} method returns "BackgroundComponent". A component that does the layout for a bundle chart. The {@link #this.type()} method returned "ChartLayoutComponent". Chart layout is controlled by the following properties: Manages one or more legend components for a bundle. The number of legends N is fixed and declared in the constructor, and legends are identified by an array index number between 0 and N-1. (For now we don't need a dynamic collection, especially since we're generating the chart structure statically and each legend gets its own <g&;gt; node. If a chart sometimes needs one legend and sometimes two, it will create two nodes and construct the manager for two legends.) The manager has the following properties: Each legend has the following properties: The general pattern of use is to create the LegendsManager in the view's constructor or setup method, allocating the maximum number of legends that will ever be needed. The chart structure will have corresponding <g> nodes, and in the view's draw method all the legend selectors are set to the corresponding group. The legend palettes, titles, and formatters will usually be set next, making sure to set the palettes of any unused legends to null, and {@link #this.anyVisible()} used to find if any rectangles need to be drawn so the overall chart may be laid out. The rectangle, orientation, and transition information can then be set and {@link #this.draw()} called. The visible legends (those with palettes) divide the rectangle equally along the orientation. For example if there are three legends in horizontal orientation and two are visible, they will split the rectangle vertically in half. Legends are drawn left-to-right for horizontal orientation, and top-to-bottom for vertical orientation, in index order. If a transition is requested and the duration is non-negative, a transition is created from the legend's selector; otherwise the selector is used. However, in order to give a somewhat better appearance, a transition is not used if the legend was not visible (no shapes rendered) the last time it was drawn. Managers the axes and gridlines for a bundle. The manager handles rectangular axes, where the axes are drawn to the top, bottom, left, and/or right of a central chart. The manager does not do the layout of axes or the setup of scales. Bundle views will normally create an instance in the setup method, then set properties in their draw method and call {@link #this.draw()} to render all the axes and gridlines (including setting the transforms and clip paths on the groups). The manager has four axes and four gridlines, identified by the logical roles X1, X2, Y1, Y2. These corresponding to the constants in the {@link (com.ibm.rave.bundles.component.AxisComponent) AxisComponent} API. The X roles are the independent axes and the Y roles are the dependent axes. The manager will create an instance of the {@link (com.ibm.rave.bundles.components.AxisComponentImpl) AxisComponentImpl} or {@link (com.ibm.rave.bundles.components.GridComponentImpl) GridComponentImpl} for each role as it is required. The manager has four group (<g>) selectors for axes and four for gridlines, identified by their geometric positions top, bottom, left, and right. In bundles the group structure is created when the bundle first runs, so these selectors can in theory be set just once. Note that the axes and grids are identified logically, while the groups are identified geometrically. By default X1 is the bottom group, X2 the top, Y1 the left, and Y2 the right. This association is controlled by properties which transpose and/or flip the assignments. This is in part a RAVE/D3 requirement, since the core Axis examines the shapes in the group to generate transitions. The group selectors should be ordinary selectors. If a transition is requested and the transition duration is non-negative, the manager creates transitions from the selectors. However in order to give a somewhat better appearance, the manager keeps track of whether shapes were drawn into the group on the previous execution, and a transition is not used if the group was not used. The manager has the following overall properties: The manager has the following per-role (X1, X2, Y1, Y2) properties: The manager has the following per-position (bottom, top, left, right) properties: An {@link (com.ibm.rave.bundles.components.AxisComponentImpl) AxisComponentImpl} and {@link (com.ibm.rave.bundles.components.GridComponentImpl) GridComponentImpl} can be obtained for each role. These instances are created on demand, usually when a view requests the instance, but also if the manager is drawing and detects that the instance is needed. Once created the instance will be used by the manager thereafter. Views should use these instances to configure the appearance properties of the axes and grids. All other properties (such as scale, bounds, orient, role, and pre-execution callback) are set by the AxesManager. Views can set these properties but the manager's {@link #this.draw()} method will change the settings. Values for some of these properties (e.g. scale and bounds) are set in the manager by the view, and the others are found automatically by the manager. Layout Properties
*/
var com_ibm_rave_bundles_component_ChartLayoutComponent = rave['internal']['Declare'].implement(
//padding : function() {},
//topPadding : function() {},
//leftPadding : function() {},
//bottomPadding : function() {},
//rightPadding : function() {},
//legendChartAlign : function() {},
//legendPosition : function() {},
//legendChartGap : function() {},
//legendPosition : function(position) {},
//topPadding : function(value) {},
//leftPadding : function(value) {},
//bottomPadding : function(value) {},
//rightPadding : function(value) {},
/**
* Sets the padding around the outside of the chart/legend.
* @param (Object) value a string containing up to 4 CSS sizes for left, top, right, bottom padding (eg. "padding-left:10px;padding-top:10%"). Null is treated as 0.
* @return (com.ibm.rave.bundles.component.ChartLayoutComponent) This object
*/
//padding : function(value) {},
/**
* Sets all chart paddings. Null values are treated as 0.
* @param (Object) top New top padding
* @param (Object) left New left padding
* @param (Object) bottom New bottom padding
* @param (Object) right New right padding
* @return (com.ibm.rave.bundles.component.ChartLayoutComponent) This object
* @deprecated Please use {@link #this.padding(Object)} and {@link #this.legendChartGap(Object)}
*/
//chartPadding : function(top, left, bottom, right) {},
/**
* Sets whether the legend should align with the chart "body".
* @param (boolean) legendChartAlign the boolean state
* @return (com.ibm.rave.bundles.component.ChartLayoutComponent) This object
*/
//legendChartAlign : function(legendChartAlign) {},
/**
* Set the space for the gap between chart and legend
* @param (Object) value the gap distance (css length)
* @return (com.ibm.rave.bundles.component.ChartLayoutComponent) This object
*/
//legendChartGap : function(value) {},
/**
* Set the size information for the legend. Null value is treated as no visible legend.
* @param (com.ibm.rave.bundles.component.ChartLayoutSizable) sizable An object that implements the ChartLayoutSizable interface
* @return (com.ibm.rave.bundles.component.ChartLayoutComponent) This object
*/
//legendSize : function(sizable) {},
/**
* Reset list of axis sizables to 0
* @return (com.ibm.rave.bundles.component.ChartLayoutComponent) This object
*/
//removeAxisSizables : function() {},
/**
* Add an axis to be considered in layout operation.
* @param (com.ibm.rave.bundles.component.ChartLayoutSizable) sizable An object that implements the ChartLayoutSizable interface
* @return (com.ibm.rave.bundles.component.ChartLayoutComponent) This object
*/
//addAxisSizable : function(sizable) {}
);
/**
* The string returned by {@link #this.type()} is "ChartLayoutComponent".
*/
/** @expose */
com_ibm_rave_bundles_component_ChartLayoutComponent.COMPONENT_TYPE = "ChartLayoutComponent";
// $source: com/ibm/rave/bundles/components/LegendsManager
/************************************************************************
** IBM Confidential
**
** IBM Business Analytics: Rapidly Adaptive Visualization Engine
**
** (C) Copyright IBM Corp. 2017
**
** 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.
************************************************************************/
// GENERATED
//@import com/ibm/rave/bundles/components/LegendComponentImpl (runtime) // new, orientationOf
/**
*
Properties
Components
To associate multiple data slots with an axis role, see {@link #this.setDataSlot(, Array)} .
* @param (int) role An axis role, one of {@link this.AxesManager#0} , {@link this.AxesManager#1} , {@link this.AxesManager#2} , {@link this.AxesManager#3} .
* @param (rave['library']['internal']['DataSlotEntry']) slot DataSlotEntry to be associated with the axis role.
*/
setDataSlot$0 : function(role, slot) {
this.setDataSlot$1(role, [slot]);
return this;
},
/**
* Set a list of data slot entries that will be associated with the specified axis role.
* @param (int) role An axis role, one of {@link this.AxesManager#0} , {@link this.AxesManager#1} , {@link this.AxesManager#2} , {@link this.AxesManager#3} .
* @param (Array) slots List of DataSlotEntry to be associated with the axis role.
*/
setDataSlot$1 : function(role, slots) {
if (role < 4 && role >= 0) {
this._dataSlotEntries[role].length = 0;
if (slots) {
for (var __i_enFor0 = 0, __exp_enFor0 = slots, __len_enFor0 = __exp_enFor0.length;
__i_enFor0 < __len_enFor0; ++__i_enFor0) {
var slot = __exp_enFor0[__i_enFor0];
this._dataSlotEntries[role].push(slot);
}
}
}
return this;
},
/**
*
A component that renders an axis (RAVE core Axis) with an optional title in an XY axis chart. The {@link #this.type()} method returns "AxisComponent".
The {@link #this.role()} method is used to identify the axis. Most charts with axes will use only the {@link #"ROLE_X1"} and {@link #"ROLE_Y1"} roles. The composite bundle also uses {@link #"ROLE_Y2"} . {@link #"ROLE_X2"} is not currently used by any chart.
The axis component uses a RAVE capability axis, available with {@link #this.axis()} . When used with a pre-execution callback, the axis is only valid for the duration of the callback (do not use the reference outside the callback). Properties of the capability axis may be set by the pre-execution callback, but note that many properties are set by the AxisComponent after the callback. To change those properties, use the methods of this class to change the AxisComponent, which will then set the capability axis properties.
*/ var com_ibm_rave_bundles_component_AxisComponent = rave['internal']['Declare'].implement( /** * @return (String) The role of the axis in the chart */ //role : function() {}, /** * @return (rave['internal']['Axis']) The capability Axis used by this AxisComponent */ //axis : function() {}, /** * The tickFormat is applied to the values of the ticks to create the string that is displayed. * @param (rave['internal']['ValueFunction']) tickFormat The new tickFormat * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //tickFormat : function(tickFormat) {}, /** * Get the tickFormat function used by this component. May be null. * @return (rave['internal']['ValueFunction']) Format function, or null */ //tickFormat : function() {}, /** * Set the indicator to be used for truncated text ex: indicator set to "..." , results in helloworld - > hello... * @param (String) indicator the string to be placed to indicated truncated text * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //textTruncateIndicator : function(indicator) {}, /** * Whether to display the axis title. * @param (boolean) displayAxisTitle true to display the axis title, false otherwise * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //displayAxisTitle : function(displayAxisTitle) {}, /** * Whether to display the axis line. * @param (boolean) displayAxisLine true to display the axis line, false otherwise * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //displayAxisLine : function(displayAxisLine) {}, /** * Whether to display the axis tick marks. * @param (boolean) displayTicks true to display the axis ticks, false otherwise * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //displayTicks : function(displayTicks) {}, /** * Whether to display the axis labels, as set by the show axis labels property * @param (boolean) displayTickLabels true to display the axis tick labels, false otherwise * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //displayTickLabels : function(displayTickLabels) {}, /** * Whether to display the axis labels, as set by the hide pan-zoom labels property * @param (boolean) showPanZoomTickLabels true to display the axis tick labels, false otherwise * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //showPanZoomTickLabels : function(showPanZoomTickLabels) {}, /** * @param (String) axisTitle The new axisTitle * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //axisTitle : function(axisTitle) {}, /** * The color used to draw the axis line and ticks. This is equivalent to calling both {@link #this.lineColor(String)} and {@link #this.tickColor(String)} . * @param (String) axisColor The new line and tick color * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //axisColor : function(axisColor) {}, /** * The color used to draw the axis line. * @param (String) lineColor The new lineColor * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //lineColor : function(lineColor) {}, /** * The color used to draw the axis ticks. * @param (String) tickColor The new tickColor * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //tickColor : function(tickColor) {}, /** * The color used to draw the axis labels. * @param (String) labelColor The new labelColor * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //labelColor : function(labelColor) {}, /** * The style for the axis labels. * @param (String) fontStyle CSS string of font properties * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //labelStyle : function(fontStyle) {}, /** * The style for the axis labels. * @param (String) fill The color used to draw the labels * @param (String) fontSize CSS font size * @param (String) fontFamily CSS font-families list * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //labelStyle : function(fill, fontSize, fontFamily) {}, /** * The color used to draw the axis title. * @param (String) titleColor The new titleColor * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //titleColor : function(titleColor) {}, /** * The style for the axis title. * @param (String) fontStyle CSS string of font properties * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //titleStyle : function(fontStyle) {}, /** * The style for the axis title. * @param (String) fill The color used to draw the title * @param (String) fontSize CSS font size * @param (String) fontFamily CSS font-families list * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ //titleStyle : function(fill, fontSize, fontFamily) {} ); /** * The string returned by {@link #this.type()} is "AxisComponent". */ /** @expose */ com_ibm_rave_bundles_component_AxisComponent.COMPONENT_TYPE = "AxisComponent"; /** * Returned by {@link #this.role()} for the first independent axis. */ /** @expose */ com_ibm_rave_bundles_component_AxisComponent.ROLE_X1 = "ROLE_X1"; /** * Returned by {@link #this.role()} for the first dependent axis. */ /** @expose */ com_ibm_rave_bundles_component_AxisComponent.ROLE_Y1 = "ROLE_Y1"; /** * Returned by {@link #this.role()} for the second independent axis. */ /** @expose */ com_ibm_rave_bundles_component_AxisComponent.ROLE_X2 = "ROLE_X2"; /** * Returned by {@link #this.role()} for the second dependent axis. */ /** @expose */ com_ibm_rave_bundles_component_AxisComponent.ROLE_Y2 = "ROLE_Y2"; // $source: com/ibm/rave/bundles/utilities/TextCrossfader /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ // GENERATED /** *Utility class for setting up a cross-fade of a single text node. This could be extended to a multiple-node selection (e.g. using value functions to return the text strings for each node in the selection), but that is not yet needed in the bundles. However use this with care, since if the transition does select multiple texts, they will all change to the new text string.
Any other text properties that are changing, for example the color or position, can be set up in the transition either before or after calling the utility method.
*/ var com_ibm_rave_bundles_utilities_TextCrossfader = rave['internal']['Declare']({ }); /** *Perform a text cross fade for a single text node. The selection holds that node. If it is not a transition, the new text is set; otherwise the cross-fade transition is done using tweeners on the "text" and "fill-opacity" attributes.
The "text" attribute tweener uses the oldText before transition time 0.5, and the new text thereafter. (Note this assumes that the old text is in fact the node's text; if not, the displayed text will change to the "old" text when the transition begins, then to the new text halfway through the transition.)
The text is optionally faded out and back in, disappearing completely at time 0.5, by setting the "fill-opacity" style attribute. The fading is controlled by the delay argument, which is clamped to the range [0.0, 0.5]. If the clamped delay is 0.5, or if the text does not actually change, no crossfade is used. Otherwise the opacity is full for transition times less than the delay or greater than 1-delay, fading to 0.0 at time 0.5. For example if the delay is 0.2, the opacity will be full from transition time 0.0 to 0.2, fade out linearly to 0 at time 0.5, fade in linearly to full at time 0.8, and be full from time 0.8 to 1.0.
The old and new texts and the full opacity are all passed as arguments, because it is generally not safe to try to find the values when the method runs. In particular, if we run this method while a transition (such as a previous cross-fade) is already in progress, we may pick up an intermediate fill-opacity value, perhaps even 0.0, and set the text opacity to that value! * @param (rave['internal']['Selection']) selection Selection containing the single text node, may be a transition * @param (String) oldText Old value of the text string, may be null * @param (String) newText New value of the text string, may be null * @param (Object) fillOpacity Fill opacity, may be null (in which case 1.0 is assumed) * @param (double) delay Number between 0 and 0.5 controlling the timing of the fade * @return (rave['internal']['Selection']) The selection, modified by the new text and fill-opacity */ /** @expose */ com_ibm_rave_bundles_utilities_TextCrossfader.textCrossFade = function(selection, oldText, newText, fillOpacity, delay) { if (!(selection.isTransition())) { return selection.text(newText); } var _t = (selection).tween("text", function(data, index, groupIndex) { return function(t) { this.rave_setText(t < 0.5 ? oldText : newText); }; }); var t0 = Math.max(0.0, Math.min(0.5, delay)); if (t0 == 0.5 || (oldText == null && newText == null) || (oldText != null && oldText == newText)) { return selection; } var opacity = fillOpacity == null ? 1.0 : + (fillOpacity); var tf = 1.0 / (0.5 - t0); return _t.tween("fill-opacity", function(data, index, groupIndex) { return function(t) { if (t <= t0 || t >= (1.0 - t0)) { this.rave_setStyle("fill-opacity", fillOpacity); } else { this.rave_setStyle("fill-opacity", opacity * Math.abs(t - 0.5) * tf); } }; }); }; // $source: com/ibm/rave/bundles/utilities/BundleLabelDropper /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ // GENERATED var com_ibm_rave_bundles_utilities_BundleLabelDropper = rave['internal']['Declare']({ //_dropOverlap : null, labelCount : 0, _$functionClassMethod : function() { var _$self = function(args) { if (args !== null || arguments.length > 1){ args = Array.prototype.slice.call(arguments, 0); } { _$self.drop(args[0], ((args[1]))); return null; } }; return _$self; }, /** @expose */ constructor : function() { this._dropOverlap = (rave.capabilities.extension("position")).drop().remove(false); this._dropOverlap.setOverlapGap(4.0); }, /** * Drop the overlapping labels or reset the overlap. * @param (rave['internal']['Selection']) labels The selector for the labels * @param (boolean) removeOverlap true to remove the overlapping labels, false to reset */ /** @expose */ drop : function(labels, removeOverlap) { if (!(labels.isTransition())) { this.applyLabelDrop(labels, removeOverlap); } else { var steps = [0, 25, 75]; var self = this; (labels).tween("__pointLabelDrop__", function(data, index, groupIndex) { if (index == 0) { return function(t) { var currentStep = Math.floor(t * 100); if (steps.length > 0 && currentStep < 100 && currentStep >= steps[0]) { steps.splice(0, 1); self.applyLabelDrop(labels, removeOverlap); } }; } return null; }); this.labelCount = 0; (labels).each(function(data, index, groupIndex) { ++self.labelCount; }).each("end", function(args) { if (args !== null || arguments.length > 1){ args = Array.prototype.slice.call(arguments, 0); } { if (--self.labelCount == 0) { self.applyLabelDrop(labels, removeOverlap); } return null; } }); } }, applyLabelDrop : function(labels, removeOverlap) { if (removeOverlap) { labels.call(this._dropOverlap); } else { this._dropOverlap.reset(labels); } }, /** @expose */ configureForDataLabels : function(rect) { if (rect) { var ex = [[rect.x, rect.y], [rect.x + rect.width, rect.y + rect.height]]; this._dropOverlap.extent(ex); } this._dropOverlap.noClipping(); } }); /** * Drop overlap extension */ //com_ibm_rave_bundles_utilities_BundleLabelDropper.POSITION_EXTENSION = "position"; /** * space between labels during overlap testing */ com_ibm_rave_bundles_utilities_BundleLabelDropper.OVERLAP_GAP = 4; // $source: com/ibm/rave/bundles/components/StyleStructs /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ // GENERATED /** * Struct classes to hold style properties. */ var com_ibm_rave_bundles_components_StyleStructs = rave['internal']['Declare']({ }); /** * Filled shape style properties. */ com_ibm_rave_bundles_components_StyleStructs.ShapeStyle = function() { this._fill = null; this._stroke = null; this._strokeWidth = null; }; /** * Line style properties. */ com_ibm_rave_bundles_components_StyleStructs.LineStyle = function() { this._stroke = null; this._strokeWidth = null; this._dashArray = null; }; // $source: com/ibm/rave/bundles/component/GridComponent /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ // GENERATED /** *
A component that renders gridlines in an XY axis chart. The {@link #this.type()} method returns "GridComponent".
The {@link #this.role()} method is used to identify the grid. The return values are defined in {@link (com.ibm.rave.bundles.component.AxisComponent) AxisComponent} : {@link this.AxisComponent#"ROLE_X1"} , {@link this.AxisComponent#"ROLE_Y1"} , and so on.
*/ var com_ibm_rave_bundles_component_GridComponent = rave['internal']['Declare'].implement( /** * @return (String) The role of the grid in the chart */ //role : function() {}, /** * Whether to display the gridlines. * @param (boolean) displayGridlines The new displayGridlines * @return (com.ibm.rave.bundles.component.GridComponent) This component */ //displayGridlines : function(displayGridlines) {}, /** * Set the line styling. Equivalent to calling {@link #this.gridlineColor(String)} and {@link #this.dashArray(String)} . * @param (String) stroke The stroke color * @param (String) dashArray The stroke-dasharray * @return (com.ibm.rave.bundles.component.GridComponent) This component */ //gridlineStyle : function(stroke, dashArray) {}, /** * The color used to draw the gridlines. * @param (String) gridlineColor The new stroke color * @return (com.ibm.rave.bundles.component.GridComponent) This component */ //gridlineColor : function(gridlineColor) {}, /** * The dashing used to draw the gridlines. The argument is a string, giving a comma-separated list of numbers as used with the SVG "stroke-dasharray" style. * @param (String) dashArray The new dash array * @return (com.ibm.rave.bundles.component.GridComponent) This component */ //dashArray : function(dashArray) {} ); /** * The string returned by {@link #this.type()} is "GridComponent". */ /** @expose */ com_ibm_rave_bundles_component_GridComponent.COMPONENT_TYPE = "GridComponent"; // $source: com/ibm/rave/bundles/components/IntervalDataUtilities /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ // GENERATED /** * A structure for holding interval data (IntervalData}, and utilities for building an array of the data from the tabular data and accessors objects. The array has one entry per entry in the tabular data, and the array entries are in the same order as the datum rows for joining by selectors. */ var com_ibm_rave_bundles_components_IntervalDataUtilities = rave['internal']['Declare']({ }); /** *Create intervals for a simple bar chart. The intervals come directly from the data, with the independent interval the independent value (for both ends) and the dependent interval 0.0 to the dependent value. The group and label are copied from the datum. The callout independent is the independent value, and the callout dependent is the dependent value (the bar extent).
If the xScale is non-null and returns null for an independent (X) value, the data is skipped.
* @param (Array) data Data array * @param (rave['internal']['SingleValueFunction']) x X accessor, should not be null * @param (rave['internal']['SingleValueFunction']) xScale Function to check if the X value is valid * @param (rave['internal']['SingleValueFunction']) y Y accessor, should not be null * @param (rave['internal']['SingleValueFunction']) color Color accessor, may be null * @param (rave['internal']['SingleValueFunction']) label Label accessor, may be null * @return (Array) Array of intervals for the data */ /** @expose */ com_ibm_rave_bundles_components_IntervalDataUtilities.simpleBars = function(data, x, xScale, y, yStart, color, label) { var result = []; if (!data || data.length == 0 || !x || !y) { return result; } data.forEach(function(d, ix, list) { var xv = x(d); if (xv != null && (!xScale || xScale(xv) != null)) { var yv = y(d); var yvStart = !yStart ? 0 : yStart(d); if (yv != null && yvStart != null) { var r = new com_ibm_rave_bundles_components_IntervalDataUtilities.IntervalData(); r.key = ix; r.ind1 = xv; r.ind2 = r.ind1; r.cind = r.ind1; r.dep1 = yvStart; r.dep2 = yv; r.cdep = r.dep2; r.color = color ? color(d) : null; r.label = label ? label(d) : null; r.value = r.dep2; r._originalData = d; r.valueAsPercentOfCategory = 100; result.push(r); } } return null; }); var sum = 0; for (var i = 0; i < result.length; ++i) { var iData = result[i]; var value = + (iData.value); sum += Math.abs(value); } if (sum != 0) { for (var i = 0; i < result.length; ++i) { var iData = result[i]; var value = + (iData.value); iData.valueAsPercentOfColor = value / sum * 100; } } return result; }; /** * Create intervals for bars in a clustered chart. This is similar to the simple bars, except the independent values are an array of accessors. * @param (Array) data Data array * @param (Array) x Independent accessor array, should not be null and no entries should be null * @param (Array) xScale Array of possibly-null functions to check if X values are in domain; array should not be null, and should be same length as x * @param (rave['internal']['SingleValueFunction']) y Dependent accessor, should not be null * @param (rave['internal']['SingleValueFunction']) color Color accessor, may be null * @param (rave['internal']['SingleValueFunction']) label Label accessor, may be null * @return (Array) Array of intervals for the data */ /** @expose */ com_ibm_rave_bundles_components_IntervalDataUtilities.clusteredBars = function(data, x, xScale, y, yStart, color, label) { var result = []; if (!data || data.length == 0 || !x || x.length == 0 || !y) { return result; } var len = x.length; var categories = {}; var colors = {}; data.forEach(function(d, ix, list) { var OK = true; var ind = []; for (var i = 0; i < len; ++i) { var xv = x[i](d); if (xv == null || (xScale[i] && xScale[i](xv) == null)) { OK = false; break; } ind.push(xv); if (i == 0) { if (!(categories.hasOwnProperty(xv))) { categories[""+(xv)] = 1; } } else if (!(colors.hasOwnProperty(xv))) { colors[""+(xv)] = 1; } } var dep = y(d); var depStart = !yStart ? 0 : yStart(d); if (OK && dep != null && depStart != null) { var r = new com_ibm_rave_bundles_components_IntervalDataUtilities.IntervalData(); r.key = ix; r.ind1 = ind; r.ind2 = ind; r.cind = ind; r.dep1 = depStart; r.dep2 = dep; r.cdep = r.dep2; r.color = color ? color(d) : null; r.label = label ? label(d) : null; r.value = r.dep2; r._originalData = d; result.push(r); } return null; }); for (var __i_enFor0 = 0, __exp_enFor0 = Object.keys(categories), __len_enFor0 = __exp_enFor0.length; __i_enFor0 < __len_enFor0; ++__i_enFor0) { var o = __exp_enFor0[__i_enFor0]; var s = ""+(o); var sum = 0; for (var i = 0; i < result.length; ++i) { var iData = result[i]; if (s == (iData.ind1)[0]) { var value = + (iData.value); sum += Math.abs(value); } } if (sum == 0) { continue; } for (var i = 0; i < result.length; ++i) { var iData = result[i]; if (s == (iData.ind1)[0]) { var value = + (iData.value); iData.valueAsPercentOfCategory = value / sum * 100; } } } for (var __i_enFor1 = 0, __exp_enFor1 = Object.keys(colors), __len_enFor1 = __exp_enFor1.length; __i_enFor1 < __len_enFor1; ++__i_enFor1) { var o = __exp_enFor1[__i_enFor1]; var s = ""+(o); var sum = 0; for (var i = 0; i < result.length; ++i) { var iData = result[i]; if (s == iData.color) { var value = + (iData.value); sum += Math.abs(value); } } if (sum == 0) { continue; } for (var i = 0; i < result.length; ++i) { var iData = result[i]; if (s == iData.color) { var value = + (iData.value); iData.valueAsPercentOfColor = value / sum * 100; } } } return result; }; /** * Create intervals for an stacked bar chart. The data is formed into stacks by the unique values of the independent data. The independent interval is the independent value (for both ends), and the dependent interval is from the stacking with the extent equal to the dependent value. The callout independent is the independent value, and the callout dependent is the dependent value (the bar extent). If percent is true, the bars are rescaled so the total height of each stack is 1.0. If xScale is non-null and returns null for an x value, that bar is skipped. * @param (Array) data Data array * @param (rave['internal']['SingleValueFunction']) x Independent accessor, should not be null * @param (rave['internal']['SingleValueFunction']) xScale Possibly-null function to check if X values are in domain * @param (rave['internal']['SingleValueFunction']) y Dependent accessor, should not be null * @param (rave['internal']['SingleValueFunction']) color Color accessor, may be null * @param (rave['internal']['SingleValueFunction']) label Label accessor, may be null * @param (boolean) percent If true, create percent bars * @return (Array) Array of intervals for the data */ /** @expose */ com_ibm_rave_bundles_components_IntervalDataUtilities.stackedBars = function(data, x, xScale, y, color, label, percent) { var result = []; if (!data || data.length == 0 || !x || !y) { return result; } var stacks = {}; var categories = {}; var colors = {}; data.forEach(function(d, ix, list) { var xv = x(d); if (xv != null && (!xScale || xScale(xv) != null)) { var yv = y(d); if (yv != null) { var stack = stacks[xv]; if (!stack) { stack = new com_ibm_rave_bundles_components_IntervalDataUtilities.Stack(); stacks[xv] = stack; } var dVal = + (yv); if (!percent) { var r = new com_ibm_rave_bundles_components_IntervalDataUtilities.IntervalData(); r.key = ix; r.ind1 = xv; r.ind2 = xv; r.cind = xv; var sum = dVal < 0.0 ? stack.negativeSum : stack.positiveSum; r.dep1 = sum; r.dep2 = sum + dVal; r.cdep = r.dep2; r.color = color ? color(d) : null; r.label = label ? label(d) : null; r.value = dVal; r._originalData = d; result.push(r); } if (dVal < 0.0) { stack.negativeSum += dVal; } else { stack.positiveCount++; stack.positiveSum += dVal; } if (!(categories.hasOwnProperty(xv))) { categories[""+(xv)] = 1; } if (color) { var o = color(d); if ((o != null) && !(colors.hasOwnProperty(o))) { colors[""+(o)] = 1; } } } } return null; }); if (percent) { data.forEach(function(d, ix, list) { var xv = x(d); if (xv != null && (!xScale || xScale(xv) != null)) { var yv = y(d); if (yv != null) { var stack = stacks[xv]; var dVal = + (yv); var percent; if (dVal < 0.0) { percent = -100.0 * dVal / stack.negativeSum; } else if (stack.positiveSum > 0) { percent = 100.0 * dVal / stack.positiveSum; } else { percent = 100.0 / stack.positiveCount; } var r = new com_ibm_rave_bundles_components_IntervalDataUtilities.IntervalData(); r.key = ix; r.ind1 = xv; r.ind2 = xv; r.cind = xv; var sum = dVal < 0.0 ? stack.negativePercent : stack.positivePercent; r.dep1 = sum; r.dep2 = sum + percent; r.cdep = r.dep2; r.color = color ? color(d) : null; r.label = label ? label(d) : null; r.value = dVal; r.valueAsPercentOfCategory = percent; r._originalData = d; result.push(r); if (dVal < 0.0) { stack.negativePercent += percent; } else { stack.positivePercent += percent; } } } return null; }); } else { for (var __i_enFor0 = 0, __exp_enFor0 = Object.keys(categories), __len_enFor0 = __exp_enFor0.length; __i_enFor0 < __len_enFor0; ++__i_enFor0) { var o = __exp_enFor0[__i_enFor0]; var s = ""+(o); var sum = 0; for (var i = 0; i < result.length; ++i) { var iData = result[i]; if (s == iData.ind1) { var value = + (iData.value); sum += Math.abs(value); } } if (sum == 0) { continue; } for (var i = 0; i < result.length; ++i) { var iData = result[i]; if (s == iData.ind1) { var value = + (iData.value); iData.valueAsPercentOfCategory = value / sum * 100; } } } } for (var __i_enFor1 = 0, __exp_enFor1 = Object.keys(colors), __len_enFor1 = __exp_enFor1.length; __i_enFor1 < __len_enFor1; ++__i_enFor1) { var o = __exp_enFor1[__i_enFor1]; var s = ""+(o); var sum = 0; for (var i = 0; i < result.length; ++i) { var iData = result[i]; if (s == iData.color) { var value = + (iData.value); sum += Math.abs(value); } } if (sum == 0) { continue; } for (var i = 0; i < result.length; ++i) { var iData = result[i]; if (s == iData.color) { var value = + (iData.value); iData.valueAsPercentOfColor = value / sum * 100; } } } return result; }; /** * Structure class holding interval information. */ com_ibm_rave_bundles_components_IntervalDataUtilities.IntervalData = rave['internal']['Declare']({ /** * Key value; for now this is the data index */ /** @expose */ key : null, /** * First independent value */ /** @expose */ ind1 : null, /** * Second independent value (in all current uses, same as ind1) */ /** @expose */ ind2 : null, /** * First dependent value */ /** @expose */ dep1 : null, /** * Second dependent value */ /** @expose */ dep2 : null, /** * The data value that the interval represents. Not the pixel value. Used in stacked chart */ /** @expose */ value : null, /** * Color value */ /** @expose */ color : null, /** * Label value */ /** @expose */ label : null, /** * Callout independent value (in all current uses, same as ind1) */ /** @expose */ cind : null, /** * Callout dependent value (dependent extent) */ /** @expose */ cdep : null, /** @expose */ _originalData : null, /** * The data value (in percentage) for specific category */ /** @expose */ valueAsPercentOfCategory : NaN, /** * The data value (in percentage) across all categories */ /** @expose */ valueAsPercentOfColor : NaN, /** @expose */ originalData : function() { return this._originalData; }, /** @expose */ originalDataList : function() { var list = []; list.push(this._originalData); return list; } }); com_ibm_rave_bundles_components_IntervalDataUtilities.Stack = function() { this.positiveCount = 0; this.positiveSum = 0; this.negativeSum = 0; this.positivePercent = 0; this.negativePercent = 0; }; /** * Accessor for the callout dependent value */ /** @expose */ com_ibm_rave_bundles_components_IntervalDataUtilities.CALLOUT_DEPENDENT_ACCESSOR = function(data) { return (data).cdep; }; /** * Accessor for the callout independent value */ /** @expose */ com_ibm_rave_bundles_components_IntervalDataUtilities.CALLOUT_INDEPENDENT_ACCESSOR = function(data) { return (data).cind; }; /** * Accessor for the data value */ /** @expose */ com_ibm_rave_bundles_components_IntervalDataUtilities.VALUE_ACCESSOR = function(data) { return (data).value; }; /** * Accessor for data value as percent of category */ /** @expose */ com_ibm_rave_bundles_components_IntervalDataUtilities.PERCENT_OF_CATEGORY_ACCESSOR = function(data) { var percent = (data).valueAsPercentOfCategory; return isNaN(percent) ? "" : percent.toFixed(1) + "%"; }; /** * Accessor for data value as percent of color (series) */ /** @expose */ com_ibm_rave_bundles_components_IntervalDataUtilities.PERCENT_OF_COLOR_ACCESSOR = function(data) { var percent = (data).valueAsPercentOfColor; return isNaN(percent) ? "" : percent.toFixed(1) + "%"; }; // $source: com/ibm/rave/bundles/data/PointDataUtilities /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ // GENERATED /** * Utility class for building arrays of point datum objects from tabular data. */ var com_ibm_rave_bundles_data_PointDataUtilities = rave['internal']['Declare']({ }); /** *Filter the input data list-array and return a list-array of PointData objects in the same order. If the data is null, an empty list is returned. Any null object in the data is skipped.
If an accessor is null, the X or Y value in the returned PointData objects is always null. If the accessor is non-null, points for which the accessor returns null are not included in the result; if the scale is also non-null, points for which the scale applied to the value returns null are not included in the result.
The returned PointDatum objects have the X accessor and Y accessor values (so may be null), and the original datum set to the object from the data.
* @param (Array) data Input data, list of arbitrary objects * @param (rave['internal']['SingleValueFunction']) xAccessor X accessor function, may be null * @param (rave['internal']['SingleValueFunction']) xScale Scale to test if the X value should be included, may be null * @param (rave['internal']['SingleValueFunction']) yAccessor Y accessor function, may be null * @param (rave['internal']['SingleValueFunction']) yScale Scale to test if the Y value should be included, may be null * @return (Array) List of PointData objects */ /** @expose */ com_ibm_rave_bundles_data_PointDataUtilities.buildPoints = function(data, xAccessor, xScale, yAccessor, yScale) { var result = []; if (data) { for (var __i_enFor0 = 0, __exp_enFor0 = data, __len_enFor0 = __exp_enFor0.length; __i_enFor0 < __len_enFor0; ++__i_enFor0) { var o = __exp_enFor0[__i_enFor0]; if (o != null) { var xv = null; if (xAccessor) { xv = xAccessor(o); if (xv == null || (xScale && xScale(xv) == null)) { continue; } } var yv = null; if (yAccessor) { yv = yAccessor(o); if (yv == null || (yScale && yScale(yv) == null)) { continue; } } var datum = new com_ibm_rave_bundles_data_PointDataUtilities.PointDatum(); datum._x = xv; datum._y = yv; datum._originalData = o; result.push(datum); } } } return result; }; /** * Datum object representing a point with X and Y values. Either X or Y may be null, depending on how the point is used, for example in a scatterplot. */ com_ibm_rave_bundles_data_PointDataUtilities.PointDatum = rave['internal']['Declare']({ /** * The X value */ /** @expose */ _x : null, /** * The Y value */ /** @expose */ _y : null, /** * The data value (in percentage) that the point represents */ /** @expose */ _yAsPercentOfCategory : null, /** * The data value (in percentage) that the point represents */ /** @expose */ _yAsPercentOfColor : null, /** * The original data */ /** @expose */ _originalData : null, /** @expose */ originalData : function() { return this._originalData; }, /** @expose */ originalDataList : function() { var list = []; list.push(this._originalData); return list; } }); /** * Accessor returning the _x property of a PointDatum. */ /** @expose */ com_ibm_rave_bundles_data_PointDataUtilities.X_ACCESSOR = function(d) { return (d)._x; }; /** * Accessor returning the _y property of a PointDatum. */ /** @expose */ com_ibm_rave_bundles_data_PointDataUtilities.Y_ACCESSOR = function(d) { return (d)._y; }; /** * Accessor returning the _yAsPercentOfCategory property of a PointDatum. */ /** @expose */ com_ibm_rave_bundles_data_PointDataUtilities.PERCENT_OF_CATEGORY_ACCESSOR = function(d) { var percent = + ((d)._yAsPercentOfCategory); return isNaN(percent) ? "" : percent.toFixed(1) + "%"; }; /** * Accessor returning the _yAsPercentOfColor property of a PointDatum. */ /** @expose */ com_ibm_rave_bundles_data_PointDataUtilities.PERCENT_OF_COLOR_ACCESSOR = function(d) { var percent = + ((d)._yAsPercentOfColor); return isNaN(percent) ? "" : percent.toFixed(1) + "%"; }; // $source: com/ibm/rave/bundles/utilities/ColorUtil /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ // GENERATED var com_ibm_rave_bundles_utilities_ColorUtil = rave['internal']['Declare']({ }); /** * It is used to get a foreground color which has atleast a 4.5 contrast ratio with the background color. * @param (Object) bg bakground color * @param (Object) fg foreground color * @return (Object) a color ( darker/ligher/same fg color ) which contrast with background. */ com_ibm_rave_bundles_utilities_ColorUtil.getContrastColor$0 = function(bg, fg) { var contrastRatio = com_ibm_rave_bundles_utilities_ColorUtil.getContrastRatio(bg, fg); if (contrastRatio < 4.5) { var bgHSL = rave.hsl(bg); var fgHSL = rave.hsl(fg); var brightness = 0.33 * (rave.rgb(bg).getR() / 255.0) + 0.5 * (rave.rgb(bg).getG() / 255.0) + 0.16 * (rave.rgb(bg).getB() / 255.0); if (brightness > 0.5) { if (bgHSL.getL() > 0.5) { return rave.hsl(fgHSL.getH(), fgHSL.getS(), Math.min(fgHSL.getL(), bgHSL.getL() - 0.4)); } else { return rave.hsl(fgHSL.getH(), fgHSL.getS(), Math.min(fgHSL.getL(), 0.1)); } } else { if (bgHSL.getL() < 0.5) { return rave.hsl(fgHSL.getH(), fgHSL.getS(), Math.max(fgHSL.getL(), bgHSL.getL() + 0.4)); } else { return rave.hsl(fgHSL.getH(), fgHSL.getS(), Math.max(fgHSL.getL(), 0.9)); } } } return fg; }; com_ibm_rave_bundles_utilities_ColorUtil.getContrastColor$1 = function(labelColor) { var labelRGB = rave.rgb(labelColor); return labelRGB.contrastShift(21); }; /** @expose */ com_ibm_rave_bundles_utilities_ColorUtil.getContrastRatio = function(colorA, colorB) { var foregroundLuminance = rave.rgb(colorA).getLuminance(); var backgroundLuminance = rave.rgb(colorB).getLuminance(); var contrastRatio = (foregroundLuminance >= backgroundLuminance) ? (foregroundLuminance + 0.05) / (backgroundLuminance + 0.05) : (backgroundLuminance + 0.05) / (foregroundLuminance + 0.05); return contrastRatio; }; /** @expose */ com_ibm_rave_bundles_utilities_ColorUtil.getContrastColor = function(a0, a1) { var args = arguments; if (args.length == 1) { return com_ibm_rave_bundles_utilities_ColorUtil.getContrastColor$1(a0); } return com_ibm_rave_bundles_utilities_ColorUtil.getContrastColor$0(a0, a1); }; // $source: com/ibm/rave/bundles/nativeImpl/components/TiledmapV2DataLayerImpl /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ var com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl = (function() { //Constructor function com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl( _type ) { this._type = _type; this.data = null; this.mapData = null; this.combined = false; this.featureAccessors = null; this.typeData = rave.map(); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl.prototype.getType = function() { return this._type; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl.prototype.setData = function( _data ) { this.data = _data; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl.prototype.setMapData = function( _mapData ) { this.mapData = _mapData; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl.prototype.setCombined = function( _combined ) { this.combined = _combined; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl.prototype.setFeatureAccessors = function( _accessors ) { this.featureAccessors = _accessors; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl.prototype.setTypeData = function( _type, _data ) { this.typeData.set( _type, _data ); } return com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl; }()); // $source: com/ibm/rave/bundles/nativeImpl/components/TiledmapV2FeatureDataMap /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2018, 2019 ** ** 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. ************************************************************************/ var com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap = ( function() { // setup guid function var guid = ( function() { // Buffer to hold the random numbers var buf = typeof Uint8Array === "undefined" ? new Array( 16 ) : new Uint8Array( 16 ); // Look up table to translate values to hex string (faster than toString( 16 )) var lut = new Array( 256 ); for ( var i = 0; i < 256; ++i ) lut[i] = ( i < 16 ? "0" : "" ) + i.toString( 16 ); // setup random values function var getRandomValues = ( function( crypto ) { if ( crypto ) { return function( _target ) { return crypto.getRandomValues( _target ); }; } else { /** * Randomize the array with 8bit unsigned values (using Math.random()). * @param _target {Array} The array to randomize. * @returns _target {Array} the modified _target array. */ return function( _target ) { for ( var r, i = 0, l = _target.length; i < l; i+=4 ) { r = ( Math.random() * 0xffffffff ) | 0; switch ( l - i ) { default: _target[i+3] = ( r >>> 24 ) & 0xff; /*falls through*/ case 3: _target[i+2] = ( r >>> 16 ) & 0xff; /*falls through*/ case 2: _target[i+1] = ( r >>> 8 ) & 0xff; /*falls through*/ case 1: _target[i] = r & 0xff; } } return _target; }; } }( typeof crypto !== "undefined" ? crypto : ( typeof msCrypto !== "undefined" ? msCrypto : null ) ) ); // guid generation function return function() { // Grab new random values getRandomValues( buf ); // Instead of writing a loop the whole concatenation is written out. The number of values is // fixed, and this is significantly faster than looping over the array. return lut[buf[ 0]] + lut[buf[ 1]] + lut[buf[ 2]] + lut[buf[ 3]] + lut[buf[ 4]] + lut[buf[ 5]] + lut[buf[ 6]|0x40] + lut[buf[ 7]] + lut[buf[ 8]|0x80] + lut[buf[ 9]] + lut[buf[10]] + lut[buf[11]] + lut[buf[12]] + lut[buf[13]] + lut[buf[14]] + lut[buf[15]]; }; }() ); // sort point size stops by descending size (the second parameter in the stop array) function _sortByPointSizeDesc( _itemA, _itemB ) { var sizeA = _itemA.properties.pointSize ? _itemA.properties.pointSize : null; var sizeB = _itemB.properties.pointSize ? _itemB.properties.pointSize : null; // handle nulls if ( ( sizeA === null ) && ( sizeB === null ) ) return 0; if ( sizeA === null ) return 1; if ( sizeB === null ) return -1; return sizeB - sizeA; } function com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap() { this._itemMapById = rave.map(); this._itemMapByKey = rave.map(); this._itemMap = rave.map(); this._featuresByTileSet = rave.map(); this._featureById = rave.map(); this._fidIdx = 0; this._tileSets = rave.map(); this._combinedLayers = false; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._itemMapById = null; com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._itemMapByKey = null; com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._itemMap = null; com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._fidIdx = null; com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._tileSets = null; com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._featuresByTileSet = null; com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._featureById = null; com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._combinedLayers = null; com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.setCombinedLayers = function( _combinedLayers ) { this._combinedLayers = _combinedLayers; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.add = function( _dataLayer, _data, _key, _feature ) { var item = { id: guid(), data: {}, dataSet: {}, layerIds: {}, tileSets: {}, key: _key, hasValueAccessor: false, hasPointColorAccessor: false, hasPointSizeAccessor: false }; var feature; if ( _feature ) { // set feature feature = _feature; // From version 170513 the type of the pk key changed from number to string. // To be able to support multiple atlas services, we need to support multiple // key types as well. if ( feature.pk ) { var pkNumber = false; var version = +( feature.mapid.substr( feature.mapid.length - 6,6 ) ); // check map version, from this version the pk type changed to string if ( version >= 170513 ) item.pk = feature.pk; else item.pk = +feature.pk; } if ( feature.location ) item.fid = "f" + this._nextFid(); if ( feature.bbox ) item.bbox = feature.bbox; // this is a normal feature if ( feature.mapid ) feature.mapid = "ibmrave." + feature.mapid; } else if ( !this._combinedLayers && this._hasCustomPolygonData( _dataLayer ) ) { feature = this._getCustomPolygonFeature( _dataLayer ); var featureId = this._getFeatureId( _dataLayer, _data ); item[ feature.property ] = featureId; } else { item.fid = "f" + this._nextFid(); // build an adhoc feature from the geoData feature = this._buildFeatureFromGeoData( _dataLayer, _data ); if ( !feature ) return; } // setup datalayer and data this._setupData( item, _dataLayer, feature, _data ); // setup lookups this._itemMapById.set( item.id, item ); if ( item.key ) this._itemMapByKey.set( item.key, item ); if ( item.fid ) this._createGeoJSON( _dataLayer, item ); if ( item.bbox ) this._addGeoJSONBBox( _dataLayer, item ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.update = function( _dataLayer, _data, _key, _feature ) { var item = this._itemMapByKey.get( _key ); if ( !item ) return; // setup datalayer and data this._setupData( item, _dataLayer, _feature, _data ); if ( item.fid ) this._createGeoJSON( _dataLayer, item ); if ( item.bbox ) this._addGeoJSONBBox( _dataLayer, item ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.hasFeature = function( _featureKey ) { return this._itemMapByKey.has( _featureKey ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.getById = function( _id ) { return this._itemMapById.get( _id ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.getByKey = function( _key ) { return this._itemMapByKey.get( _key ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.getItem = function( _tileSetId, _layerId, _properties ) { var tileSets = this.getTileSets( { id: _tileSetId } ); var tileSet = null; var key = null; if ( !tileSets.length ) return null; // find the tileSet with the correct layer tileSets.some( function( _tileSet ) { // verify the tileSet layer if ( _tileSet[ _tileSet.layer ] === _layerId ) { tileSet = _tileSet; return true; } return false; } ); if ( !tileSet ) return null; // If we're using a combined layers, the tileset property will be the same for all tilesets. // Otherwise, the key should be separate per tileset. if ( this._combinedLayers ) key = tileSet.property + "-" + _properties[ tileSet.property ]; else key = tileSet.id + "-" + tileSet[ tileSet.layer ] + "-" + tileSet.property + "-" + _properties[ tileSet.property ]; return this._itemMap.get( key ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.getMapFilter = function( _tileSet ) { var expression = [ "in", _tileSet.property ]; var keysForTileSet = this._itemMapById.values().filter( function( _item ) { return _item.tileSets[ _tileSet.type ] && _item.tileSets[ _tileSet.type ].id === _tileSet.id; } ).forEach( function( _item ) { // loop the pk's and add them to the expression expression.push( _item[_tileSet.property] ); } ); return expression; }, com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.getFeatures = function( _tileSetId ) { var featuresInfo = this._featuresByTileSet.get( _tileSetId ); if ( featuresInfo ) { // Check if the features need to be sorted. // We want to sort the features by size, so that small points show before bigger ones. // The order of the features depends on the way they're added to the GeoJSON if ( !featuresInfo.sorted ) { featuresInfo.features.sort( _sortByPointSizeDesc ); featuresInfo.sorted = true; } return featuresInfo.features; } return []; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.getTileSets = function( _filter ) { var tileSets = []; var keys = _filter ? Object.keys( _filter ) : null; this._tileSets.forEach( function( _tileSetKey, _tileSet ) { if ( !keys || keys.every( function( _key ) { return _filter[_key] === _tileSet[_key] } ) ) tileSets.push( _tileSet ); } ); return tileSets; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.size = function() { return this._itemMapById.size(); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.clear = function() { this._itemMapById = rave.map(); this._itemMapByKey = rave.map(); this._itemMap = rave.map(); this._fidIdx = 0; this._tileSets = rave.map(); this._featuresByTileSet = rave.map(); this._featureById = rave.map(); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.updateDataLayerProperties = function( _dataLayer ) { var self = this; this._itemMapById.forEach( function( _id, _item ) { var dataSetId = _dataLayer.getType(); _dataLayer.typeData.forEach( function( _type, _typeData ) { var tileSet = _item.tileSets[ _type ]; // check for vector tileSet or geoJson tileSet with same ID if ( tileSet && ( ( tileSet.tileType === "vector" ) || ( tileSet.id === self._getAdhocTileId( _type, dataSetId ) ) ) ) self._updateTypeDataProperties( _type, _typeData, _item ); } ); } ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype.filter = function( _filter, _sortBy ) { // TODO: make this more generic if ( _sortBy ) { // use a rave map for sorting, when requesting the values() they are sorted by key var sorted = rave.map(); this._itemMapById.values().forEach( function( _item ) { if ( _item.tileSets[ _filter.type ] && ( _item.tileSets[ _filter.type ].id === _filter.tileSet ) && _item.layerIds[ _filter.type ] && ( _item.layerIds[ _filter.type ] === _filter.layer ) ) sorted.set( _item[ _sortBy ], _item ); } ); return sorted.values(); } else { return this._itemMapById.values().filter( function( _item ) { return _item.tileSets[ _filter.type ] && ( _item.tileSets[ _filter.type ].id === _filter.tileSet ) && _item[ _filter.property ]; } ); } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._addItem = function( _tileSet, _item ) { var key; // If we're using a combined layers, the tileset property will be the same for all tilesets. // Otherwise, the key should be separate per tileset. if ( this._combinedLayers ) key = _tileSet.property + "-" + _item[ _tileSet.property ]; else key = _tileSet.id + "-" + _tileSet[ _tileSet.layer ] + "-" + _tileSet.property + "-" + _item[ _tileSet.property ]; this._itemMap.set( key, _item ); }, com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._hasCustomPolygonData = function( _dataLayer ) { var hasCustomPolygonData = false; // since custom polygon data is not available for combined layers we can safely loop the dataLayers (which will be just 1) _dataLayer.typeData.forEach( function( _type, _typeData ) { hasCustomPolygonData = hasCustomPolygonData || _typeData.hasOwnProperty( "customPolygon" ) && ( _typeData.customPolygon !== null ) && ( typeof _typeData.customPolygon !== "undefined" ); } ); return hasCustomPolygonData; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._getCustomPolygonFeature = function( _dataLayer ) { var feature = { mapid: null, polyLayer: null, pointLayer: null, property: null, customPolygon: true }; // since custom polygon data is not available for combined layers we can safely loop the dataLayers (which will be just 1) _dataLayer.typeData.forEach( function( _type, _typeData ) { feature.mapid = _typeData.customPolygon.mapId; if ( _type === "region" ) feature.polyLayer = _typeData.customPolygon.layerName; else feature.pointLayer = _typeData.customPolygon.layerName; feature.property = _typeData.customPolygon.propertyName; } ); return feature; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._getFeatureId = function( _dataLayer, _data ) { var featureAccessor = _dataLayer.featureAccessors[ 0 ]; if ( featureAccessor ) { var geoData = featureAccessor( _data ); if ( ( typeof geoData === "object" ) && ( geoData.featureId !== null ) ) return geoData.featureId; } return null; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._setupData = function( _item, _dataLayer, _feature, _data ) { var dataSetId = _dataLayer.getType(); var self = this; var nullColor = null; _dataLayer.typeData.forEach( function( _type, _typeData ) { if ( _type === "region" ) { self._setupRegionData( _item, _feature, _data, dataSetId, _type, _typeData ); nullColor = _typeData.nullColor; } else { self._setupPointData( _item, _feature, _data, dataSetId, _type, _typeData ); } } ); // special case for combined layer // add a null value is there are no accessors if ( this._combinedLayers && !_item.hasValueAccessor && !_item.hasPointColorAccessor && !_item.hasPointSizeAccessor ) _item.fillColor = nullColor; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._setupRegionData = function( _item, _feature, _data, _dataSetId, _type, _typeData ) { if ( ( _feature.mapid && _feature.polyLayer ) || ( _feature.location ) ) { var tileSet; // add tileset info, favor the mapid/polylayer over the location if ( _feature.mapid && _feature.polyLayer ) { tileSet = { type: _type, id: _feature.mapid, tileType: "vector", layer: "polyLayer", polyLayer: _type + "-" + _feature.polyLayer, sourceLayer: _feature.polyLayer, opacityProp: "fill-opacity", transparency: _typeData.transparency }; tileSet.property = ( _feature.property ) ? _feature.property : "pk"; } else { tileSet = { type: _type, id: this._getAdhocTileId( _type, _dataSetId ), tileType: "geojson", layer: "polyLayer", polyLayer: this._getAdhocLayerId( _dataSetId, "geopoly" ), opacityProp: "circle-opacity", property: "fid", transparency: _typeData.transparency }; // remember point location if ( _feature.location ) _item[ _type ] = _feature.location; } tileSet.customPolygon = _feature.customPolygon || false; tileSet.propertyType = tileSet.customPolygon ? null : typeof _item[ tileSet.property ]; _item.tileSets[ _type ] = tileSet; this._addTileSet( tileSet ); layerId = tileSet.polyLayer; // set layerId _item.layerIds[ _type ] = layerId; // set data _item.data[ layerId ] = _data; _item.dataSet[ layerId ] = _dataSetId; // type data if ( _typeData.valueAccessor ) { _item.value = _typeData.valueAccessor( _data ); _item.hasValueAccessor = true; } else if ( !this._combinedLayers ) { _item.value = null; } // add item this._addItem( tileSet, _item ); // update type data properties this._updateTypeDataProperties( _type, _typeData, _item ); } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._setupPointData = function( _item, _feature, _data, _dataSetId, _type, _typeData ) { var tileSet; // add tileset info if ( _feature.location ) { tileSet = { type: _type, id: this._getAdhocTileId( _type, _dataSetId ), tileType: "geojson", layer: "pointLayer", pointLayer: this._getAdhocLayerId( _dataSetId, "geopoint" ), property: "fid", transparency: _typeData.transparency }; } else { tileSet = { type: _type, id: _feature.mapid, tileType: "vector", layer: "pointLayer", pointLayer: _type + "-" + _feature.pointLayer, sourceLayer: _feature.pointLayer, transparency: _typeData.transparency }; tileSet.property = ( _feature.property ) ? _feature.property : "pk"; } tileSet.customPolygon = _feature.customPolygon || false; tileSet.propertyType = tileSet.customPolygon ? null : typeof _item[ tileSet.property ]; _item.tileSets[ _type ] = tileSet; this._addTileSet( tileSet ); layerId = tileSet.pointLayer; // set layerId _item.layerIds[ _type ] = layerId; // set data _item.data[ layerId ] = _data; _item.dataSet[ layerId ] = _dataSetId; // remember point location if ( _feature.location ) _item[ _type ] = _feature.location; if ( _typeData.pointColorAccessor || _typeData.pointSizeAccessor ) { if ( _typeData.pointColorAccessor ) { _item.pointColorValue = _typeData.pointColorAccessor( _data ); _item.hasPointColorAccessor = true; } else { _item.pointColorValue = null; } if ( _typeData.pointSizeAccessor ) { _item.pointSizeValue = _typeData.pointSizeAccessor( _data ) _item.hasPointSizeAccessor = true; } else { _item.pointSizeValue = null; } } // draw defaultSized points when there are no accessors mapped else if ( !this._combinedLayers ) { _item.pointColor = _typeData.nullColor; _item.pointSize = _typeData.defaultPointSize; } // add item this._addItem( tileSet, _item ); // update type data properties this._updateTypeDataProperties( _type, _typeData, _item ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._getAdhocTileId = function( _type, _dataLayerId ) { return _type + "." + _dataLayerId + ".adhocGeo"; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._getAdhocLayerId = function( _dataLayerId, _layer ) { return _dataLayerId + "." + _layer; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._createGeoJSON = function( _dataLayer, _item ) { // build GeoJSON objects for each type of data var keys = _dataLayer.typeData.keys(); for ( var idx = 0, size = keys.length; idx < size; ++idx ) { var type = keys[ idx ]; // check if there's location data if ( _item[ type ] ) this._addGeoJSONPoint( this._getAdhocTileId( type, _dataLayer.getType() ), _item, type ); } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._addGeoJSONPoint = function( _tileSetId, _item, _coordinatesField ) { // get features info for tileSet var featuresInfo = this._featuresByTileSet.get( _tileSetId ); if ( !featuresInfo ) { featuresInfo = { features: [], sorted: false }; this._featuresByTileSet.set( _tileSetId, featuresInfo ); } // reset sorted, since adding features requires re-sort featuresInfo.sorted = false; // build GeoJSON feature var feature = this._featureById.get( _item.fid ); if ( !feature ) { feature = { type: "Feature", geometry: { type: "Point", coordinates: _item[ _coordinatesField ] }, properties: { fid: _item.fid } }; this._featureById.set( _item.fid, feature ) } if ( _item.pointSize ) feature.properties.pointSize = _item.pointSize; // add feature featuresInfo.features.push( feature ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._addGeoJSONBBox = function( _dataLayer, _item ) { // bbox will only be available on regions var tileSet = _item.tileSets[ "region" ]; if ( _dataLayer.typeData.has( "region" ) && tileSet ) { var tileSetId = tileSet.id; var featuresInfo = this._featuresByTileSet.get( tileSetId ); if ( !featuresInfo ) { featuresInfo = { features: [], sorted: true }; this._featuresByTileSet.set( tileSetId, featuresInfo ); } // build GeoJSON feature var rect = _item.bbox; var feature = { type: "Feature", geometry: { type: "Polygon", coordinates: [ [ [ rect[ 0 ], rect[ 1 ] ], [ rect[ 2 ], rect[ 1 ] ], [ rect[ 2 ], rect[ 3 ] ], [ rect[ 0 ], rect[ 3 ] ], [ rect[ 0 ], rect[ 1 ] ] ] ] } }; // add feature featuresInfo.features.push( feature ); } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._nextFid = function() { return ++this._fidIdx; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._addTileSet = function( _tileSet ) { var key = this._buildKey( _tileSet ); if ( !this._tileSets.has( key ) ) this._tileSets.set( key, _tileSet ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._buildKey = function( _tileSet ) { return Object.keys( _tileSet ).map( function( _key ) { return _tileSet[ _key ]; } ).join( "|" ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._updateTypeDataProperties = function( _type, _typeData, _item ) { switch( _type ) { case "region": // set value and color if ( _item.hasOwnProperty( "value" ) ) { var color = _typeData.nullColor; if ( _item.value !== null ) color = _typeData.palette( _item.value ); _item.fillColor = color ? color : _typeData.nullColor; } break; case "point": // set point color if ( _item.hasOwnProperty( "pointColorValue" ) ) { if ( _item.pointColorValue !== null ) { var color = _typeData.palette( _item.pointColorValue ); _item.pointColor = color ? color : _typeData.nullColor; } else { _item.pointColor = _typeData.nullColor; } } // set point size if ( _item.hasOwnProperty( "pointSizeValue" ) ) { var pointSize = _item.pointSizeValue; if ( pointSize != null ) { if ( ( pointSize === 0 ) && ( _typeData.staticZeroValuePointSize !== null ) ) { _item.pointSize = _typeData.staticZeroValuePointSize; _item.hasStaticZeroValuePointSize = true; } else { _item.pointSize = _typeData.pointSizeScale( pointSize ); } } else { _item.pointSize = _typeData.defaultPointSize; } } break; } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap.prototype._buildFeatureFromGeoData = function( _dataLayer, _data ) { var feature = null; var featureAccessor = _dataLayer.featureAccessors[ 0 ]; if ( featureAccessor ) { var geoData = featureAccessor( _data ); if ( typeof geoData === "object" ) { feature = {}; if ( geoData.hasOwnProperty( "latitude" ) && geoData.hasOwnProperty( "longitude" ) ) // mapbox uses a longitude, latitude notation feature.location = [ geoData.longitude, geoData.latitude ]; } } return feature; } return com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap; }()); // $source: com/ibm/rave/bundles/nativeImpl/components/TiledmapV2MapDataCache /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2018 ** ** 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. ************************************************************************/ var com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache = ( function() { function com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache() { this.version = 0; this._itemMap = rave.map(); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache.prototype.version = null; com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache.prototype._itemMap = null; com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache.prototype.refreshCache = function( _dataLayers ) { var cacheUpdated = false; // get current keys var curKeys = rave.set( this._itemMap.keys() ); var touchedKeys = rave.set(); // iterate data layers for ( var layerIdx = 0, layerSize = _dataLayers.length; layerIdx < layerSize; ++layerIdx ) { var layer = _dataLayers[ layerIdx ]; // extract mapData if ( layer.mapData ) { for ( var itemIdx = 0, itemSize = layer.mapData.length; itemIdx < itemSize; ++itemIdx ) { var item = layer.mapData[ itemIdx ]; var key = this._buildKey( layer.getType(), this._extractNames( item ) ); if ( curKeys.has( key ) ) { // compare PKs to check if it's the same item var cacheItem = this._itemMap.set( key, item ); if ( cacheItem.pk === item.pk ) { touchedKeys.add( key ); curKeys.remove( key ); } } else if ( !touchedKeys.has( key ) ) { this._itemMap.set( key, item ); touchedKeys.add( key ); cacheUpdated = true; } } } } // check if there are item which need to be dropped from the cache if ( curKeys.size() > 0 ) { var self = this; curKeys.forEach( function( _key ) { self._itemMap.remove( _key ); } ); cacheUpdated = true; } // update version when data was updated if ( cacheUpdated ) this.version++; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache.prototype.get = function( _key ) { return this._itemMap.get( _key ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache.prototype.size = function() { return this._itemMap.size(); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache.prototype.clear = function() { this._itemMap = rave.map(); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache.prototype.getKey = function( _layerType, _arrKeys ) { return this._buildKey( _layerType, _arrKeys ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache.prototype._buildKey = function( _layerType, _arrKeys ) { return _layerType + "|" + _arrKeys.join( "|" ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache.prototype._extractNames = function( _item/*, _names */ ) { var names = arguments.length > 1 ? arguments[ 1 ] : []; names.push( _item.name ); if ( _item.refine ) { for ( var idx = 0, size = _item.refine.length; idx < size; ++idx ) names.push( _item.refine[ idx ] ); } return names; } return com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache; }()); // $source: com/ibm/rave/bundles/nativeImpl/components/TiledmapV2RegionTypeDataImpl /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017,2018 ** ** 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. ************************************************************************/ var com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl = (function() { //Constructor function com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl() { this.paletteDef = null; this.palette = null; this.nullColor = null; this.transparency = null; this.valueAccessor = null; this.minValue = null; this.maxValue = null; this.hasGeoData = false; this.customPolygon = null; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl.prototype.setPaletteDef = function( _paletteDef ) { this.paletteDef = _paletteDef; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl.prototype.setPalette = function( _palette ) { this.palette = _palette; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl.prototype.setNullColor = function( _nullColor ) { this.nullColor = _nullColor; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl.prototype.setTransparency = function( _transparency ) { this.transparency = _transparency; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl.prototype.setHasGeoData = function( _hasGeoData ) { this.hasGeoData = _hasGeoData; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl.prototype.setValueAccessor = function( _accessor ) { this.valueAccessor = _accessor; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl.prototype.minimumValue = function( _minValue ) { this.minValue = _minValue; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl.prototype.maximumValue = function( _maxValue ) { this.maxValue = _maxValue; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl.prototype.setCustomPolygon = function( _mapId, _layerName, _propertyName ) { if ( _mapId && _layerName && _propertyName ) { this.customPolygon = { mapId: _mapId, layerName: _layerName, propertyName: _propertyName }; } } return com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl; }()); // $source: com/ibm/rave/bundles/nativeImpl/components/TiledmapV2PointTypeDataImpl /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017,2018 ** ** 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. ************************************************************************/ var com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl = (function() { //Constructor function com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl() { this.paletteDef = null; this.palette = null; this.nullColor = null; this.transparency = null; this.pointColorAccessor = null; this.pointSizeAccessor = null; this.pointSizeScale = null; this.defaultPointSize = null; this.staticZeroValuePointSize = null; this.hasGeoData = false; this.customPolygon = null; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl.prototype.setPaletteDef = function( _paletteDef ) { this.paletteDef = _paletteDef; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl.prototype.setPalette = function( _palette ) { this.palette = _palette; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl.prototype.setNullColor = function( _nullColor ) { this.nullColor = _nullColor; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl.prototype.setTransparency = function( _transparency ) { this.transparency = _transparency; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl.prototype.setHasGeoData = function( _hasGeoData ) { this.hasGeoData = _hasGeoData; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl.prototype.setPointColorAccessor = function( _accessor ) { this.pointColorAccessor = _accessor; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl.prototype.setPointSizeAccessor = function( _accessor ) { this.pointSizeAccessor = _accessor; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl.prototype.setPointSizeScale = function( _scale ) { this.pointSizeScale = _scale; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl.prototype.setDefaultPointSize = function( _size ) { this.defaultPointSize = _size; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl.prototype.setStaticZeroValuePointSize = function( _size ) { this.staticZeroValuePointSize = _size; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl.prototype.setCustomPolygon = function( _mapId, _layerName, _propertyName ) { if ( _mapId && _layerName && _propertyName ) { this.customPolygon = { mapId: _mapId, layerName: _layerName, propertyName: _propertyName }; } } return com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl; }()); // $source: com/ibm/rave/bundles/internal/nativeImpl/BundleModule /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2015 ** ** 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. ************************************************************************/ // Must be the first import // @import ./BundleModuleHeader // expose DataFormatter to the global variable rave //rave["library"]["CustomFormatter"]=com_ibm_rave_library_framework_CustomFormatter; // $source: com/ibm/rave/bundles/tiledmapV2Bundle/TiledmapV2Bundle /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2018 ** ** 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. ************************************************************************/ // GENERATED //@import com/ibm/rave/library/Library (static) // Library //@import com/ibm/rave/bundles/RaveBundle (loadtime) // superclass //@import com/ibm/rave/bundles/tiledmapV2Bundle/TiledmapV2View (runtime) // new var com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle = rave['internal']['Declare'](com_ibm_rave_bundles_RaveBundle, { //mapboxSecretToken : null, //mapboxAccoutName : null, mapboxtoken : "", /** @expose */ getName : function() { return com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle.BUNDLE_NAME; }, /** @expose */ createView : function(ctx) { ctx.properties.property("tiledmap.token").value(this.mapboxtoken); return new com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View(ctx); }, /** @expose */ _doConfigure : function(configurations, userCallback, bundle) { if (configurations) { this.mapboxSecretToken = configurations["Mapbox.secretToken"]; this.mapboxAccoutName = configurations["Mapbox.accountName"]; this.mapboxtoken = configurations["Mapbox.token"]; } if ((this.mapboxSecretToken != null) && (this.mapboxAccoutName != null)) { var requestURL = "https://api.mapbox.com/styles/v1/" + this.mapboxAccoutName + "?access_token=" + this.mapboxSecretToken; var self = this; rave.json(requestURL, function(error, response) { if (response) { var properties = bundle.info().properties(); properties.forEach(function(currentValue, index, array) { if (currentValue.simpleId() == "style") { var responseArray = response; for (var __i_enFor0 = 0, __exp_enFor0 = responseArray, __len_enFor0 = __exp_enFor0.length; __i_enFor0 < __len_enFor0; ++__i_enFor0) { var obj = __exp_enFor0[__i_enFor0]; var style = obj; var styleID = ""+(style["id"]); var styleName = ""+(style["name"]); var value = "mapbox://style/" + self.mapboxAccoutName + "/" + styleID; var catalogEntry = {}; var messages = new rave['library']['internal']['MessagesRegistry'](); var catalog = null; var newOption = null; catalogEntry[styleID] = styleName; catalog = rave['library']['internal']['Messages'].createFromCatalog(catalogEntry, bundle.locale()); messages.add(bundle.locale(), catalog); newOption = new rave['library']['internal']['StringPropertyOption'](value, ""+(style["id"]), messages); currentValue.options().push(newOption); if (styleName == "Default") { currentValue.setDefaultValue(value); } } } return currentValue; }); } if (userCallback) { userCallback(); } }); } else if (userCallback) { userCallback(); } } //constructor : function() {} }); /** * Register the bundle factory with the library. The bundle will not be made available if this method is not called. */ /** @expose */ com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle.init = function() { if (!(com_ibm_rave_library_Library.bundle.isRegistered(com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle.BUNDLE_NAME))) { var bundle; com_ibm_rave_library_Library.bundle.extension(com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle.BUNDLE_NAME, function() { if (!bundle) { bundle = new com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle(); bundle.loadResources(); require("./mapbox-gl.css"); require("./vizlibrary-tiledmap.css"); } return bundle; }); } return com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle.BUNDLE_NAME; }; com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle.BUNDLE_NAME = "tiledmapV2Bundle"; // Auto initialization com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle.init(); if (!com_ibm_rave_library_Library.bundle[com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle.BUNDLE_NAME]) { com_ibm_rave_library_Library.bundle[com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle.BUNDLE_NAME] = function() { if (!bundle) { bundle = new com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2Bundle(); bundle.loadResources(); require("./mapbox-gl.css"); require("./vizlibrary-tiledmap.css"); } return bundle; }; } else { console.log("Could not register extension: TiledmapV2Bundle"); } // $source: com/ibm/rave/bundles/tiledmapV2Bundle/TiledmapV2View /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2019 ** ** 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. ************************************************************************/ // GENERATED //@import com/ibm/rave/bundles/views/BundleView (loadtime) // superclass //@import com/ibm/rave/bundles/nativeImpl/components/TiledmapV2DataLayerImpl (runtime) // new //@import com/ibm/rave/bundles/nativeImpl/components/TiledmapV2NativeSubComponentImpl (runtime) // new //@import com/ibm/rave/bundles/nativeImpl/components/TiledmapV2RegionTypeDataImpl (runtime) // new //@import com/ibm/rave/library/Library (runtime) // Library //@import com/ibm/rave/bundles/nativeImpl/components/TiledmapV2PointTypeDataImpl (runtime) // new /** *A map chart view. For this example, additional files are required to be loaded in addition to the usual data schema, data file, properties, etc. We must also load at least one GeoJSON file, and a palette file as well.
The input data properties are the feature name (which could be used to find features in the GeoJSON, if the features there have some kind of id), Standard Color (a numeric referencing a standard palette), Continuous Color (a numeric referencing a continuous palette), and the label that appears on the feature if the features are to be labelled.
Properties required for maps are: GeoJSON: A string for one or more GeoJSON URL's required for this map. scale: A default scale for the map missingFeatureColor: The default color assigned to a feature we do not have a color for. borderColor: Color of the borders between features borderThickness: The border thickness. showLabels: If true, display labels. featureLabelFont: The font of the feature labels. featureLabelColor: The color for the feature labels. featureLabelSize: The size for the feature labels. mapProjection: Map Projection Type-- default is mercator; legendDisplay: boolean, to show or hide the legend. legendPosition: The legend position in the chart.
*/ var com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View = rave['internal']['Declare'](com_ibm_rave_bundles_views_BundleView, { //_mapComponent : null, //_mapInitializedCallback : null, //_maxZoom : null, //_mapLocale : null, //_mapStyle : null, //_registeredEventHandlers : null, //_lastChartRect : null, //_combinedLayerMapping : null, //_regionLayerMapping : null, //_pointLayerMapping : null, //_latlongLayerMapping : null, //_combinedLegendMapping : null, //_pointLegendMapping : null, //_latlongLegendMapping : null, //_delayedInit : null, _mapInitialized : false, /** @expose */ constructor : function(context) { }, /** @expose */ setup : function() { com_ibm_rave_bundles_views_BundleView.prototype.setup.call(this); var self = this; var action = this.context.actions.action("highlight"); action.setOperation(new (rave['internal']['Declare']([rave['library']['internal']['ActionOperation']], { _$functionClassMethod : function() { var _$self = function(args) { if (args !== null || arguments.length > 1){ args = Array.prototype.slice.call(arguments); } { if (self._mapComponent) { self._mapComponent.highlightAction(args[0]); } } }; return _$self; } }))()); action = this.context.actions.action("select"); action.setOperation(new (rave['internal']['Declare']([rave['library']['internal']['ActionOperation']], { _$functionClassMethod : function() { var _$self = function(args) { if (args !== null || arguments.length > 1){ args = Array.prototype.slice.call(arguments); } { if (self._mapComponent) { self._mapComponent.selectAction(args[0]); } } }; return _$self; } }))()); action = this.context.actions.action("deselect"); action.setOperation(new (rave['internal']['Declare']([rave['library']['internal']['ActionOperation']], { _$functionClassMethod : function() { var _$self = function(args) { if (args !== null || arguments.length > 1){ args = Array.prototype.slice.call(arguments); } { if (self._mapComponent) { self._mapComponent.deselectAction(args[0]); } } }; return _$self; } }))()); action = this.context.actions.action("deselectAll"); action.setOperation(new (rave['internal']['Declare']([rave['library']['internal']['ActionOperation']], { _$functionClassMethod : function() { var _$self = function(args) { if (args !== null || arguments.length > 1){ args = Array.prototype.slice.call(arguments); } { if (self._mapComponent) { self._mapComponent.deselectAllAction(); } } }; return _$self; } }))()); action = this.context.actions.action("locate"); action.setOperation(new (rave['internal']['Declare']([rave['library']['internal']['ActionOperation']], { _$functionClassMethod : function() { var _$self = function(args) {}; return _$self; }, get : function(_id) { if (_id == "locator") { return new (rave['internal']['Declare']({ getItemsAtPoint : function(_point) { if (self._mapComponent) { return self._mapComponent.getItemsAtPoint(_point); } return []; }, getItemsInRect : function(_points) { if (self._mapComponent) { return self._mapComponent.getItemsInRect(_points); } return []; } }))(); } return null; } }))()); action = this.context.actions.action("zoom"); action.setOperation(new (rave['internal']['Declare']([rave['library']['internal']['ActionOperation']], { _$functionClassMethod : function() { var _$self = function(args) {}; return _$self; }, get : function(_id) { if (_id == "state") { return new (rave['internal']['Declare']({ getBoundingBox : function() { if (self._mapComponent) { return self._mapComponent.getBoundingBox(); } return null; }, setBoundingBox : function(_bbox) { if (self._mapComponent) { self._mapComponent.setBoundingBox(_bbox); } } }))(); } return null; } }))()); this._combinedLayerMapping = {}; this._combinedLayerMapping["featureLvl1"] = "featureLvl1"; this._combinedLayerMapping["featureLvl2"] = "featureLvl2"; this._combinedLayerMapping["featureLvl3"] = "featureLvl3"; this._combinedLayerMapping["fill"] = "value"; this._combinedLayerMapping["pointSize"] = "pointSize"; this._combinedLayerMapping["pointColor"] = "pointColor"; this._combinedLayerMapping["region.palette"] = "color.palette"; this._combinedLayerMapping["region.alt.palette"] = "region.palette"; this._combinedLayerMapping["region.transparency"] = "color.fillTransparency"; this._combinedLayerMapping["region.mapData"] = "region.mapData"; this._combinedLayerMapping["region.custom.mapId"] = "region.custom.mapId"; this._combinedLayerMapping["region.custom.layerName"] = "region.custom.layerName"; this._combinedLayerMapping["region.custom.propertyName"] = "region.custom.propertyName"; this._combinedLayerMapping["point.palette"] = "color.palette"; this._combinedLayerMapping["point.alt.palette"] = "point.palette"; this._combinedLayerMapping["point.transparency"] = "color.pointTransparency"; this._combinedLayerMapping["point.mapData"] = "point.mapData"; this._combinedLayerMapping["point.minSize"] = "minPointSize"; this._combinedLayerMapping["point.maxSize"] = "maxPointSize"; this._combinedLayerMapping["point.defaultSize"] = "point.defaultSize"; this._combinedLayerMapping["point.staticZeroValueSize"] = "staticZeroValuePointSize"; this._combinedLayerMapping["point.custom.mapId"] = "point.custom.mapId"; this._combinedLayerMapping["point.custom.layerName"] = "point.custom.layerName"; this._combinedLayerMapping["point.custom.propertyName"] = "point.custom.propertyName"; this._combinedLayerMapping["legend.pointsize.title"] = "legend.pointsize.title"; this._combinedLayerMapping["legend.pointcolor.title"] = "legend.pointcolor.title"; this._combinedLegendMapping = {}; this._combinedLegendMapping["pointSize"] = 0; this._combinedLegendMapping["pointColor"] = 1; this._regionLayerMapping = {}; this._regionLayerMapping["featureLvl1"] = "featureLvl1"; this._regionLayerMapping["featureLvl2"] = "featureLvl2"; this._regionLayerMapping["featureLvl3"] = "featureLvl3"; this._regionLayerMapping["fill"] = "fill"; this._regionLayerMapping["region.palette"] = "region.palette"; this._regionLayerMapping["region.alt.palette"] = "region.palette"; this._regionLayerMapping["region.transparency"] = "region.transparency"; this._regionLayerMapping["region.mapData"] = "region.mapData"; this._regionLayerMapping["region.custom.mapId"] = "region.custom.mapId"; this._regionLayerMapping["region.custom.layerName"] = "region.custom.layerName"; this._regionLayerMapping["region.custom.propertyName"] = "region.custom.propertyName"; this._pointLayerMapping = {}; this._pointLayerMapping["featureLvl1"] = "featureLvl1"; this._pointLayerMapping["featureLvl2"] = "featureLvl2"; this._pointLayerMapping["featureLvl3"] = "featureLvl3"; this._pointLayerMapping["pointSize"] = "pointSize"; this._pointLayerMapping["pointColor"] = "pointColor"; this._pointLayerMapping["point.palette"] = "point.palette"; this._pointLayerMapping["point.alt.palette"] = "point.palette"; this._pointLayerMapping["point.transparency"] = "point.transparency"; this._pointLayerMapping["point.mapData"] = "point.mapData"; this._pointLayerMapping["point.minSize"] = "point.minSize"; this._pointLayerMapping["point.maxSize"] = "point.maxSize"; this._pointLayerMapping["point.defaultSize"] = "point.defaultSize"; this._pointLayerMapping["point.staticZeroValueSize"] = "point.staticZeroValueSize"; this._pointLayerMapping["point.custom.mapId"] = "point.custom.mapId"; this._pointLayerMapping["point.custom.layerName"] = "point.custom.layerName"; this._pointLayerMapping["point.custom.propertyName"] = "point.custom.propertyName"; this._pointLayerMapping["legend.pointsize.title"] = "legend.pointsize.title"; this._pointLayerMapping["legend.pointcolor.title"] = "legend.pointcolor.title"; this._pointLayerMapping["sizeLegend"] = "g.legend.size"; this._pointLayerMapping["colorLegend"] = "g.legend.point"; this._pointLegendMapping = {}; this._pointLegendMapping["pointSize"] = 0; this._pointLegendMapping["pointColor"] = 1; this._latlongLayerMapping = {}; this._latlongLayerMapping["pointSize"] = "latlongSize"; this._latlongLayerMapping["pointColor"] = "latlongColor"; this._latlongLayerMapping["point.palette"] = "latlong.palette"; this._latlongLayerMapping["point.alt.palette"] = "latlong.palette"; this._latlongLayerMapping["point.transparency"] = "latlong.transparency"; this._latlongLayerMapping["point.minSize"] = "latlong.minSize"; this._latlongLayerMapping["point.maxSize"] = "latlong.maxSize"; this._latlongLayerMapping["point.defaultSize"] = "latlong.defaultSize"; this._latlongLayerMapping["point.staticZeroValueSize"] = "latlong.staticZeroValueSize"; this._latlongLayerMapping["legend.pointsize.title"] = "legend.latlong.pointsize.title"; this._latlongLayerMapping["legend.pointcolor.title"] = "legend.latlong.pointcolor.title"; this._latlongLayerMapping["sizeLegend"] = "g.legend.latlongSize"; this._latlongLayerMapping["colorLegend"] = "g.legend.latlongPoint"; this._latlongLegendMapping = {}; this._latlongLegendMapping["pointSize"] = 2; this._latlongLegendMapping["pointColor"] = 3; this._registeredEventHandlers = []; this._delayedInit = null; }, /** @expose */ dispose : function() { if (this._mapComponent) { this._mapComponent.dispose(); } }, /** @expose */ on : function(_eventName, _callback) { rave['library']['internal']['AbstractView'].prototype.on.call(this, _eventName, _callback); if (this._mapComponent) { this._mapComponent.on(_eventName, function(_e) { _callback(_e); }); } this._registeredEventHandlers.push(new com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.EventHandler(_eventName, _callback)); }, /** @expose */ draw : function() { var accessToken = this.getStringProperty("tiledmap.token"); if ((accessToken == null) || accessToken == "") { return; } var self = this; this.preDraw("g.vizlibrary-tiledmap"); this.context.node.selectAll("g.legends").style("pointer-events", "all"); if (!(this.validateDataModel("*"))) { return; } var legendPosition = this.getLegendPosition(); var showLegend = this.isShowLegend(); this._legends.visible(showLegend).position(legendPosition).transition(false, 0).setPreExecute(this.context.getPreExecute()); var maxZoom = this.getProperty("tiledmap.maxZoom"); var mapLocale = this.getStringPropertyEmptyAsNull("tiledmap.mapLocale"); if (mapLocale == null) { mapLocale = this.context.locale(); } var mapStyle = this.getStringProperty("tiledmap.style"); var combinedLayers = false; var dataLayers = []; if (this.dataModel.getDescriptor().id() == "tabular") { combinedLayers = true; var combinedDataSet = this.dataModel.dataset("data"); var data = (combinedDataSet.data()); var geoJson = this.getProperty("tiledmap.geoJson"); var mapData = null; if (geoJson != null) { if ((typeof geoJson === "array" || geoJson instanceof Array)) { mapData = geoJson; } else { mapData = (geoJson)["mapboxData"]; } } var dataLayer = new com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl("data"); dataLayers.push(dataLayer); dataLayer.setData(data); dataLayer.setMapData(mapData); var dseFeatureLvl1 = combinedDataSet.slot(this._combinedLayerMapping["featureLvl1"]).entry(); var dseFeatureLvl2 = combinedDataSet.slot(this._combinedLayerMapping["featureLvl2"]).entry(); var dseFeatureLvl3 = combinedDataSet.slot(this._combinedLayerMapping["featureLvl3"]).entry(); var dsePointSize = combinedDataSet.slot(this._combinedLayerMapping["pointSize"]).entry(); var dsePointColor = combinedDataSet.slot(this._combinedLayerMapping["pointColor"]).entry(); var featureAccessors = []; featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseFeatureLvl1)); featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseFeatureLvl2)); featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseFeatureLvl3)); dataLayer.setFeatureAccessors(featureAccessors); if (dseFeatureLvl1) { this._setupRegionDataLayer(dataLayer, combinedDataSet, data, this._combinedLayerMapping, false, showLegend); } else { this._legends.visible(4, false); } if ((dseFeatureLvl1) && ((dsePointSize) || (dsePointColor))) { this._setupPointDataLayer(dataLayer, combinedDataSet, data, this._combinedLayerMapping, this._pointLegendMapping, false, showLegend); } else { this._legends.visible(0, false); this._legends.visible(1, false); } this._legends.visible(2, false); this._legends.visible(3, false); } else if (this.dataModel.getDescriptor().id() == "multiTable") { var regionDataSet = this.dataModel.dataset("data.region"); var pointDataSet = this.dataModel.dataset("data.point"); var latlongDataSet = this.dataModel.dataset("data.latlong"); if (regionDataSet.data() != null) { var data = (regionDataSet.data()); var regionLayer = new com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl("data.region"); dataLayers.push(regionLayer); regionLayer.setData(data); regionLayer.setMapData(this.getProperty(this._regionLayerMapping["region.mapData"])); var dseFeatureLvl1 = regionDataSet.slot(this._regionLayerMapping["featureLvl1"]).entry(); var dseFeatureLvl2 = regionDataSet.slot(this._regionLayerMapping["featureLvl2"]).entry(); var dseFeatureLvl3 = regionDataSet.slot(this._regionLayerMapping["featureLvl3"]).entry(); var hasGeo = ((dseFeatureLvl1) && (this.getStringProperty(this._regionLayerMapping["region.custom.mapId"]).length > 0) && (this.getStringProperty(this._regionLayerMapping["region.custom.layerName"]).length > 0) && (this.getStringProperty(this._regionLayerMapping["region.custom.propertyName"]).length > 0)); var featureAccessors = []; if (hasGeo) { featureAccessors.push(this._createGeoDataAccessor(null, null, null, dseFeatureLvl1)); } else { featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseFeatureLvl1)); featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseFeatureLvl2)); featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseFeatureLvl3)); } regionLayer.setFeatureAccessors(featureAccessors); this._setupRegionDataLayer(regionLayer, regionDataSet, data, this._regionLayerMapping, hasGeo, showLegend); } else { this._legends.visible(4, false); } if (pointDataSet.data() != null) { var data = (pointDataSet.data()); var pointLayer = new com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl("data.point"); dataLayers.push(pointLayer); pointLayer.setData(data); pointLayer.setMapData(this.getProperty(this._pointLayerMapping["point.mapData"])); var dseFeatureLvl1 = pointDataSet.slot(this._pointLayerMapping["featureLvl1"]).entry(); var dseFeatureLvl2 = pointDataSet.slot(this._pointLayerMapping["featureLvl2"]).entry(); var dseFeatureLvl3 = pointDataSet.slot(this._pointLayerMapping["featureLvl3"]).entry(); var hasGeo = ((dseFeatureLvl1) && (this.getStringProperty(this._pointLayerMapping["point.custom.mapId"]).length > 0) && (this.getStringProperty(this._pointLayerMapping["point.custom.layerName"]).length > 0) && (this.getStringProperty(this._pointLayerMapping["point.custom.propertyName"]).length > 0)); var featureAccessors = []; if (hasGeo) { featureAccessors.push(this._createGeoDataAccessor(null, null, null, dseFeatureLvl1)); } else { featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseFeatureLvl1)); featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseFeatureLvl2)); featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseFeatureLvl3)); } pointLayer.setFeatureAccessors(featureAccessors); this._setupPointDataLayer(pointLayer, pointDataSet, data, this._pointLayerMapping, this._pointLegendMapping, hasGeo, showLegend); } else { this._legends.visible(0, false); this._legends.visible(1, false); } if (latlongDataSet.data() != null) { var dseLatitude = latlongDataSet.slot("latitude").entry(); var dseLongitude = latlongDataSet.slot("longitude").entry(); var dseLabel = latlongDataSet.slot("label").entry(); var hasGeo = ((dseLatitude) || (dseLongitude)); if (hasGeo) { var featureAccessors = []; if ((dseLatitude) && (dseLatitude.type() == "object")) { featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseLatitude)); } else if ((dseLongitude) && (dseLongitude.type() == "object")) { featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseLongitude)); } else if ((dseLabel) && (dseLabel.type() == "object")) { featureAccessors.push(rave['library']['internal']['AbstractView'].accessorOf(dseLabel)); } else if ((dseLatitude) && (dseLongitude)) { featureAccessors.push(this._createGeoDataAccessor(dseLabel, dseLatitude, dseLongitude, null)); } if (featureAccessors.length > 0) { var data = (latlongDataSet.data()); var latlongLayer = new com_ibm_rave_bundles_nativeImpl_components_TiledmapV2DataLayerImpl("data.latlong"); dataLayers.push(latlongLayer); latlongLayer.setData(data); latlongLayer.setFeatureAccessors(featureAccessors); this._setupPointDataLayer(latlongLayer, latlongDataSet, data, this._latlongLayerMapping, this._latlongLegendMapping, hasGeo, showLegend); } } } else { this._legends.visible(2, false); this._legends.visible(3, false); } } if (this.updateType <= 1) { this.prepareLayoutComponent(); this.prepareLayoutSizables(this._layoutComponent, false, false, false, false, this._legends.anyVisible()); this._legends.preLayout(this._layoutComponent); this._layoutComponent.layout(); } var chartRect = this._layoutComponent.elementRect(); this._legends.rectangle(this._layoutComponent.legendRect()); this._legends.draw(); var maxPointSize = this.evaluateSize(this.getStringProperty("point.maxSize"), chartRect.width, 10); var autoZoom = this.getBooleanProperty("tiledmap.autoZoom"); if (!this._mapComponent) { this._mapComponent = new com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl(); this._mapComponent.accessToken(accessToken); this._mapComponent.setContainerRect(chartRect); this._mapComponent.setup(this.context.node, this.getNLS()); this._mapComponent.setDataLayers(dataLayers, true, combinedLayers); this._mapComponent.draw(this.context.node); this._mapComponent.mapStyle(mapStyle); this._mapComponent.setMaxBounds(com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.BASE_BOUNDS); if (maxZoom != this._maxZoom) { this._mapComponent.setMaxZoom(maxZoom); } this._mapComponent.setMapLocale(mapLocale); this._mapComponent.setMaxPointSize(maxPointSize); this._mapComponent.setAutoZoom(autoZoom); if (this._registeredEventHandlers.length > 0) { for (var idx = 0, size = this._registeredEventHandlers.length; idx < size; ++idx) { var evt = this._registeredEventHandlers[idx]; this._mapComponent.on(evt.eventName, new com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.EventCallback(evt.callback)); } } this._mapInitializedCallback = function(e) { self._mapInitialized = true; if (self._delayedInit) { if (self._delayedInit.chartRect) { self._mapComponent.setContainerRect(self._delayedInit.chartRect); } self._mapComponent.setDataLayers(self._delayedInit.dataLayers, self._delayedInit.resetData, self._delayedInit.combinedLayers); if (self._delayedInit.maxZoom != null) { self._mapComponent.setMaxZoom(self._delayedInit.maxZoom); } if (self._delayedInit.mapLocale != null) { self._mapComponent.setMapLocale(self._delayedInit.mapLocale); } if (self._delayedInit.mapStyle != null) { self._mapComponent.mapStyle(self._delayedInit.mapStyle); } if (self._delayedInit.maxPointSize != null) { self._mapComponent.setMaxPointSize(self._delayedInit.maxPointSize); } self._mapComponent.setAutoZoom(self._delayedInit.autoZoom); } self._mapComponent.off("style.load", self._mapInitializedCallback); }; this._mapComponent.on("style.load", this._mapInitializedCallback); } else if (this._mapInitialized) { var resetData = (this.updateType == 0); if (!(this._isRectEqual(this._lastChartRect, chartRect))) { this._mapComponent.setContainerRect(chartRect); } this._mapComponent.setDataLayers(dataLayers, resetData, combinedLayers); if (this.updateType <= 1) { if (maxZoom != this._maxZoom) { this._mapComponent.setMaxZoom(maxZoom); } if (!(mapLocale == this._mapLocale)) { this._mapComponent.setMapLocale(mapLocale); } if (!(mapStyle == this._mapStyle)) { this._mapComponent.mapStyle(mapStyle); } this._mapComponent.setMaxPointSize(maxPointSize); this._mapComponent.setAutoZoom(autoZoom); } if (resetData || ((this.updateType <= 1) && mapStyle == this._mapStyle)) { this._mapComponent.fire("style.load"); } } else { var resetData = (this.updateType == 0); if (!this._delayedInit) { this._delayedInit = new com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DelayedInit(); } if (!(this._isRectEqual(this._lastChartRect, chartRect))) { this._delayedInit.setChartRect(chartRect); } this._delayedInit.setDataLayers(dataLayers, resetData, combinedLayers); if (maxZoom != this._maxZoom) { this._delayedInit.setMaxZoom(maxZoom); } if (!(mapLocale == this._mapLocale)) { this._delayedInit.setMapLocale(mapLocale); } if (!(mapStyle == this._mapStyle)) { this._delayedInit.setMapStyle(mapStyle); } this._delayedInit.setMaxPointSize(maxPointSize); this._delayedInit.setAutoZoom(autoZoom); } this._maxZoom = maxZoom; this._mapLocale = mapLocale; this._mapStyle = mapStyle; this._lastChartRect = this._cloneRect(chartRect); this.resetUpdate(); }, _createGeoDataAccessor : function(_captionEntry, _latEntry, _longEntry, _featureIdEntry) { return (new com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.GeoDataAccessor(rave['library']['internal']['AbstractView'].accessorOf(_captionEntry), rave['library']['internal']['AbstractView'].accessorOf(_latEntry), rave['library']['internal']['AbstractView'].accessorOf(_longEntry), rave['library']['internal']['AbstractView'].accessorOf(_featureIdEntry))).getAccessor(); }, evaluateSize : function(value, extent, defValue) { var v = rave['library']['internal']['CSSConverter'].convertCSSSizeToPixelNumber(value, extent, 10); var d = v != null ? v : defValue; return Math.max(0, Math.min(d, extent)); }, /** @expose */ getLegendCount : function() { return 5; }, /** @expose */ getGroupStructure : function() { return ["defs", "g.vizlibrary vizlibrary-tiledmap", "(", "rect.background chart", "g.chart", "g.legends", "(", "g.legends-layout", "g.legend size", "g.legend point", "g.legend latlongSize", "g.legend latlongPoint", "g.legend region", ")", ")"]; }, _setupRegionDataLayer : function(_dataLayer, _dataSet, _data, _layerMap, _geoData, _showLegend) { var regionTypeData = new com_ibm_rave_bundles_nativeImpl_components_TiledmapV2RegionTypeDataImpl(); var nullColor = this.getStringProperty("color.null"); var nullColorDefault = ""+(this.getPropertyDefault("color.null")); var currentPaletteId = this.getStringProperty(_layerMap["region.alt.palette"]); if (""+(this.getPropertyDefault(_layerMap["region.alt.palette"])) == currentPaletteId) { currentPaletteId = this.getStringProperty(_layerMap["region.palette"]); } var jsonPalette = com_ibm_rave_library_Library.palettes.getJSONPalette(currentPaletteId); var dseValue = _dataSet.slot(_layerMap["fill"]).entry(); regionTypeData.setValueAccessor(rave['library']['internal']['AbstractView'].accessorOf(dseValue)); var valueExtent = [0, 0]; if (dseValue) { if (dseValue.domain()) { valueExtent = dseValue.domain(); } else { rave.extent(_data, function(data, index, groupIndex) { return dseValue(data); }); } } regionTypeData.minimumValue(+ (valueExtent[0])); regionTypeData.maximumValue(+ (valueExtent[1])); var featurePalette = com_ibm_rave_library_Library.palettes.getPalette(currentPaletteId); featurePalette.setData(_dataSet, _layerMap["fill"]); regionTypeData.setPaletteDef(jsonPalette); regionTypeData.setPalette(featurePalette); regionTypeData.setNullColor(nullColor == "" ? nullColorDefault : nullColor); regionTypeData.setHasGeoData(_geoData); regionTypeData.setTransparency(this.getIntProperty(_layerMap["region.transparency"])); regionTypeData.setCustomPolygon(this.getStringProperty(_layerMap["region.custom.mapId"]), this.getStringProperty(_layerMap["region.custom.layerName"]), this.getStringProperty(_layerMap["region.custom.propertyName"])); _dataLayer.setTypeData("region", regionTypeData); if (_showLegend) { this._legends.visible(4, !!((dseValue))).selector(4, this.context.node.selectAll("g.legend.region")).palette(4, featurePalette).shape(4, "square").title(4, this.context.getDataSlotLabel("legend.regioncolor.title", dseValue)).titleFill(4, (this.context.getPropertyValue("legend.titlestyle.fill"))).titleFontSize(4, (this.context.getPropertyValue("legend.titlestyle.fontsize"))).titleFontFamily(4, (this.context.getPropertyValue("legend.titlestyle.fontfamily"))).setDataSlot(4, dseValue); } }, _setupPointDataLayer : function(_dataLayer, _dataSet, _data, _layerMap, _legendMap, _geoData, _showLegend) { var pointTypeData = new com_ibm_rave_bundles_nativeImpl_components_TiledmapV2PointTypeDataImpl(); var nullColor = this.getStringProperty("color.null"); var nullColorDefault = ""+(this.getPropertyDefault("color.null")); var currentPaletteId = this.getStringProperty(_layerMap["point.alt.palette"]); if (""+(this.getPropertyDefault(_layerMap["point.alt.palette"])) == currentPaletteId) { currentPaletteId = this.getStringProperty(_layerMap["point.palette"]); } var dsePointColor = _dataSet.slot(_layerMap["pointColor"]).entry(); var dsePointSize = _dataSet.slot(_layerMap["pointSize"]).entry(); pointTypeData.setPointColorAccessor(rave['library']['internal']['AbstractView'].accessorOf(dsePointColor)); pointTypeData.setPointSizeAccessor(rave['library']['internal']['AbstractView'].accessorOf(dsePointSize)); pointTypeData.setHasGeoData(_geoData); pointTypeData.setCustomPolygon(this.getStringProperty(_layerMap["point.custom.mapId"]), this.getStringProperty(_layerMap["point.custom.layerName"]), this.getStringProperty(_layerMap["point.custom.propertyName"])); var pointSizeDomain = [0, 0]; if (dsePointSize) { if (dsePointSize.domain()) { pointSizeDomain = dsePointSize.domain(); } else { pointSizeDomain = rave.extent(_data, function(data, index, groupIndex) { return dsePointSize(data); }); } } var pointPalette = com_ibm_rave_library_Library.palettes.getPalette(currentPaletteId); pointPalette.setData(_dataSet, _layerMap["pointColor"]); pointTypeData.setPalette(pointPalette); var bb = this._chart.node().rave_getParentNode().rave_getParentNode().getBoundingClientRect(); var min = this.evaluateSize(this.getStringProperty(_layerMap["point.minSize"]), bb.width, 10); var max = this.evaluateSize(this.getStringProperty(_layerMap["point.maxSize"]), bb.width, 10); var defaultSize = this.evaluateSize(this.getStringProperty(_layerMap["point.defaultSize"]), bb.width, min + max / 2); var pointSizeScale = rave.scale.linear().domain(pointSizeDomain).range([min, max]); pointTypeData.setPointSizeScale(pointSizeScale); pointTypeData.setDefaultPointSize(defaultSize); var nullColorPalette; if (pointSizeScale) { var minValue = pointSizeScale.domain()[0]; var maxValue = pointSizeScale.domain()[1]; nullColorPalette = rave.scale.ordinal().domain([minValue, maxValue]).range([nullColor]); } pointTypeData.setNullColor(nullColor == "" ? nullColorDefault : nullColor); pointTypeData.setTransparency(this.getIntProperty(_layerMap["point.transparency"])); var staticZeroValueSize = this.getStringProperty(_layerMap["point.staticZeroValueSize"]); if ((staticZeroValueSize == null) || (staticZeroValueSize.length == 0)) { pointTypeData.setStaticZeroValuePointSize(null); } else { pointTypeData.setStaticZeroValuePointSize(this.evaluateSize(staticZeroValueSize, bb.width, 10)); } _dataLayer.setTypeData("point", pointTypeData); if (_showLegend) { var legendIndex = _legendMap["pointSize"]; this._legends.visible(legendIndex, !!((dsePointSize))).selector(legendIndex, this.context.node.selectAll(_layerMap["sizeLegend"])).scale(legendIndex, nullColorPalette).shape(legendIndex, "circle").swatchSize(legendIndex, function(_data, index, groupIndex) { return Math.PI * Math.pow(+ (+ (pointSizeScale.call(null, _data, index, groupIndex))), 2); }).title(legendIndex, this.context.getDataSlotLabel(_layerMap["legend.pointsize.title"], dsePointSize)).titleFill(legendIndex, (this.context.getPropertyValue("legend.titlestyle.fill"))).titleFontSize(legendIndex, (this.context.getPropertyValue("legend.titlestyle.fontsize"))).titleFontFamily(legendIndex, (this.context.getPropertyValue("legend.titlestyle.fontfamily"))).setDataSlot(legendIndex, dsePointSize); legendIndex = _legendMap["pointColor"]; this._legends.visible(legendIndex, !!((dsePointColor))).selector(legendIndex, this.context.node.selectAll(_layerMap["colorLegend"])).palette(legendIndex, pointPalette).shape(legendIndex, "square").title(legendIndex, this.context.getDataSlotLabel(_layerMap["legend.pointcolor.title"], dsePointColor)).titleFill(legendIndex, (this.context.getPropertyValue("legend.titlestyle.fill"))).titleFontSize(legendIndex, (this.context.getPropertyValue("legend.titlestyle.fontsize"))).titleFontFamily(legendIndex, (this.context.getPropertyValue("legend.titlestyle.fontfamily"))).setDataSlot(legendIndex, dsePointColor); } }, _cloneRect : function(_rect) { return new rave['internal']['RectStruct'](_rect.x, _rect.y, _rect.width, _rect.height); }, _isRectEqual : function(_rectA, _rectB) { return ((_rectA.x == _rectB.x) && (_rectA.y == _rectB.y) && (_rectA.width == _rectB.width) && (_rectA.height == _rectB.height)); }, getNLS : function() { var self = this; return function(_key) { return self.message(_key, null); }; } }); com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.EventHandler = rave['internal']['Declare']({ /** @expose */ eventName : null, /** @expose */ callback : null, /** @expose */ constructor : function(_eventName, _callback) { this.eventName = _eventName; this.callback = _callback; } }); com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DelayedInit = rave['internal']['Declare']({ /** @expose */ chartRect : null, /** @expose */ dataLayers : null, /** @expose */ maxZoom : null, /** @expose */ mapLocale : null, /** @expose */ mapStyle : null, /** @expose */ maxPointSize : null, /** @expose */ resetData : false, /** @expose */ combinedLayers : false, /** @expose */ autoZoom : false, /** @expose */ constructor : function() { this.chartRect = null; this.dataLayers = null; this.maxZoom = null; this.mapLocale = null; this.mapStyle = null; this.maxPointSize = null; }, /** @expose */ setChartRect : function(_chartRect) { this.chartRect = _chartRect; }, /** @expose */ setDataLayers : function(_dataLayers, _resetData, _combinedLayers) { this.dataLayers = _dataLayers; this.resetData = _resetData; this.combinedLayers = _combinedLayers; }, /** @expose */ setMaxZoom : function(_maxZoom) { this.maxZoom = _maxZoom; }, /** @expose */ setMapLocale : function(_mapLocale) { this.mapLocale = _mapLocale; }, /** @expose */ setMapStyle : function(_mapStyle) { this.mapStyle = _mapStyle; }, /** @expose */ setMaxPointSize : function(_size) { this.maxPointSize = _size; }, /** @expose */ setAutoZoom : function(_autoZoom) { this.autoZoom = _autoZoom; } }); com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.EventCallback = rave['internal']['Declare']({ //callback : null, _$functionClassMethod : function() { var _$self = function(_e) { _$self.callback(_e); }; return _$self; }, /** @expose */ constructor : function(_callback) { this.callback = _callback; } }); com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.GeoData = rave['internal']['Declare']({ /** @expose */ caption : null, /** @expose */ featureId : null, /** @expose */ latitude : 0, /** @expose */ longitude : 0, /** @expose */ invalidLatLong : false, /** @expose */ constructor : function(_caption, _latitude, _longitude, _featureId) { this.caption = _caption; if (this.isValidLatLong(_latitude, _longitude)) { this.latitude = _latitude; this.longitude = this.normalizeLongitude(_longitude); this.invalidLatLong = false; } else { this.latitude = 0; this.longitude = 0; this.invalidLatLong = true; } this.featureId = _featureId; }, isValidLatLong : function(_latitude, _longitude) { if ((_latitude == null) || (_latitude >= 90) || (_latitude <= -90)) { return false; } return (_longitude != null); }, normalizeLongitude : function(_longitude) { var longitude = _longitude; var correction = (_longitude < 0) ? 360 : -360; while ((longitude < -180) || (longitude > 180)) { longitude += correction; } return longitude; } }); com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.GeoDataAccessor = rave['internal']['Declare']({ //captionAccessor : null, //latitudeAccessor : null, //longitudeAccessor : null, //featureIdAccessor : null, /** @expose */ constructor : function(_caption, _latitude, _longitude, _featureId) { this.captionAccessor = _caption; this.latitudeAccessor = _latitude; this.longitudeAccessor = _longitude; this.featureIdAccessor = _featureId; }, /** @expose */ getAccessor : function() { var self = this; return function(_data) { return new com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.GeoData((self.captionAccessor) ? self.captionAccessor(_data) : null, (self.latitudeAccessor) ? self.latitudeAccessor(_data) : 0, (self.longitudeAccessor) ? self.longitudeAccessor(_data) : 0, (self.featureIdAccessor) ? self.featureIdAccessor(_data) : null); }; } }); //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASET_DATA = "data"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASET_DATA_REGION = "data.region"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASET_DATA_POINT = "data.point"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASET_DATA_LATLONG = "data.latlong"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.TILEDMAP_TOKEN = "tiledmap.token"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.TILEDMAP_STYLE = "tiledmap.style"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.TILEDMAP_GEOJSON = "tiledmap.geoJson"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.TILEDMAP_MAXZOOM = "tiledmap.maxZoom"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.TILEDMAP_MAPLOCALE = "tiledmap.mapLocale"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.TILEDMAP_AUTOZOOM = "tiledmap.autoZoom"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_FEATURE_LVL1 = "featureLvl1"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_FEATURE_LVL2 = "featureLvl2"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_FEATURE_LVL3 = "featureLvl3"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_LATITUDE = "latitude"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_LONGITUDE = "longitude"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_LABEL = "label"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_VALUE = "value"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_FILL = "fill"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_POINTSIZE = "pointSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_POINTCOLOR = "pointColor"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_LATLONG_POINTSIZE = "latlongSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.DATASLOT_LATLONG_POINTCOLOR = "latlongColor"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_MINSIZE = "minPointSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_MAXSIZE = "maxPointSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_STATICZEROVALUEPOINTSIZE = "staticZeroValuePointSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_FILLTRANS = "color.fillTransparency"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINTTRANS = "color.pointTransparency"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_REGION_PALETTE = "region.palette"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_REGION_TRANSPARENCY = "region.transparency"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_REGION_MAPDATA = "region.mapData"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_REGION_CUSTOM_MAPID = "region.custom.mapId"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_REGION_CUSTOM_LAYERNAME = "region.custom.layerName"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_REGION_CUSTOM_PROPERTYNAME = "region.custom.propertyName"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_PALETTE = "point.palette"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_TRANSPARENCY = "point.transparency"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_MAPDATA = "point.mapData"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_MINSIZE = "point.minSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_MAXSIZE = "point.maxSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_DEFAULTSIZE = "point.defaultSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_STATICZEROVALUESIZE = "point.staticZeroValueSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_CUSTOM_MAPID = "point.custom.mapId"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_CUSTOM_LAYERNAME = "point.custom.layerName"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_CUSTOM_PROPERTYNAME = "point.custom.propertyName"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_LEGEND_SIZE_TITLE = "legend.pointsize.title"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_POINT_LEGEND_COLOR_TITLE = "legend.pointcolor.title"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.SELECTOR_POINTSIZE_LEGEND = "g.legend.size"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.SELECTOR_POINTCOLOR_LEGEND = "g.legend.point"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_LATLONG_PALETTE = "latlong.palette"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_LATLONG_TRANSPARENCY = "latlong.transparency"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_LATLONG_MINSIZE = "latlong.minSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_LATLONG_MAXSIZE = "latlong.maxSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_LATLONG_DEFAULTSIZE = "latlong.defaultSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_LATLONG_STATICZEROVALUESIZE = "latlong.staticZeroValueSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_LATLONG_LEGEND_SIZE_TITLE = "legend.latlong.pointsize.title"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.PROP_LATLONG_LEGEND_COLOR_TITLE = "legend.latlong.pointcolor.title"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.SELECTOR_LATLONG_POINTSIZE_LEGEND = "g.legend.latlongSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.SELECTOR_LATLONG_POINTCOLOR_LEGEND = "g.legend.latlongPoint"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_DATASLOT_FEATURE_LVL1 = "featureLvl1"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_DATASLOT_FEATURE_LVL2 = "featureLvl2"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_DATASLOT_FEATURE_LVL3 = "featureLvl3"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_DATASLOT_FILL = "fill"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_DATASLOT_POINTSIZE = "pointSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_DATASLOT_POINTCOLOR = "pointColor"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_REGION_PALETTE = "region.palette"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_REGION_ALT_PALETTE = "region.alt.palette"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_REGION_TRANSPARENCY = "region.transparency"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_REGION_MAPDATA = "region.mapData"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_REGION_CUSTOM_MAPID = "region.custom.mapId"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_REGION_CUSTOM_LAYERNAME = "region.custom.layerName"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_REGION_CUSTOM_PROPERTYNAME = "region.custom.propertyName"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_POINT_PALETTE = "point.palette"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_POINT_ALT_PALETTE = "point.alt.palette"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_POINT_TRANSPARENCY = "point.transparency"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_POINT_MAPDATA = "point.mapData"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_POINT_MINSIZE = "point.minSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_POINT_MAXSIZE = "point.maxSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_POINT_DEFAULTSIZE = "point.defaultSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_POINT_STATICZEROVALUESIZE = "point.staticZeroValueSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_POINT_CUSTOM_MAPID = "point.custom.mapId"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_POINT_CUSTOM_LAYERNAME = "point.custom.layerName"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_POINT_CUSTOM_PROPERTYNAME = "point.custom.propertyName"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_LEGEND_SIZE_TITLE = "legend.pointsize.title"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_PROP_LEGEND_COLOR_TITLE = "legend.pointcolor.title"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_LEGEND_POINTSIZE = "pointSize"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_LEGEND_POINTCOLOR = "pointColor"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_SELECTOR_POINTSIZE_LEGEND = "sizeLegend"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.NORM_SELECTOR_POINTCOLOR_LEGEND = "colorLegend"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.TYPE_REGION = "region"; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.TYPE_POINT = "point"; com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.LEGEND_POINTSIZE = 0; com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.LEGEND_POINTCOLOR = 1; com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.LEGEND_LATLONG_POINTSIZE = 2; com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.LEGEND_LATLONG_POINTCOLOR = 3; com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.LEGEND_REGIONCOLOR = 4; //com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.ELEMENT_SHAPE_SELECTOR = "." + "element-shape"; com_ibm_rave_bundles_tiledmapV2Bundle_TiledmapV2View.BASE_BOUNDS = [[-180, -85.05112], [180, 85.05112]]; // $source: com/ibm/rave/bundles/components/BackgroundComponentImpl /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ // GENERATED //@import com/ibm/rave/bundles/components/BundleComponentImpl (loadtime) // superclass //@import com/ibm/rave/bundles/component/BackgroundComponent (runtime) // BackgroundComponent /** *Component to set the background color of a bundle. The component properties are:
The component assumes that the selector on which it is executed is a "rect" shape which lies below the chart. If the size property is non-null, it sets the geometry of this rectangle to be the given size, with upper-left corner at 0,0. If the size is null, the rectangle is not resized.
The rectangle fill is set to the backgroundColor property. If the property is null, white (#FFFFFF) is used. TODO. Should we set it to null, so the CSS style can also be used to set the background?
*/ var com_ibm_rave_bundles_components_BackgroundComponentImpl = rave['internal']['Declare'](com_ibm_rave_bundles_components_BundleComponentImpl, { //_backgroundColor : null, //_rect : null, /** @expose */ constructor : function() { this._rect = new rave['internal']['RectStruct'](0, 0, 0, 0); }, /** @expose */ execute : function(g) { this.preExecute(); g.style("fill", this._backgroundColor != null ? this._backgroundColor : "#FFFFFF").style("fill-opacity", 1.0); g.attr("x", this._rect.x).attr("y", this._rect.y).attr("width", this._rect.width).attr("height", this._rect.height); }, /** @expose */ type : function() { return com_ibm_rave_bundles_component_BackgroundComponent.COMPONENT_TYPE; }, backgroundColor$0 : function() { return this._backgroundColor; }, backgroundColor$1 : function(backgroundColor) { this._backgroundColor = backgroundColor; return this; }, /** * @param (rave['library']['internal']['ContextSize']) size New value of size property * @return (com.ibm.rave.bundles.components.BackgroundComponentImpl) This component */ /** @expose */ size : function(size) { this._rect.x = 0; this._rect.y = 0; this._rect.width = size.w; this._rect.height = size.h; return this; }, /** @expose */ rect : function(rect) { var r = new rave['internal']['RectStruct'](rect.x, rect.y, rect.width, rect.height); this._rect = r; return this; }, /** @expose */ backgroundColor : function(a0) { var args = arguments; if (args.length == 0) { return this.backgroundColor$0(); } return this.backgroundColor$1(a0); } }); // $source: com/ibm/rave/bundles/components/ChartLayoutComponentImpl /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ // GENERATED //@import com/ibm/rave/bundles/components/BundleComponentImpl (loadtime) // superclass //@import com/ibm/rave/bundles/component/ChartLayoutComponent (runtime) // ChartLayoutComponent /** *Implementation of the chart layout component API. General sequence in a bundle view:
_clip.clipRect(new RectStruct(50, 50, 200, 200)) // Set the clipping rectangle .applyTo(chart.select(".content")) // Apply the clip-path attribute to a graphical element. This can be called repeatedly on different selections. .applyTo(chart.select(".otherContent")) .run(context.node.select("defs")); // ClipPathComponent creates a clipPath element within the provided node. This component should be executed on a single "defs" node, however there is no restriction.*/ var com_ibm_rave_bundles_components_ClipPathComponentImpl = rave['internal']['Declare'](com_ibm_rave_bundles_components_BundleComponentImpl, { //_id : null, //_clipRect : null, constructor : function(id) { this._clipRect = new rave['internal']['RectStruct'](0, 0, 100, 100); /** * Initializes the component. The provided id will be used as the "id" attribute for the clipPath element created by this component. Recall that an "id" in an SVG/HTML document must be unique across the entire document. If you create multiple clipPath elements with the same id, then all elements referencing one of these clip paths will not be resolved as you expected. * @param (String) id String ID that is unique across the document. */ { this._id = id; } }, /** @expose */ type : function() { return "ClipPathComponent"; }, /** * Set the rectangular clipping area. Make the _clipRect one pixel larger than requested to avoid the cut-off at bounds. TODO: why?!? * @param (rave['internal']['RectStruct']) rect The rectangular bounds of the clipping area. * @return (com.ibm.rave.bundles.components.ClipPathComponentImpl) This ClipPathComponent. */ /** @expose */ clipRect : function(rect) { this._clipRect = new rave['internal']['RectStruct'](rect.x - 1, rect.y - 1, rect.width + 2, rect.height + 2); return this; }, /** * Set the clip-path attribute on the provided selection. * @return (com.ibm.rave.bundles.components.ClipPathComponentImpl) This ClipPathComponent. */ /** @expose */ applyTo : function(s) { s.attr("clip-path", "url(" + this.url() + ")"); return this; }, /** * Retrieve the id assigned to this clip path. */ /** @expose */ id : function() { return this._id; }, /** * Retrieve the URL that can be used to reference this clip path. */ /** @expose */ url : function() { return "#" + this._id; }, /** @expose */ execute : function(g) { var clipPath = g.selectAll("#" + this._id).data([0]); clipPath.enter().append("clipPath").attr("id", this._id).append("rect"); rave.transition(clipPath.select("rect")).attr("x", this._clipRect.x).attr("y", this._clipRect.y).attr("width", this._clipRect.width).attr("height", this._clipRect.height); } }); // $source: com/ibm/rave/bundles/components/LegendComponentImpl /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ // GENERATED //@import com/ibm/rave/bundles/components/BundleComponentImpl (loadtime) // superclass //@import com/ibm/rave/bundles/utilities/FontPropertyParser (runtime) // parseCSSFont /** *
A component to draw a legend, using a RAVE capability swatch legend. In JavaScript the RAVE legend and layout extensions must be loaded. The legend puts its shapes into the selector passed to its execute method, so that selector should choose a group node.
Most of the component properties are passed directly to the RAVE legend. The properties are:
visible: If true, the legend is drawn; otherwise it is cleared (all shapes are removed from the legend). The default is true.
size: A Dim with the size of the legend in the chart coordinate system. If null or zero-sized, the legend is cleared. This is passed to the swatch legend.
colorScale: A scale (OrdinalScale) used as the RAVE legend scale. If null, the legend is cleared. The legend currently only supports a single ordinal color scale.
orient: The RAVE legend orient, either "horizontal" or "vertical". The default is "vertical".
swatchSize: The RAVE legend size. Note that this is in square pixels. The default is 20*20.
shape: The RAVE legend shape. The default is "square".
title: The RAVE legend title. The default is null.
titleFill: The legend title color. The default is null.
titleFontSize: The legend title font size. The default is null.
titleFontFamily: The legend title font family. The default is null.
borderColor: The RAVE legend borderColor. The default is "black".
labelFormat: The RAVE legend labelFormat. The default is null.
*/ var com_ibm_rave_bundles_components_LegendComponentImpl = rave['internal']['Declare'](com_ibm_rave_bundles_components_BundleComponentImpl, { /** * Legend size property */ //_size : null, /** * Color scale */ //_colorPalette : null, /** * Orient, "horizontal" or "vertical" */ //_orient : null, /** * Swatch size function */ //_swatchSizeFunc : null, /** * Scale */ //_scale : null, /** * Swatch symbol */ //_shape : null, /** * Legend title */ //_title : null, /** * Legend title styling */ //_titleStyle : null, /** * Legend entry styling */ //_entryStyle : null, /** * Custom formatter */ //_labelFormat : null, /** * The swatch legend, created on demand */ //_swatchLegend : null, /** * The continuous legend, created on demand */ //_continuousLegend : null, /** * The legend type, either "SwatchLegend" or "ContinuousLegend" */ //_legendType : null, /** * Is the legend visible */ _visible : false, /** * Swatch size in square pixels */ _swatchSize : 0, /** * Constructor; sets bound and, colorScale to null, all other properties to their default values. */ /** @expose */ constructor : function() { this._visible = true; this._size = null; this._colorPalette = null; this._orient = "horizontal"; this._swatchSize = 16.0 * 16.0; this._swatchSizeFunc = null; this._scale = null; this._shape = "square"; this._title = null; this._titleStyle = {}; this._entryStyle = {}; this._labelFormat = null; this._swatchLegend = null; this._continuousLegend = null; this._legendType = null; }, /** @expose */ type : function() { return "LegendComponent"; }, /** @expose */ execute : function(g) { if (this._colorPalette) { if ("continuous" == this._colorPalette.getType()) { if (!this._continuousLegend) { this._continuousLegend = (rave.capabilities.extension("legend")).continuous(); } this._legendType = "ContinuousLegend"; } else { if (!this._swatchLegend) { this._swatchLegend = (rave.capabilities.extension("legend")).swatch(); } this._legendType = "SwatchLegend"; } } else if (this._swatchSizeFunc) { if (!this._swatchLegend) { this._swatchLegend = (rave.capabilities.extension("legend")).swatch(); } this._legendType = "SwatchLegend"; } else { this._legendType = null; } this.preExecute(); if (!this._visible || (!this._colorPalette && !this._swatchSizeFunc) || !this._size || this._size[0] <= 0 || this._size[1] <= 0) { g.selectAll("*").remove(); return; } var fontChecker = rave.capabilities.extension("fontchecker"); if (this._colorPalette && "continuous" == this._colorPalette.getType()) { this._continuousLegend.shapeRectSize("horizontal" == this._orient ? [-1.0, 16.0] : [16.0, -1.0]).size(this._size).scale(this._colorPalette.getScale()).orient(this._orient).title(this._title).titleFill(this._titleStyle["fill"]).titleFontSize(this._titleStyle["font-size"]).titleFontFamily(this._titleStyle["font-Family"]).titleAlignment("start").labelFormat(this._labelFormat); var legend = g.call(this._continuousLegend); if (this._entryStyle) { legend.selectAll(".legendLabel").style(this._entryStyle); } if (this._titleStyle) { legend.selectAll(".legendTitle").style(this._titleStyle); } if (fontChecker) { legend.selectAll(".legendLabel").call(fontChecker); legend.selectAll(".legendTitle").call(fontChecker); } } else { var insets = {}; insets["bottom"] = 5; var swatchSize = this._swatchSize; var scale = null; var labelFormatter = this._labelFormat; if (this._swatchSizeFunc && this._scale) { swatchSize = this._swatchSizeFunc; scale = this._scale; } if (this._colorPalette) { scale = this._colorPalette.getScale(); var originalDomain = this._colorPalette.originalDomain(); if (originalDomain) { scale.domain(originalDomain); var f = this._colorPalette.originalDomainLabelAccessor(); if (this._labelFormat) { var self = this; labelFormatter = function(data, index, groupIndex) { return self._labelFormat.call(this, f.call(this, data, index, groupIndex), index, groupIndex); }; } else { labelFormatter = f; } } } this._swatchLegend.labelPadding(8).size(this._size).scale(scale).orient(this._orient).swatchSize(swatchSize).shape(this._shape).title(this._title).titleFill(this._titleStyle["fill"]).titleFontSize(this._titleStyle["font-size"]).titleFontFamily(this._titleStyle["font-family"]).titleAlignment("start").labelFormat(labelFormatter).titleInsets(insets); var legend = g.call(this._swatchLegend); if (this._entryStyle) { legend.selectAll(".legendLabel").style(this._entryStyle); } if (this._titleStyle) { legend.selectAll(".legendTitle").style(this._titleStyle); } if (fontChecker) { legend.selectAll(".legendLabel").call(fontChecker); legend.selectAll(".legendTitle").call(fontChecker); } } }, /** @expose */ legend : function() { if ("ContinuousLegend" == this._legendType) { return this._continuousLegend; } if ("SwatchLegend" == this._legendType) { return this._swatchLegend; } return null; }, /** @expose */ legendType : function() { return this._legendType; }, /** * Set the visible property. * @param (boolean) visible New visible * @return (com.ibm.rave.bundles.components.LegendComponentImpl) This object */ /** @expose */ visible : function(visible) { this._visible = visible; return this; }, /** * see if the legend is visible * @return (boolean) if its visible */ /** @expose */ isVisible : function() { return this._visible; }, /** * Set the size property. * @param (Array) size New size * @return (com.ibm.rave.bundles.components.LegendComponentImpl) This object */ /** @expose */ size : function(size) { this._size = size; return this; }, /** * Set the color scale property. * @param (rave['library']['internal']['Palette']) colorPalette New color scale * @return (com.ibm.rave.bundles.components.LegendComponentImpl) This object */ /** @expose */ colorPalette : function(colorPalette) { this._colorPalette = colorPalette; return this; }, /** * Set the orient property. If the argument is not "horizontal" or "vertical", it is ignored and the orient property is not changed. * @param (String) orient New orient * @return (com.ibm.rave.bundles.components.LegendComponentImpl) This object */ /** @expose */ orient : function(orient) { if ("horizontal" == orient || "vertical" == orient) { this._orient = orient; } return this; }, /** * Set the orient property from a legend position. If the argument is "top" or "bottom", the orient is set to "horizontal". Otherwise it is set to "vertical". * @param (String) position Legend position * @return (com.ibm.rave.bundles.components.LegendComponentImpl) This object */ /** @expose */ position : function(position) { return this.orient(com_ibm_rave_bundles_components_LegendComponentImpl.orientationOf(position)); }, swatchSize$0 : function(swatchSize) { if (swatchSize >= 0.0 && swatchSize != null) { this._swatchSize = swatchSize; } return this; }, /** @expose */ scale : function(scale) { this._scale = scale; return this; }, swatchSize$1 : function(swatchSize) { if (swatchSize) { this._swatchSizeFunc = swatchSize; } return this; }, /** @expose */ shape : function(shape) { this._shape = shape; return this; }, /** @expose */ title : function(title) { this._title = (title != null && title.length > 0) ? title : null; return this; }, /** @expose */ titleFill : function(titleFill) { this._titleStyle["fill"] = titleFill; return this; }, /** @expose */ titleFontSize : function(titleFontSize) { this._titleStyle["font-size"] = titleFontSize; return this; }, /** @expose */ titleFontFamily : function(titleFontFamily) { this._titleStyle["font-family"] = titleFontFamily; return this; }, /** @expose */ labelFormat : function(labelFormat) { this._labelFormat = labelFormat; return this; }, /** @expose */ titleFont : function(titleFontStyle) { this._titleStyle = com_ibm_rave_bundles_utilities_FontPropertyParser.parseCSSFont(titleFontStyle); return this; }, /** @expose */ entryFont : function(entryFontStyle) { this._entryStyle = com_ibm_rave_bundles_utilities_FontPropertyParser.parseCSSFont(entryFontStyle); return this; }, /** @expose */ getSpaceUsed : function() { if (this._colorPalette && "continuous" == this._colorPalette.getType()) { return this._continuousLegend.getUsedSize() + 2; } else { return this._swatchLegend.getUsedSize() + 2; } }, /** @expose */ swatchSize : function(a0) { var args = arguments; if (args.length == 1 && typeof a0 === "function") { return this.swatchSize$1(a0); } return this.swatchSize$0(a0); } }); /** * Get the orient for a position. "top" and "bottom" return "horizontal", anything else ("left", "right", or unknown/null) is "vertical". * @param (String) position A position * @return (String) "horizontal" or "vertical" */ /** @expose */ com_ibm_rave_bundles_components_LegendComponentImpl.orientationOf = function(position) { if ("top" == position || "bottom" == position) { return "horizontal"; } return "vertical"; }; //com_ibm_rave_bundles_components_LegendComponentImpl.HORIZONTAL = "horizontal"; //com_ibm_rave_bundles_components_LegendComponentImpl.VERTICAL = "vertical"; com_ibm_rave_bundles_components_LegendComponentImpl.BAR_THINKNESS = 16; com_ibm_rave_bundles_components_LegendComponentImpl.SWATCH_SIZE = 16; /** @expose */ com_ibm_rave_bundles_components_LegendComponentImpl.TOP = "top"; /** @expose */ com_ibm_rave_bundles_components_LegendComponentImpl.BOTTOM = "bottom"; /** @expose */ com_ibm_rave_bundles_components_LegendComponentImpl.LEFT = "left"; /** @expose */ com_ibm_rave_bundles_components_LegendComponentImpl.RIGHT = "right"; /** @expose */ com_ibm_rave_bundles_components_LegendComponentImpl.ADJUSTABLE = -1; // $source: com/ibm/rave/bundles/components/AxisComponentImpl /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2018 ** ** 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. ************************************************************************/ // GENERATED //@import com/ibm/rave/bundles/components/BundleComponentImpl (loadtime) // superclass //@import com/ibm/rave/bundles/component/AxisComponent (runtime) // AxisComponent //@import com/ibm/rave/bundles/utilities/TextCrossfader (runtime) // textCrossFade //@import com/ibm/rave/bundles/utilities/FontPropertyParser (runtime) // parseCSSFont //@import com/ibm/rave/bundles/utilities/BundleLabelDropper (runtime) // new /** *Component to draw an axis and title. The component is drawn into a Selector group, and the user of the component must translate the group to the axis position and set up the axis scale for the correct number of pixels.
The component uses a RAVE core Axis for drawing the axis. Most component properties are passed to the axis. The component properties are:
scale: The axis scale. This must be set up with the domain and range (pixels) of the axis. If null the axis does not render, and removes all axis shapes from the selector. Default null.
orient: The axis orient, "top", "bottom", "left", or "right". Default "bottom".
bounds: The bounding box for the axis, used to position the title and to wrap/truncate axis labels. If null the title is placed 50 pixels from the axis line and text is not wrapped.
tickFormat: A value function passed to the axis to format tick labels. Default null, meaning the RAVE default formatting is used.
displayAxisTitle: Whether to display the axis title. Default true.
axisTitle: The title to display on the axis. It is centered on the axis range, and the size property is used to find the distance from the axis. Default null.
axisColor: A color-string for the axis line. If null, no color is applied and the CSS defaults are used. Default null.
tickColor: A color-string for the axis ticks. If null, no color is applied and the CSS defaults are used. Default null.
labelColor: A color-string for the axis tick labels. If null, no color is applied and the CSS defaults are used. Default null.
titleColor: A color-string for the axis title. If null, no color is applied and the CSS defaults are used. Default null.
displayAxisLine: Whether to display the axis line. Default true.
displayAxisTicks: Whether to display the axis ticks. Default true.
displayAxisTickLabels: Whether to display the axis tick labels. Default true.
*/ var com_ibm_rave_bundles_components_AxisComponentImpl = rave['internal']['Declare'](com_ibm_rave_bundles_components_BundleComponentImpl, { /** * Axis - created on demand */ //_axis : null, /** * Role, from the AxisComponent API */ //_role : null, /** * CoordinateScale */ //_scale : null, /** * Orient, always one of the four legal values */ //_orient : null, /** * Size */ //_bounds : null, //_elementRect : null, /** * The title text; default null (nothing visible) */ /** @expose */ _axisTitle : null, /** * The title style; defaults null (use the CSS styling) */ /** @expose */ _titleStyle : null, /** * Axis line color; default null (use the CSS styling) */ /** @expose */ _lineColor : null, /** * Axis tick color; default null (use the CSS styling) */ /** @expose */ _tickColor : null, /** * Axis tick label style; defaults null (use the CSS styling) */ /** @expose */ _labelStyle : null, //_staggerRotate45Nodes : null, //_staggerFirstNode : null, //_staggerLastNode : null, /** * Axis tick label formatting */ //_tickFormat : null, //_dropOverlap : null, /** * Used to get the extension to enable axis label wrapping */ //_textFlow : null, /** * Used to check the fonts on each label to make sure all characters are covered */ //_fontChecker : null, /** * Run function that applies the properties to the axis line */ //_axisLineProperties : null, /** * Run function that applies the properties to the axis ticks */ //_axisTickProperties : null, /** * Run function that applies the properties to the axis tick labels */ //_axisTickLabelProperties : null, /** * Run function that hides or displays the axis tick labels */ //_displayHideLabels : null, /** * Run function that hides or displays the axis tick labels */ //_panZoomLabels : null, /** * The tick handler registered with the axis; will get called during axis transition */ //_tickHandler : null, //_textTruncationIndicator : null, /** * Used when dealing with numeric scale on the vertical axis and the numbers don't fit */ //_simplifiedTickFormat : null, //_tickMagnitude : null, /** * Whether to display the axis title; default true */ /** @expose */ _displayAxisTitle : false, /** * Whether to display the axis line; default true */ /** @expose */ _displayAxisLine : false, /** * Whether to display the axis ticks; default true */ /** @expose */ _displayTicks : false, /** * Whether to display the axis tick labels (conditional on show labels property); default true */ /** @expose */ _displayTickLabels : false, /** * Whether to display the axis tick labels (conditional on pan-zoom hide property); default true */ /** @expose */ _showPanZoomTickLabels : false, /** * Whether to rotate the axis tick labels; default false */ _rotateLabels : false, _staggerCellWidth : 0, _staggerAlignFirstAtStart : false, _staggerAlignLastAtEnd : false, _layoutTimerId : 0, _layoutTitleSize : 0, _layoutLabelSize : 0, _layoutLabelHeight : 0, _layoutAverageDigitWidth : 0, _layoutSpillOver : 0, /** * Whether to hide overlapping labels; default true */ /** @expose */ _hideOverlappingLabels : false, /** * When true, don't start a new timer */ _pendingLabelTimer : false, /** * The padding in px between tick axis line and tick label, and also between tick label and title. Default 16px. */ _padding : 0, /** * After calling the component, this is true if shapes were rendered, false if they were cleared. */ _renderedShapes : false, _layoutMode : -1, _allowAutoAxisLayoutToChangeOrientaiton : true, _lastAutomaticAxisLayoutOrientation : -1, _allowStagger : false, _allowRotate45 : false, _allowRotate90 : false, constructor : function() { { var self = this; this._axisLineProperties = function(args) { if (args !== null || arguments.length > 1){ args = Array.prototype.slice.call(arguments, 0); } { var line = this.selectAll("path.domain"); if (self._lineColor != null) { line.style("stroke", self._lineColor); } if (self._displayAxisLine) { line.attr("visibility", null); } else { line.attr("visibility", "hidden"); } return null; } }; this._axisTickProperties = function(args) { if (args !== null || arguments.length > 1){ args = Array.prototype.slice.call(arguments, 0); } { var tickLines = this.selectAll("line"); if (self._displayTicks) { tickLines.attr("visibility", null); } else { tickLines.attr("visibility", "hidden"); } if (self._lineColor != null) { tickLines.style("stroke", self._tickColor); } return null; } }; this._axisTickLabelProperties = function(args) { if (args !== null || arguments.length > 1){ args = Array.prototype.slice.call(arguments, 0); } { var labels = this.selectAll("text"); labels.each(self._displayHideLabels); labels.each(self._panZoomLabels); labels.style(self._labelStyle); self._axis.ticksHandler(null); return null; } }; this._displayHideLabels = function(obj, group, index) { if (self._displayTickLabels) { if (this.rave_hasProperty("__tickLabelHidden__")) { this.rave_removeProperty("__tickLabelHidden__"); var count = ~~ (this.rave_getProperty("__hiddenCount__")); if (count <= 1) { this.rave_removeProperty("__hiddenCount__"); this.removeAttribute("visibility"); } else { this.rave_setProperty("__hiddenCount__", count - 1); } } } else { if (!(this.rave_hasProperty("__tickLabelHidden__"))) { this.setAttribute("visibility", "hidden"); this.rave_setProperty("__tickLabelHidden__", "hidden"); var count = ~~ (this.rave_getProperty("__hiddenCount__")); this.rave_setProperty("__hiddenCount__", count + 1); } } }; this._panZoomLabels = function(obj, group, index) { if (self._showPanZoomTickLabels) { if (this.rave_hasProperty("__panZoomHidden__")) { this.rave_removeProperty("__panZoomHidden__"); var count = ~~ (this.rave_getProperty("__hiddenCount__")); if (count <= 1) { this.rave_removeProperty("__hiddenCount__"); this.removeAttribute("visibility"); } else { this.rave_setProperty("__hiddenCount__", count - 1); } } } else { if (!(this.rave_hasProperty("__panZoomHidden__"))) { this.setAttribute("visibility", "hidden"); this.rave_setProperty("__panZoomHidden__", "hidden"); var count = ~~ (this.rave_getProperty("__hiddenCount__")); this.rave_setProperty("__hiddenCount__", count + 1); } } }; } this._tickHandler = new com_ibm_rave_bundles_components_AxisComponentImpl.AxisTickHandler(this._axisTickLabelProperties, this._axisTickProperties); /** * Initialize properties to defaults */ { this._axis = null; this._role = null; this._scale = null; this._orient = "bottom"; this._bounds = null; this._displayAxisTitle = true; this._axisTitle = null; this._titleStyle = {}; this._displayAxisLine = true; this._lineColor = null; this._displayTicks = true; this._tickColor = null; this._displayTickLabels = true; this._labelStyle = {}; this._rotateLabels = false; this._hideOverlappingLabels = true; this._dropOverlap = new com_ibm_rave_bundles_utilities_BundleLabelDropper(); this._tickFormat = null; this._showPanZoomTickLabels = true; this._pendingLabelTimer = false; this._padding = 16; this._textFlow = rave.capabilities.extension("textflow"); this._fontChecker = rave.capabilities.extension("fontchecker"); this._renderedShapes = false; } }, /** @expose */ type : function() { return com_ibm_rave_bundles_component_AxisComponent.COMPONENT_TYPE; }, /** @expose */ role : function() { return this._role; }, /** @expose */ execute : function(g) { this.preExecute(); if (!this._scale) { g.selectAll("*").remove(); this._renderedShapes = false; return; } this._renderedShapes = true; if (this._scale.isOrdinal() || this._scale.isClustered()) { this._hideOverlappingLabels = false; this._rotateLabels = true; } else { this._hideOverlappingLabels = true; this._rotateLabels = true; } this.drawTitle(g); this.drawAxis(g); this.handleAxisText(g); this.drawTitle(g); }, /** * This is one place where all the calls that affect the axis text happen in case of allowAutomaticAxisLayout the new behavior applies here * @param (rave['internal']['Selector']) g */ handleAxisText : function(g) { this.stopLabelDroppingUpdate(); var duration = 0, delay = 0; var g2 = rave.transition(g); if (g2.isTransition()) { var t2 = (g2); duration = t2.duration(); delay = t2.delay(); } var axisSelector = g.selectAll("g.axis"); var labels = axisSelector.selectAll("g.tick").filter(rave['library']['internal']['BundleUtils'].notExit).selectAll("text"); var fontChecker = rave.capabilities.extension("fontchecker"); labels.style(this._labelStyle); if (fontChecker) { labels.call(fontChecker); } var mode = this._allowAutoAxisLayoutToChangeOrientaiton ? this.determineWhichAutoMode(g) : this._lastAutomaticAxisLayoutOrientation; this.configureStaggerData(g, mode); this.handleLabelsRotationAndPosition(g, labels, mode); this.hashingNumericScales(labels, this.labelExtent(g), mode); if (duration == 0) { this.doLabelWrapping(g, mode); this.handleLabelsRotationAndPosition(g, labels, mode); } this._lastAutomaticAxisLayoutOrientation = mode; if (!(this._scale.isOrdinal()) && !(this._scale.isClustered())) { var isHorizontal = this._orient == "bottom" || this._orient == "top"; var tick = axisSelector.append("g").classed("tick", true); var tickText = tick.append("text"); if (labels.size() == 0) { var singleValue = this._scale.scale().domain()[0]; var formatter = this._tickFormat; if (!formatter) { var tickFunc = this._scale.scale().tickFormat; if (tickFunc) { formatter = tickFunc.apply(tickFunc, [singleValue]); } } var node = tickText[0][0]; var stringValue = formatter ? formatter.call(node, singleValue, 0, 0) : ""+(singleValue); tickText.text(stringValue); var dim = node.getBBox(); this._layoutLabelSize = isHorizontal ? dim.height : dim.width; if (!isHorizontal || mode != 0) { tickText.text(".0"); this._layoutLabelSize += node.getBBox().width; } } if (!isHorizontal || mode != 0) { tickText.text(".0"); var node = tickText[0][0]; var dim = node.getBBox(); this._layoutAverageDigitWidth = dim.width; } tick.remove(); } if (this._hideOverlappingLabels && duration > 0) { this.updateLabelDropping(labels, duration, delay); } if (duration > 0) { this.doLabelWrappingAfterAnimation(g, labels, mode, duration, delay); } if (!this._displayTickLabels) { this._layoutLabelSize = 0; this._layoutAverageDigitWidth = 0; } }, /** * Rotates the text and shifts it to compensate for the rotation Needs to be called twice once before wrapping in order to have text in correct position for wrap then after to know the correct height of wrapped text in order to shift it correct TODO: find a better way to do this * @param (rave['internal']['Selector']) g selector * @param (rave['internal']['Selector']) labels labels selector * @param (int) mode one of HORIZONTAL, STAGGER, ROTATE90 */ handleLabelsRotationAndPosition : function(g, labels, mode) { if (mode == 2 || mode == 1) { if (this._orient == "bottom") { this.rotateLabels(g, labels, "end", mode); } else if (this._orient == "top") { this.rotateLabels(g, labels, "start", mode); } else { this.rotateLabels(g, labels, "middle", mode); } } else { if (this._orient == "bottom" || this._orient == "top") { this.rotateLabels(g, labels, "middle", mode); } else if (this._orient == "right") { this.rotateLabels(g, labels, "start", mode); } else { this.rotateLabels(g, labels, "end", mode); } } }, /** *Numeric scales cannot be truncated or wrapped, if a number doesn't fit the allowed space the number should be hashed
ex: 12345 -> #####
This method should be called before {@link #this.doLabelWrapping(rave['internal']['Selector'])} , truncation must be set to off in case of numeric scale
* @param (rave['internal']['Selector']) labels */ hashingNumericScales : function(labels, extent, mode) { if (!labels || !extent) { return; } if (!(this._scale.isOrdinal()) && !(this._scale.isClustered())) { var isHorizontal = this._orient == "bottom" || this._orient == "top"; var tickSpace = mode == 1 ? extent[1] : extent[0]; this._textTruncationIndicator = ""; this._layoutLabelSize = 0; for (var i = 0; i < labels.size(); ++i) { var node = labels[i][0]; var dim = node.getBBox(); var width = dim.width; var height = dim.height; var size = !isHorizontal || mode == 1 ? width : height; if (size > this._layoutLabelSize) { this._layoutLabelSize = size; } if (width >= tickSpace) { if (this._simplifiedTickFormat) { var newText = this._simplifiedTickFormat.call(null, node.rave_getData(), 0, 0); if (newText != null) { node.rave_setText(newText); } if (node.getBBox().width >= tickSpace) { node.rave_setText(this.stringOfSize(node.rave_getText().length, "#")); } } else { node.rave_setText(this.stringOfSize(node.rave_getText().length, "#")); } } } } }, /** * @param (int) size The desired size of the string * @param (String) ch The character to be repeated in the string * @return (String) A string of the specified size containing repetition of the specified character */ stringOfSize : function(size, ch) { var returnString = ""; for (var i = 0; i < size; ++i) { returnString += ch; } return returnString; }, configureStaggerData : function(g, mode) { if (mode == 3 || mode == 2) { var horizontalDimensions = this.labelExtent(g); var cellWidth = horizontalDimensions[0]; var axisSelector = g.selectAll("g.axis"); var labels = axisSelector.selectAll("text"); var domain = this._scale.scale().domain(); var originalDataLabelAccessor = (this._scale).originalDomainLabelAccessor(); this._staggerRotate45Nodes = []; this._staggerFirstNode = null; this._staggerLastNode = null; for (var i = 0; i < labels.size(); ++i) { var node = labels[0][i]; if (this.isValid(node.rave_getData())) { var domainIndex = -1; if (mode == 3) { var domainLabel = !this._tickFormat ? node.rave_getText() : originalDataLabelAccessor.call(node, node.rave_getData(), 0, 0); for (var index = 0; index < domain.length; ++index) { if (domain[index].toString() == domainLabel) { domainIndex = index; break; } } } this._staggerRotate45Nodes.push(new com_ibm_rave_bundles_components_AxisComponentImpl.NodeIndex(node, domainIndex)); if (domainIndex == 0) { this._staggerFirstNode = node; } if (domainIndex == domain.length - 1) { this._staggerLastNode = node; } } } this._staggerCellWidth = cellWidth * 2; this._staggerAlignFirstAtStart = this._staggerFirstNode ? this._staggerFirstNode.getBBox().width > cellWidth : false; this._staggerAlignLastAtEnd = this._staggerLastNode ? this._staggerLastNode.getBBox().width > cellWidth : false; } }, getStaggerIndex : function(node) { for (var index = 0; index < this._staggerRotate45Nodes.length; ++index) { if (this._staggerRotate45Nodes[index].contains(node)) { var domainIndex = this._staggerRotate45Nodes[index].getIndex(); return domainIndex == -1 ? 0 : domainIndex; } } return -1; }, getStaggerCount : function() { var domain = this._scale.scale().domain(); return domain.length; }, /** *The method is responsible for determining which mode to be used with the label positioning if {@link com_ibm_rave_bundles_components_AxisComponentImpl._allowAutomaticLayout} flag is enabled
* @param (rave['internal']['Selector']) g */ determineWhichAutoMode : function(g) { var isHorizontal = this._orient == "bottom" || this._orient == "top"; var axisSelector = g.selectAll("g.axis"); var labels = axisSelector.selectAll("text"); var dim = this.labelExtent(g); var cellWidth = dim[0]; var cellWidth90 = dim[1]; var layoutLabelHeight = 0; var layoutLabelWidth = 0; var horizontalScore = 0; var staggerScore = 0; var rotate45Score = 0; var rotate90Score = 0; var validNodes = []; for (var i = 0; i < labels.size(); ++i) { var node = labels[0][i]; if (this.isValid(node.rave_getData())) { validNodes.push(node); } } var labelCount = validNodes.length; if (!(this._scale.isOrdinal()) && !(this._scale.isClustered())) { var mode = 0; if (isHorizontal) { mode = this._layoutMode == 1 ? 1 : 0; var tick = axisSelector.append("g").classed("tick", true); var tickText = tick.append("text"); tickText.style(this._labelStyle); tickText.text(",0"); var node = tickText[0][0]; var zeroWidth = node.getBBox().width; tick.remove(); var widestLabel = 0; for (var i = 0; i < labelCount; ++i) { node = validNodes[i]; var nodeRect = node.getBBox(); if (nodeRect.width > widestLabel) { widestLabel = nodeRect.width; } if (nodeRect.height > this._layoutLabelHeight) { this._layoutLabelHeight = nodeRect.height; } } widestLabel += zeroWidth; this._layoutSpillOver = mode == 1 ? this._layoutLabelHeight / 2 : widestLabel / 2 + 2; } else { for (var i = 0; i < labelCount; ++i) { var node = validNodes[i]; var nodeRect = node.getBBox(); if (nodeRect.height > this._layoutLabelHeight) { this._layoutLabelHeight = nodeRect.height; } } this._layoutSpillOver = this._layoutLabelHeight / 2; } return mode; } var originalDataLabelAccessor = (this._scale).originalDomainLabelAccessor(); var staggerStringsWontMatch = this._tickFormat && !originalDataLabelAccessor; var calcStagger = ((this._allowStagger && this._layoutMode == -1) || this._layoutMode == 3) && !staggerStringsWontMatch; var calcRotate45 = (this._allowRotate45 && this._layoutMode == -1) || this._layoutMode == 2; var calcRotate90 = (this._allowRotate90 && this._layoutMode == -1) || this._layoutMode == 1; var spaceFor45Label = 0; for (var i = 0; i < labelCount; ++i) { var node = validNodes[i]; var nodeRect = node.getBBox(); layoutLabelHeight = nodeRect.height; var labelWidth = nodeRect.width; if (labelWidth > layoutLabelWidth) { layoutLabelWidth = labelWidth; } horizontalScore += (labelWidth <= cellWidth ? 1 : cellWidth / labelWidth); if (isHorizontal) { if (calcStagger) { var spaceForLabel = cellWidth * 2; if (i == 0 && i == labelCount - 1) { spaceForLabel *= 0.5; } else if (i == 0 || i == labelCount - 1) { spaceForLabel *= 0.75; } staggerScore += (labelWidth <= spaceForLabel ? 1 : spaceForLabel / labelWidth); } if (calcRotate45) { if (spaceFor45Label == 0) { spaceFor45Label = cellWidth90 / 0.7071 - layoutLabelHeight; } var space = this.calculate45DegreeSpace(node, spaceFor45Label); rotate45Score += (labelWidth <= space ? 1 : space / labelWidth); } if (calcRotate90) { rotate90Score += (labelWidth <= cellWidth90 ? 1 : cellWidth90 / labelWidth); } } } var mode = 0; if (this._layoutMode == -1) { if (isHorizontal && this._allowStagger) { horizontalScore *= 1.1; staggerScore *= 1.1; } if ((staggerScore > horizontalScore) && (staggerScore >= rotate45Score) && (staggerScore >= rotate90Score)) { mode = 3; } else if ((rotate45Score > horizontalScore) && (rotate45Score >= rotate90Score)) { mode = 2; } else if (rotate90Score > horizontalScore) { mode = 1; } } else { if ((this._layoutMode == 3 && staggerStringsWontMatch) || !isHorizontal) { mode = 0; } else { mode = this._layoutMode; } } if (isHorizontal) { switch (mode) { case 3: this._layoutLabelSize = layoutLabelHeight * 2; break; case 2: this._layoutLabelSize = (layoutLabelWidth + layoutLabelHeight) * 0.7071; break; case 1: this._layoutLabelSize = layoutLabelWidth; break; case 0: default: this._layoutLabelSize = layoutLabelHeight; break; } } else { this._layoutLabelSize = layoutLabelWidth; } this._layoutLabelHeight = layoutLabelHeight; return mode; }, calculate45DegreeSpace : function(node, maxWidth) { var width = maxWidth; var tfm = node.rave_getParentNode().getAttribute("transform"); if (tfm != null) { var tfmString = tfm.toString(); var indexOfTrans = tfmString.indexOf("translate("); if (indexOfTrans != -1) { indexOfTrans += 10; var indexOfComma = tfmString.indexOf(",", indexOfTrans); if (indexOfComma != -1) { var xAmount = tfmString.substring(indexOfTrans, indexOfComma); var xLabelPos = + (xAmount); var width45Degrees = node.getBBox().width; var xLabelWidth = width45Degrees * 0.7071; var isBottom = this._orient == "bottom"; if (isBottom) { xLabelPos -= node.getBBox().height / 4; if (xLabelPos - xLabelWidth < this._bounds.x) { xLabelWidth = xLabelPos - this._bounds.x; width = xLabelWidth / 0.7071; } } else { if (xLabelPos + xLabelWidth > this._bounds.x + this._bounds.width) { xLabelWidth = (this._bounds.x + this._bounds.width) - xLabelPos; width = xLabelWidth / 0.7071; } } if (width > maxWidth) { width = maxWidth; } } } } return width; }, /** * @param (rave['internal']['Selector']) labels selector with all labels to be rotated * @param (rave['internal']['Selector']) g The parent selector of labels * @param (String) textAnchor The position of the anchor * @param alignmentMode One of HORIZONTAL, STAGGER, ROTATE45, ROTATE90 */ rotateLabels : function(g, labels, textAnchor, mode) { if (this._rotateLabels) { var self = this; var positioning = function(data, index, groupIndex) { var x = 0; var y = 0; var rotation_cy = 0; var isBottom = self._orient == "bottom"; if (mode == 3) { var cellIndex = self.getStaggerIndex(this); if (cellIndex != -1) { if (cellIndex % 2 == 1) { var staggerDirection = isBottom ? 1 : -1; y += (self._layoutLabelHeight * staggerDirection); } if (cellIndex == 0 && self._staggerAlignFirstAtStart) { x -= self._staggerCellWidth / 4; } else if (cellIndex == self.getStaggerCount() - 1 && self._staggerAlignLastAtEnd) { x += self._staggerCellWidth / 4; } } } else if (mode == 2) { if (isBottom) { x -= self._layoutLabelHeight; } else { x += self._layoutLabelHeight / 2; } } else if (mode == 1) { if (isBottom) { x -= (this.getBBox().height / 2 + self._layoutLabelHeight / 4); rotation_cy = ~~(self._padding / 4 + self._axis.tickSize()); } else { x -= (this.getBBox().height / 2 - self._layoutLabelHeight); rotation_cy = ~~-(self._padding / 4 + self._axis.tickSize()); } } var rotationDegrees = mode == 1 ? -90 : mode == 2 ? -45 : 0; return "translate(" + x + "," + y + ") rotate(" + rotationDegrees + ",0," + rotation_cy + ")"; }; labels.attr("transform", positioning).style("text-anchor", textAnchor); if (mode == 3) { if (this._staggerAlignFirstAtStart) { this._staggerFirstNode.rave_setStyle("text-anchor", "start"); } if (this._staggerAlignLastAtEnd) { this._staggerLastNode.rave_setStyle("text-anchor", "end"); } } } }, /** @expose */ axis : function() { return this._axis; }, /** * Draw the axis. The scale is non-null. * @param (rave['internal']['Selector']) g Selector group into which the axis is drawn. */ drawAxis : function(g) { var axisSelector = g.selectAll("g.axis").data([0]); axisSelector.enter().append("g").classed("axis", true).classed(this._orient, true); if (!this._axis) { this._axis = new rave['internal']['Axis'](); } if (this._hideOverlappingLabels) { this._textFlow.valignment("top").dropTextOnFail(false); } this._axis.ticksHandler(this._tickHandler); this._axis.orient(this._orient); this._axis.tickFormat(this._tickFormat); this._axis.tickPadding(10.0); if (this._scale.isOrdinal() || this._scale.isClustered()) { var labelHeight = 20.0; var isHorizontal = this._orient == "bottom" || this._orient == "top"; if (isHorizontal) { labelHeight /= 0.7071; } var range = this._scale.scale().rangeExtent(); var extent = + (range[1]) - + (range[0]); this._axis.ticks(extent / labelHeight); } else { if (this._tickMagnitude == null) { this._axis.ticks(10.0); } else { this._axis.ticks.apply(this._axis, [10.0, this._scale.scale().getTickFormat(), this._tickMagnitude]); } } var s = this._scale.scale(); if (this._scale.originalDomain()) { var sOrdinal = s.copy(); sOrdinal.domain(this._scale.originalDomain()); s = sOrdinal; var self = this; var originalDataLabelAccessor = (self._scale).originalDomainLabelAccessor(); var tickFormatter; if (originalDataLabelAccessor) { if (this._tickFormat) { tickFormatter = function(data, index, groupIndex) { return self._tickFormat.call(this, originalDataLabelAccessor.call(this, data, index, groupIndex), index, groupIndex); }; } else { tickFormatter = originalDataLabelAccessor; } } else { tickFormatter = this._tickFormat; } this._axis.tickFormat(tickFormatter); } this._axis.scale(s); axisSelector.call(this._axis); var g2 = rave.transition(axisSelector); if (!(g2.isTransition())) { axisSelector.selectAll("text").call(this._dropOverlap, this._hideOverlappingLabels); } axisSelector.selectAll("path.domain").classed("axis-line", true); axisSelector.selectAll("g.tick line").classed("axis-tick", true); if (this._fontChecker) { axisSelector.selectAll("g.tick text").classed("axis-label", true).call(this._fontChecker); } else { axisSelector.selectAll("g.tick text").classed("axis-label", true); } axisSelector.call(this._axisLineProperties); }, /** * Draw the axis title. * @param (rave['internal']['Selector']) g Selector group into which the title is drawn. */ drawTitle : function(g) { if (!this._displayAxisTitle || this._axisTitle == null || this._axisTitle.trim().length == 0 || !this._bounds) { g.selectAll("text.axis-title." + this._orient).remove(); return; } var x = 0; var y = 0; var dy = ""; var transform; if ("top" == this._orient) { x = this._elementRect.x + this._elementRect.width / 2; y = -this._bounds.height + this._padding / 4; dy = "0.75em"; } else if ("bottom" == this._orient) { x = this._elementRect.x + this._elementRect.width / 2; y = this._bounds.height - this._padding / 4; dy = "-0.25em"; } else if ("left" == this._orient) { x = -this._elementRect.y - this._elementRect.height / 2; y = -this._bounds.width + this._padding / 4; dy = "0.75em"; transform = "rotate(-90)"; } else { x = this._elementRect.y + this._elementRect.height / 2; y = -this._bounds.width + this._padding / 4; dy = "0.75em"; transform = "rotate(90)"; } var fillOpacity; { var tmp = g.append("text").attr("class", "axis-title " + this._orient); fillOpacity = tmp.style("fill-opacity"); tmp.remove(); } var label = g.selectAll("text.axis-title." + this._orient); if (label.size() == 0) { label.data([0]).enter().append("text").attr("class", "axis-title " + this._orient).style("text-anchor", "middle").attr("x", x).attr("y", y).attr("transform", transform).attr("dy", dy).style(this._titleStyle).text(this._axisTitle); if (this._fontChecker) { g.selectAll("text.axis-title." + this._orient).call(this._fontChecker); } } com_ibm_rave_bundles_utilities_TextCrossfader.textCrossFade(rave.transition(label), label.text(), this._axisTitle, fillOpacity, 0.25).style("text-anchor", "middle").attr("x", x).attr("y", y).attr("transform", transform).attr("dy", dy).style(this._titleStyle); }, getUnZoomedScale : function(scale) { var s = scale.copy(); if (s.getZoomTransform()) { s.getZoomTransform()(1, 0); } return s; }, isValid : function(data) { var s = this.getUnZoomedScale(this._axis.scale()); var v = + (s.call(null, data, 0, 0)); var range = this._axis.scale().range(); if (this._axis.scale().range().indexOf(v)> -1) { return true; } if (range[0] < v && v < range[1]) { return true; } if (range[0] > v && v > range[1]) { return true; } return false; }, /** * Apply label wrapping if requested. * @param (rave['internal']['Selector']) g * @param (int) mode One of HORIZONTAL, STAGGER, ROTATE45, ROTATE90 */ doLabelWrapping : function(g, mode) { if (this._displayTickLabels) { this._textFlow.valignment("top"); if (!this._hideOverlappingLabels) { this._textFlow.dropTextOnFail(true); } var d = this.labelExtent(g); if (!d || d[0] < 0 || d[1] < 0) { return; } var w = ~~ (d[0]); var h = ~~ (d[1]); if (mode == 2) { w = ~~(d[1] / 0.7071 - this._layoutLabelHeight); h = ~~(this._layoutLabelHeight / 0.7071); } else if (mode == 1) { var tmp = w; w = h; h = tmp; } var allowWrap = mode == 1; if (this._scale.isOrdinal() || this._scale.isClustered()) { var hActual = ~~ (this._layoutLabelHeight * 1.2); if (hActual > h) { h = hActual; } var isHorizontal = this._orient == "bottom" || this._orient == "top"; if (mode == 0 && !isHorizontal) { allowWrap = true; } } var self = this; var cellWidth = w; var cellHeight = h; this._textFlow.wrap(allowWrap).truncate(true).textTruncateIndicator(this._textTruncationIndicator != null ? this._textTruncationIndicator : "...").spacing(1.2).extent(function(data, index, groupIndex) { var width = cellWidth; var height = cellHeight; if (mode == 2) { var cellIndex = self.getStaggerIndex(this); if (cellIndex != -1) { width = ~~self.calculate45DegreeSpace(this, cellWidth); } } else if (mode == 3) { var cellIndex = self.getStaggerIndex(this); if (cellIndex != -1) { if (cellIndex == 0 && cellIndex == self.getStaggerCount() - 1) { width = cellWidth; } else if (cellIndex == 0 || cellIndex == self.getStaggerCount() - 1) { width = cellWidth * 3 / 2; } else { width = cellWidth * 2; } height = cellHeight / 2; } } return [width, height]; }); g.selectAll("g.tick > text").call(this._textFlow); } }, /** *Get the extent of the axis label bounds. If the axis bounds are non-null they are used as the axis bounds; otherwise the scale range and AXIS_LABEL_EXTENT_CONSTANT are used as the bounds.
If the axis scale has range bands, the label bounds are the size of the range bands in the dimension parallel to the axis and the size of the axis bounds in the other dimension. Otherwise the label bounds are the axis bounds.
If a title with non-empty text was created, the label bounds are reduced by the title font height in the dimension perpendicular to the axis (since the title is always placed at the edge of the bounds).
* @param (rave['internal']['Selector']) g Selector group for axis * @return (Array) The extent of the axis label bounds */ /** @expose */ labelExtent : function(g) { var isHorizontal = this._orient == "bottom" || this._orient == "top"; var w = this._bounds.width; var h = this._bounds.height; if (this._scale.scale().rangeBand) { var rangeBandValue = + (this._scale.scale().rangeBand()); if (isHorizontal) { w = rangeBandValue; } else { h = rangeBandValue; } } this.calcTitleExtent(g); if (isHorizontal) { h -= this._axis.tickSize(); h -= this._padding / 2; if (this._layoutTitleSize != 0) { h -= this._layoutTitleSize; h -= this._padding / 2; } } else { w -= this._axis.tickSize(); w -= this._padding / 2; if (this._layoutTitleSize != 0) { w -= this._layoutTitleSize; w -= this._padding / 2; } } return [w, h]; }, calcTitleExtent : function(g) { this._layoutTitleSize = 0; var title = g.selectAll("text.axis-title"); if (title.size() > 0) { var textHeight = title[0][0].getBBox().height; this._layoutTitleSize = textHeight; } }, /** * Set the role to one of the constants ROLE_X1 etc. defined in AxisComponent. * @param (String) role The new role * @return (com.ibm.rave.bundles.components.AxisComponentImpl) This object */ /** @expose */ setRole : function(role) { this._role = role; return this; }, /** * Set the ticks interval on the scale based on the magnitude. tickMagnitude represents power of 10. null value gives the default scale ticks. * @param (Number) tickMagnitude * @return (com.ibm.rave.bundles.component.AxisComponent) this */ /** @expose */ scaleTickMagnitude : function(tickMagnitude) { this._tickMagnitude = tickMagnitude; return this; }, /** * @param (rave['library']['internal']['CoordinateScaleImpl']) scale The new scale */ /** @expose */ scale : function(scale) { this._scale = scale ? scale : null; return this; }, /** * Only legal values are accepted, otherwise the orient is unchanged. * @param (String) orient The new orient */ orient$0 : function(orient) { if ("left" == orient || "bottom" == orient || "right" == orient || "top" == orient) { this._orient = orient; if (this._role == null) { if ("left" == orient) { this._role = "ROLE_Y1"; } else if ("bottom" == orient) { this._role = "ROLE_X1"; } else if ("right" == orient) { this._role = "ROLE_Y2"; } else { this._role = "ROLE_X2"; } } } return this; }, /** * Returns the current orientation string return The current orient */ orient$1 : function() { return this._orient; }, /** * @param (rave['internal']['RectStruct']) bounds The new bounds */ /** @expose */ bounds : function(bounds) { this._bounds = bounds; return this; }, /** @expose */ elementRect : function(elementRect) { this._elementRect = elementRect; return this; }, tickFormat$0 : function(tickFormat) { this._tickFormat = tickFormat; return this; }, tickFormat$1 : function() { return this._tickFormat; }, simplifiedTickFormat$0 : function(tickFormat) { this._simplifiedTickFormat = tickFormat; return this; }, simplifiedTickFormat$1 : function() { return this._simplifiedTickFormat; }, /** @expose */ displayAxisTitle : function(displayAxisTitle) { this._displayAxisTitle = displayAxisTitle; return this; }, /** @expose */ displayAxisLine : function(displayAxisLine) { this._displayAxisLine = displayAxisLine; return this; }, /** @expose */ displayTicks : function(displayTicks) { this._displayTicks = displayTicks; return this; }, /** @expose */ displayTickLabels : function(displayTickLabels) { this._displayTickLabels = displayTickLabels; return this; }, /** @expose */ allowAutomaticAxisLayoutToChangeOrientation : function(state) { this._allowAutoAxisLayoutToChangeOrientaiton = state; return this; }, /** @expose */ isAllowAutomaticAxisLayoutToChangeOrientation : function() { return this._allowAutoAxisLayoutToChangeOrientaiton; }, /** @expose */ showPanZoomTickLabels : function(showPanZoomTickLabels) { this._showPanZoomTickLabels = showPanZoomTickLabels; return this; }, /** @expose */ axisTitle : function(axisTitle) { this._axisTitle = axisTitle; return this; }, /** @expose */ axisColor : function(axisColor) { this._lineColor = axisColor; this._tickColor = axisColor; return this; }, /** @expose */ lineColor : function(lineColor) { this._lineColor = lineColor; return this; }, /** @expose */ tickColor : function(tickColor) { this._tickColor = tickColor; return this; }, /** @expose */ labelColor : function(labelColor) { this._labelStyle["fill"] = labelColor; return this; }, labelStyle$0 : function(fill, fontSize, fontFamily) { this._labelStyle["fill"] = fill; this._labelStyle["font-size"] = fontSize; this._labelStyle["font-family"] = fontFamily; return this; }, /** @expose */ titleColor : function(titleColor) { this._titleStyle["fill"] = titleColor; return this; }, titleStyle$0 : function(fill, fontSize, fontFamily) { this._titleStyle["fill"] = fill; this._titleStyle["font-size"] = fontSize; this._titleStyle["font-family"] = fontFamily; return this; }, /** * @param (int) padding The new padding */ /** @expose */ padding : function(padding) { this._padding = padding; return this; }, /** * @param mode LayoutMode for axis, one of: null (numeric axis), automatic, horizontal, stagger, rotate45, rotate90 */ /** @expose */ layoutMode : function(layoutMode) { this._layoutMode = -1; if (layoutMode != null) { if (layoutMode == "horizontal") { this._layoutMode = 0; } else if (layoutMode == "stagger") { this._layoutMode = 3; } else if (layoutMode == "rotate45") { this._layoutMode = 2; } else if (layoutMode == "rotate90") { this._layoutMode = 1; } } return this; }, /** * @param (boolean) allow Enable Stagger to be considered in the automatic layout algorithm */ /** @expose */ allowStagger : function(allow) { this._allowStagger = allow; return this; }, /** * @param (boolean) allow Enable Rotate 45 to be considered in the automatic layout algorithm */ /** @expose */ allowRotate45 : function(allow) { this._allowRotate45 = allow; return this; }, /** * @param (boolean) allow Enable Rotate 90 to be considered in the automatic layout algorithm */ /** @expose */ allowRotate90 : function(allow) { this._allowRotate90 = allow; return this; }, /** * @return (boolean) True if on the last call the axis rendered shapes, false otherwise */ renderedShapes : function() { return this._renderedShapes; }, labelStyle$1 : function(fontStyle) { this._labelStyle = com_ibm_rave_bundles_utilities_FontPropertyParser.parseCSSFont(fontStyle); return this; }, titleStyle$1 : function(fontStyle) { this._titleStyle = com_ibm_rave_bundles_utilities_FontPropertyParser.parseCSSFont(fontStyle); return this; }, /** * Determines whether the axis is swapped. * @return (boolean) True if axis is swapped */ isAxisSwapped : function() { return (((this._role == "ROLE_Y1" || this._role == "ROLE_Y2") && (this._orient == "top" || this._orient == "bottom")) || ((this._role == "ROLE_X1" || this._role == "ROLE_X2") && (this._orient == "right" || this._orient == "left"))); }, /** *Set the indicator to be used for truncated text
ex: indicator set to "..." , results in helloworld - > hello...
If the indicator is not set the default indicator "..." is used
* @param (String) indicator the string to be placed to indicated truncated text * @return (com.ibm.rave.bundles.component.AxisComponent) This component */ /** @expose */ textTruncateIndicator : function(indicator) { this._textTruncationIndicator = indicator; return this; }, /** * If at least one label collision request is pending we stop the label collision component, and shut down the label collision timer event. */ stopLabelDroppingUpdate : function() { this._pendingLabelTimer = false; }, /** * Start Rave timers with a delay of half the transition duration and the full transition duration. This will fire the label dropping at the halfway mark and at the end. * @param (rave['internal']['Selector']) labels the selection of valid labels for the end of the transition * @param (double) duration of the transition. If 0, we don't do anything. * @param (double) delay of the transition. Added to the duration to delay the updates. */ updateLabelDropping : function(labels, duration, delay) { var self = this; var start = delay + duration; var labelCollideCallback = function(elapsed) { if (!self._pendingLabelTimer) { return true; } labels.call(self._dropOverlap, self._hideOverlappingLabels); if (elapsed >= start) { self._pendingLabelTimer = false; return true; } return false; }; if (duration > 0) { this._pendingLabelTimer = true; rave.timer(labelCollideCallback, start); } }, doLabelWrappingAfterAnimation : function(g, labels, mode, duration, delay) { this._layoutTimerId++; var timerId = this._layoutTimerId; var self = this; var wrapCallback = function(elapsed) { if (self._layoutTimerId == timerId) { self.doLabelWrapping(g, mode); self.handleLabelsRotationAndPosition(g, labels, mode); } return true; }; rave.timer(wrapCallback, delay + duration); }, /** @expose */ preLayout : function() { this._layoutTitleSize = 0; this._layoutLabelSize = 0; this._layoutLabelHeight = 0; this._layoutAverageDigitWidth = 0; this._layoutSpillOver = 0; }, /** @expose */ getSizableType : function() { return this._scale.isOrdinal() || this._scale.isClustered() ? 1 : 0; }, /** @expose */ getSizableOrientation : function() { return this._orient; }, /** @expose */ getPreferredSize : function() { var layoutPaddingSize = 0; if (this._axis) { layoutPaddingSize = this._axis.tickSize(); if (this._layoutLabelSize != 0) { layoutPaddingSize += this._padding / 2; } if (this._layoutTitleSize != 0) { layoutPaddingSize += this._padding / 2; } } return this._layoutLabelSize + this._layoutAverageDigitWidth + this._layoutTitleSize + layoutPaddingSize + 2; }, /** @expose */ getSpillOverSize : function() { return this._layoutSpillOver; }, /** @expose */ orient : function(a0) { var args = arguments; if (args.length == 0) { return this.orient$1(); } return this.orient$0(a0); }, /** @expose */ tickFormat : function(a0) { var args = arguments; if (args.length == 0) { return this.tickFormat$1(); } return this.tickFormat$0(a0); }, /** @expose */ simplifiedTickFormat : function(a0) { var args = arguments; if (args.length == 0) { return this.simplifiedTickFormat$1(); } return this.simplifiedTickFormat$0(a0); }, /** @expose */ labelStyle : function(a0, a1, a2) { var args = arguments; if (args.length == 1) { return this.labelStyle$1(a0); } return this.labelStyle$0(a0, a1, a2); }, /** @expose */ titleStyle : function(a0, a1, a2) { var args = arguments; if (args.length == 1) { return this.titleStyle$1(a0); } return this.titleStyle$0(a0, a1, a2); } }); /** * Given the bounds for the axis and the orientation, return the [x,y] translation for the group containing the axis. These are the usual settings for d3 (RAVE core) axes, where the axis range (pixels) is in the global coordinates, then the axis is moved perpendicular to that to place it next to the chart. * @param (rave['internal']['RectStruct']) bounds Rectangle of the axis bounds * @param (String) orient Orient, "top", "bottom", "left", "right"; if not valid, "bottom" used * @return (double[]) Translation [x,y] */ /** @expose */ com_ibm_rave_bundles_components_AxisComponentImpl.getTranslation = function(bounds, orient) { if ("left" == orient) { return [bounds.x + bounds.width, 0.0]; } if ("right" == orient) { return [bounds.x, 0.0]; } if ("top" == orient) { return [0.0, bounds.y + bounds.height]; } return [0.0, bounds.y]; }; com_ibm_rave_bundles_components_AxisComponentImpl.NodeIndex = rave['internal']['Declare']({ //_node : null, _domainIndex : 0, /** @expose */ constructor : function(node, domainIndex) { this._node = node; this._domainIndex = domainIndex; }, /** @expose */ contains : function(node) { return node == this._node; }, /** @expose */ getIndex : function() { return this._domainIndex; } }); /** * Tick Handler for the axis. This will get called as the core axis is transitioned. */ com_ibm_rave_bundles_components_AxisComponentImpl.AxisTickHandler = rave['internal']['Declare'](rave['internal']['AbstractTickHandler'], { //_label : null, //_tick : null, _$functionClassMethod : function() { var _$self = function(args) { if (args !== null || arguments.length > 1){ args = Array.prototype.slice.call(arguments, 0); } { _$self.handle(args[0]); return null; } }; return _$self; }, constructor : function(label, tick) { this._label = label; this._tick = tick; }, /** @expose */ handle : function(ticks) { ticks.call(this._tick); ticks.call(this._label); } }); //com_ibm_rave_bundles_components_AxisComponentImpl.VISIBILITY = "visibility"; //com_ibm_rave_bundles_components_AxisComponentImpl.HIDDEN = "hidden"; /** @expose */ com_ibm_rave_bundles_components_AxisComponentImpl.LABEL_HIDDEN_FLAG = "__tickLabelHidden__"; /** @expose */ com_ibm_rave_bundles_components_AxisComponentImpl.PANZOOM_HIDDEN_FLAG = "__panZoomHidden__"; /** @expose */ com_ibm_rave_bundles_components_AxisComponentImpl.HIDDEN_COUNT = "__hiddenCount__"; /** @expose */ com_ibm_rave_bundles_components_AxisComponentImpl.PREFERRED_SPACE_PER_TICK = 20; /** @expose */ com_ibm_rave_bundles_components_AxisComponentImpl.PREFERRED_TICK_COUNT = 10; /** @expose */ com_ibm_rave_bundles_components_AxisComponentImpl.TICK_PADDING = 10; //com_ibm_rave_bundles_components_AxisComponentImpl.HORIZONTAL_WEIGHT = 1.1; com_ibm_rave_bundles_components_AxisComponentImpl.HORIZONTAL = 0; com_ibm_rave_bundles_components_AxisComponentImpl.ROTATE90 = 1; com_ibm_rave_bundles_components_AxisComponentImpl.ROTATE45 = 2; com_ibm_rave_bundles_components_AxisComponentImpl.STAGGER = 3; /** * Constant used for text flow spacing */ com_ibm_rave_bundles_components_AxisComponentImpl.TEXTFLOW_SPACING = 1.2; /** * Bottom axis orientation string. */ /** @expose */ com_ibm_rave_bundles_components_AxisComponentImpl.BOTTOM_ORIENTATION = "bottom"; /** * Top axis orientation string. */ /** @expose */ com_ibm_rave_bundles_components_AxisComponentImpl.TOP_ORIENTATION = "top"; /** * Left axis orientation string. */ /** @expose */ com_ibm_rave_bundles_components_AxisComponentImpl.LEFT_ORIENTATION = "left"; /** * Right axis orientation string. */ /** @expose */ com_ibm_rave_bundles_components_AxisComponentImpl.RIGHT_ORIENTATION = "right"; com_ibm_rave_bundles_components_AxisComponentImpl.AUTOMODE = -1; // $source: com/ibm/rave/bundles/components/GridComponentImpl /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017 ** ** 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. ************************************************************************/ // GENERATED //@import com/ibm/rave/bundles/components/BundleComponentImpl (loadtime) // superclass //@import com/ibm/rave/bundles/components/StyleStructs (runtime) // new //@import com/ibm/rave/bundles/component/GridComponent (runtime) // GridComponent /** *Component to draw gridlines for an axis. The component is drawn into a Selector group, and the user of the component must translate the group to the axis position. Gridlines are created using the axis, setting the tick size to the dimension of the gridline space. For correct behavior the gridline component should be called after the axis has been called.
The properties are:
axis: The axis to use. If null, no gridlines are drawn. Default null.
orient: The axis orientation, one of "top", "bottom", "left", "right". Default "bottom".
bounds: A rectangle bounding the gridline area, used to find the line length. If null, no gridlines are drawn. Default null.
displayGridlines: Whether to draw the gridlines. Default false.
gridlineColor: A color-string for the grid lines. If null, no color is applied and the CSS defaults are used. Default null.
*/ var com_ibm_rave_bundles_components_GridComponentImpl = rave['internal']['Declare'](com_ibm_rave_bundles_components_BundleComponentImpl, { /** * The axis property */ //_axis : null, /** * Role, from the AxisComponent API */ //_role : null, /** * The orientation */ //_orient : null, /** * The bounds */ //_bounds : null, /** * Style of gridlines */ //_gridlineStyle : null, /** * Whether to display gridlines */ _displayGridlines : false, /** * After calling the component, this is true if shapes were rendered, false if they were cleared. */ _renderedShapes : false, /** * Construct, with all properties the defaults. */ /** @expose */ constructor : function() { this._axis = null; this._role = null; this._orient = "bottom"; this._bounds = null; this._displayGridlines = true; this._gridlineStyle = new com_ibm_rave_bundles_components_StyleStructs.LineStyle(); this._renderedShapes = false; }, /** @expose */ type : function() { return com_ibm_rave_bundles_component_GridComponent.COMPONENT_TYPE; }, /** @expose */ role : function() { return this._role; }, /** @expose */ execute : function(g) { this.preExecute(); if (!this._displayGridlines || !this._axis || !this._bounds) { g.selectAll("*").remove(); this._renderedShapes = false; return; } this._renderedShapes = true; var size = ("bottom" == this._orient || "top" == this._orient) ? this._bounds.height : this._bounds.width; var ticksHandler = this._axis.ticksHandler(); var tickSize = this._axis.tickSize(); var outerTickSize = this._axis.outerTickSize(); var tickFormat = this._axis.tickFormat(); var ax = this._axis.tickSize(-size, 0).tickFormat("").ticksHandler(null); g.call(ax); this._axis.tickSize(tickSize, outerTickSize).tickFormat(tickFormat).ticksHandler(ticksHandler); g.selectAll("g.tick line").classed("grid-tick", true); g.selectAll(".grid-tick").style("stroke", this._gridlineStyle._stroke).style("stroke-dasharray", (this._gridlineStyle._dashArray)); g.selectAll("path.domain").remove(); }, /** * @param (rave['internal']['Axis']) axis The new axis */ /** @expose */ axis : function(axis) { this._axis = axis; return this; }, /** * Set the role to one of the constants ROLE_X1 etc. defined in AxisComponent. * @param (String) role The new role * @return (com.ibm.rave.bundles.components.GridComponentImpl) This object */ /** @expose */ setRole : function(role) { this._role = role; return this; }, /** * Only legal values are accepted, otherwise the orient is unchanged. * @param (String) orient The new orient */ orient$0 : function(orient) { if ("left" == orient || "right" == orient || "bottom" == orient || "top" == orient) { this._orient = orient; } return this; }, /** * @param (rave['internal']['RectStruct']) bounds The new bounds */ /** @expose */ bounds : function(bounds) { this._bounds = bounds; return this; }, displayGridlines$0 : function(displayGridlines) { this._displayGridlines = displayGridlines; return this; }, /** @expose */ gridlineStyle : function(gridlineColor, dashArray) { this.gridlineColor(gridlineColor); this.dashArray(dashArray); return this; }, gridlineColor$0 : function(gridlineColor) { this._gridlineStyle._stroke = (gridlineColor != null && gridlineColor.length > 0) ? gridlineColor : null; return this; }, dashArray$0 : function(dashArray) { this._gridlineStyle._dashArray = (dashArray != null && dashArray.length > 0) ? dashArray : null; return this; }, /** * @return (String) The orientation of the gridline. */ orient$1 : function() { return this._orient; }, displayGridlines$1 : function() { return this._displayGridlines; }, gridlineColor$1 : function() { return this._gridlineStyle._stroke; }, dashArray$1 : function() { return this._gridlineStyle._dashArray; }, /** * @return (boolean) True if on the last call the axis rendered shapes, false otherwise */ renderedShapes : function() { return this._renderedShapes; }, /** @expose */ orient : function(a0) { var args = arguments; if (args.length == 0) { return this.orient$1(); } return this.orient$0(a0); }, /** @expose */ displayGridlines : function(a0) { var args = arguments; if (args.length == 0) { return this.displayGridlines$1(); } return this.displayGridlines$0(a0); }, /** @expose */ gridlineColor : function(a0) { var args = arguments; if (args.length == 0) { return this.gridlineColor$1(); } return this.gridlineColor$0(a0); }, /** @expose */ dashArray : function(a0) { var args = arguments; if (args.length == 0) { return this.dashArray$1(); } return this.dashArray$0(a0); } }); // $source: com/ibm/rave/bundles/nativeImpl/components/TiledmapV2NativeSubComponentImpl /************************************************************************ ** IBM Confidential ** ** IBM Business Analytics: Rapidly Adaptive Visualization Engine ** ** (C) Copyright IBM Corp. 2017,2020 ** ** 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. ************************************************************************/ // Add javascript dependencies // @import ./TiledmapV2FeatureDataMap // @import ./TiledmapV2MapDataCache var com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl = ( function() { var reLayerError = /source layer "([^"]+)".*on source "([^"]+)".*style layer "([^"]+)"/i; var reNameField = /^\{name/; var FILTER_NONE = false; /** * Returns the optimized bounding box of a geoJSON object. * It balances returning the minimal bounding box containing all coordinates of the passed geoJSON object * with keeping the map oriented on the Atlantic ocean if the bounding box stretches more then 3/4 of the world. * @param {Object} _geo geoJSON object. * @param {Array} _bbox (optional) existing bounding box. * @returns {Array} The bounding box of the _geo object. If an existing * bounding box was specified in _bbox, then this object is modified and * returned. This allows chaining the function for multiple objects. */ function getBalancedBoundingBox( _geo, _bbox ) { var coords = flattenCoords( _geo ); var minbbox = _bbox ? [ _bbox[0], _bbox[1], _bbox[2], _bbox[3] ] : [ Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY ]; var bbox = _bbox ? [ _bbox[0], _bbox[1], _bbox[2], _bbox[3] ] : [ Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY ]; // Calculate both the minimal bounding box and a regular bounding box for ( var i = coords.length - 1; i >= 0; --i ) { var coord = coords[ i ]; var coord0 = coord[ 0 ]; if ( coord0 - minbbox[ 0 ] < 0 ) { // Coordinate is on the left side of the bounding box. if ( coord0 + 360 - minbbox[ 2 ] < minbbox[ 0 ] - coord0 ) coord0 += 360; // adjust x-coordinate } else if ( coord0 - minbbox[ 2 ] > 0 ) { // Coordinate is on the right side of the bounding box. if ( minbbox[ 0 ] - coord0 + 360 < coord0 - minbbox[ 2 ] ) coord0 -= 360; // adjust x-coordinate } // Update horizontal for minimal bounding box minbbox[ 0 ] = Math.min( coord0, minbbox[ 0 ] ); minbbox[ 2 ] = Math.max( coord0, minbbox[ 2 ] ); // Update vertical for minimal bounding box minbbox[ 1 ] = Math.min( coord[ 1 ], minbbox[ 1 ] ); minbbox[ 3 ] = Math.max( coord[ 1 ], minbbox[ 3 ] ); // Update regular bounding box bbox[ 0 ] = Math.min( coord[ 0 ], bbox[ 0 ] ); bbox[ 1 ] = Math.min( coord[ 1 ], bbox[ 1 ] ); bbox[ 2 ] = Math.max( coord[ 0 ], bbox[ 2 ] ); bbox[ 3 ] = Math.max( coord[ 1 ], bbox[ 3 ] ); } // RTC 190107 demands favoring the Atlantic ocean, when showing the map // The minbbox determines the minimal bounding box of the passed coordinates. // The mechanism used to determine the minbbox has the disadvantage that the minbbox might move // the center of the coordinates with wide selections (spanning a large part of the world). // In general an orientation over Greenwich is preferred. // Check if the bounding box stretches more then 3/4 of the world, in that case, use the regular bbox // (which seems to resort to the world view farily quickly) var bbExtend = minbbox[ 2 ] - minbbox[ 0 ]; if ( bbExtend > 270 ) return bbox; // If our minimal bounding box stretches 2/3 of the world and is completely left or right of Greenwich (Longitude = 0), // use the regular bbox if ( ( bbExtend > 240 ) && ( ( ( minbbox[ 0 ] < -180 ) && ( minbbox[ 2 ] < 0 ) ) || ( ( minbbox[ 2 ] > 180 ) && ( minbbox[ 0 ] > 0 ) ) ) ) return bbox; return minbbox; } /** * Returns a flat list of coordinates contained within a geoJSON object. * @param {Object} _geo geoJSON object. * @returns {Array} A flat array of coordinates. */ function flattenCoords( _geo ) { var src, src2, dest; var i, j, len; switch ( _geo.type.toLowerCase() ) { case "point": return [ _geo.coordinates ]; case "linestring": case "multipoint": return _geo.coordinates; case "polygon": case "multilinestring": src = _geo.coordinates; for ( dest = [], i = 0, len = src.length; i < len; ++i ) dest.push.apply( dest, src[ i ] ); return dest; case "multipolygon": src = _geo.coordinates; for ( dest = [], i = 0, len = src.length; i < len; ++i ) for ( src2 = src[ i ], j = 0; j < src2.length; ++j ) dest.push.apply( dest, src2[ j ] ); return dest; case "feature": return flattenCoords( _geo.geometry ); case "geometrycollection": src = _geo.geometries; for ( dest = [], i = 0, len = src.length; i < len; ++i ) dest.push.apply( dest, flattenCoords( src[ i ] ) ); return dest; case "featurecollection": src = _geo.features; for ( dest = [], i = 0, len = src.length; i < len; ++i ) dest.push.apply( dest, flattenCoords( src[ i ] ) ); return dest; default: return []; } } function setMaxTileCacheSize( _mapOptions ) { var ua = typeof navigator !== "undefined" ? navigator.userAgent : ""; // IE <= 10 || IE 11 var isIE = ua.indexOf( 'MSIE ' ) >= 0 || ua.indexOf( 'Trident/' ) >= 0; if ( isIE ) { _mapOptions.maxTileCacheSize = 6; } } function easing( _t ) { return _t * (2 - _t); } //Constructor function com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl(node) { this._featureDataMap = new com_ibm_rave_bundles_nativeImpl_components_TiledmapV2FeatureDataMap(); this._mapCache = new com_ibm_rave_bundles_nativeImpl_components_TiledmapV2MapDataCache(); this._mapCacheVersion = this._mapCache.version; this._map = null; this._nls = null; this._mapLoaded = false; this._mapboxToken = ""; this._mapboxStyle = "mapbox://style/mapbox/streets-v9"; this._mapboxStyleDirty = true; this._mapboxDataDirty = true; this._mapBBox = null; this._containerRect = { // Default rect struct. The width and height are based on the defaults for the D3/Rave Core mercator projection size. x: 0, y: 0, width: 960, height: 500 }; this._svg = null; this._mapContainer = null; this._selectedItems = rave.set(); // list of polygons that are currently selected this._addedResources = rave.map(); // List added sources and layers this._highlights = { items: [] }; // list of polygons that are currently highlighted this._dataLayers = []; this._mapLocale = "en"; this._styleDataCache = rave.map(); this._maxPointSize = null; // maxZoom handling this._maxZoom = null; this._zoomStart = null; this._zoomStartHandler = null; this._zoomEndHandler = null; this._maxZoomCallbacks = []; this._mappingErrorCallbacks = []; this._autoZoom = true; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.draw = function( _svg ) { // console.debug( "TiledMap::draw" ); // // integrators current pass RAVE an svg element for rendering // mapbox renders inside a div // we still need the svg element for rendering the legend // the strategy here is to create a sibling div to the svg element and let mapbox draw there var self = this; // set the mapbox access token mapboxgl.accessToken = this._mapboxToken; // TODO: Could go in the constructor? // get access to the root SVG element this._svg = _svg; var svgOwner = rave.select( this._svg.node().parentNode ); // add a new container for both mapbox canvas and chart (legend) SVG var containerNode = svgOwner.append( "div" ) .classed( "vizlibrary-tiledmap", true ) .classed( "tiledmap-container", true ) .style( "position", "relative" ) .style( "width", "100%" ) .style( "height", "100%" ); // create mapContainer this._mapContainer = containerNode.append( "div" ) .style( "position", "absolute" ) .style( "text-align", "left" ) // dashboards needs this for now .style( "left", this._containerRect.x + "px" ) .style( "top", this._containerRect.y + "px" ) .style( "width", this._containerRect.width + "px" ) .style( "height", this._containerRect.height + "px" ); // re-parent and style the svg containerNode.node().appendChild( this._svg.node() ); this._svg.style( "position", "absolute" ) .style( "top","0px" ) .style( "left","0px" ) .style( "pointer-events", "none" ); // Prevent pointer events on the svg container itself. The child svg nodes can have events enabled if needed. var options = { container: this._mapContainer.node(), attributionControl: false, style: this._mapboxStyle }; setMaxTileCacheSize( options ); // create the mapbox control this._map = new mapboxgl.Map( options ); // Currently not supporting mapbox rotation. this._map.dragRotate.disable(); this._map.addControl(new mapboxgl.NavigationControl()); // add attribution control this._map.addControl( new mapboxgl.AttributionControl( { compact: true } ), "bottom-right" ); var onStyleLoaded = function() { self._applyMapLocale(); // a style load causes all layers to be reset as well, reset loaded tilesets if ( self._mapboxStyleDirty ) self._addedResources = rave.map(); else self._clearAddedResources(); self._mapboxStyleDirty = false; self._loadLayers(); // reset zoom when data was dropped if ( self._autoZoom && self._mapboxDataDirty && ( self._featureDataMap.size() === 0 ) ) self._map.setZoom(0); // check delayed bounding box if ( self._mapBBox ) { self._fitBounds( self._mapBBox ); self._mapBBox = null; } // re-apply selections and highlights if ( self._selectedItems.size() ) self._updateSelectedItemFilters(); if ( self._highlights.items.length ) self.highlightAction( self._highlights ); self._mapboxDataDirty = false; } this._map.on( "style.load", function() { // if the map hasn't loaded yet, postpone style.load handling if ( self._mapLoaded ) onStyleLoaded(); else self._map.once( "load", onStyleLoaded ); } ); this._map.on( "load", function() { // mark map loaded self._mapLoaded = true; } ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.fire = function( _type ) { // console.debug( "TiledMap::fire - " + _type ); this._map.fire( _type ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._loadLayers = function() { // console.debug( "TiledMap::_loadLayers" ); var self = this; var styleData = this._styleDataCache.get( this._mapboxStyle ); var filter; if ( !styleData || ( this._featureDataMap.size() === 0 ) ) return; // to make sure the layers are added in the correct order [ "region", "point" ].forEach( function( _type ) { // iterate tilesets self._featureDataMap.getTileSets( { type: _type } ).forEach( function( _tileSet ) { // add tileset source if ( !self._map.getSource( _tileSet.id ) ) { var source = { type: _tileSet.tileType }; var actionSourceId = null; switch ( _tileSet.tileType ) { case "vector": filter = self._featureDataMap.getMapFilter( _tileSet ); source.url = "mapbox://" + _tileSet.id; self._map.addSource( _tileSet.id, source ); self._addResource( { type: "source", tileType: _tileSet.tileType, id: _tileSet.id } ); // vector layers get an additional source for hover/select/focus actions actionSourceId = _tileSet.id + "Action"; self._map.addSource( actionSourceId, source ); self._addResource( { type: "source", tileType: _tileSet.tileType, id: actionSourceId } ); break; case "geojson": source.data = { type: "FeatureCollection", features: self._featureDataMap.getFeatures( _tileSet.id ) }; self._map.addSource( _tileSet.id, source ); self._addResource( { type: "source", tileType: _tileSet.tileType, id: _tileSet.id } ); break; } } // check for region if ( _tileSet.polyLayer ) { var polyLayerId = _tileSet.polyLayer; if ( _tileSet.tileType === "vector" ) { // setup fill layer if ( !self._map.getLayer( polyLayerId ) ) { // console.debug( "- addLayer: " + polyLayerId ); self._map.addLayer( { "id": polyLayerId, "type": "fill", "source": _tileSet.id, "source-layer": _tileSet.sourceLayer, "paint": { "fill-opacity": 1 - ( _tileSet.transparency / 100.0 ) } }, styleData.baseLayer ); self._addResource( { type: "layer", source: _tileSet.id, tileType: _tileSet.tileType, id: polyLayerId } ); if ( filter ) { self._map.setFilter( polyLayerId, filter ); } } // setup focus layer layerId = polyLayerId + "Focus"; if ( !self._map.getLayer( layerId ) ) { // console.debug( "- addLayer: " + layerId ); self._map.addLayer( { "id": layerId, "type": "fill", "source": actionSourceId, "source-layer": _tileSet.sourceLayer, "paint": { "fill-opacity": 1 }, "filter": [ "==", _tileSet.property, FILTER_NONE ] }, styleData.baseLayer ); self._addResource( { type: "layer", source: actionSourceId, tileType: _tileSet.tileType, id: layerId } ); } // setup select layer layerId = polyLayerId + "Select"; if ( !self._map.getLayer( layerId ) ) { // console.debug( "- addLayer: " + layerId ); self._map.addLayer( { "id": layerId, "type": "line", "source": actionSourceId, "source-layer": _tileSet.sourceLayer, "paint": { "line-width": 2, "line-opacity": 1 }, "filter": [ "==", _tileSet.property, FILTER_NONE ] }, styleData.baseLayer ); self._addResource( { type: "layer", source: actionSourceId, tileType: _tileSet.tileType, id: layerId } ); } // setup hover layer layerId = polyLayerId + "Hover"; if ( !self._map.getLayer( layerId ) ) { // console.debug( "- addLayer: " + layerId ); self._map.addLayer( { "id": layerId, "type": "line", "source": actionSourceId, "source-layer": _tileSet.sourceLayer, "paint": { "line-width": 2, "line-opacity": 1 }, "filter": [ "==", _tileSet.property, FILTER_NONE ] }, styleData.baseLayer ); self._addResource( { type: "layer", source: actionSourceId, tileType: _tileSet.tileType, id: layerId } ); } } else if ( _tileSet.tileType === "geojson" ) { // add placeholder layer (regions with only location information) layerId = polyLayerId; if ( !self._map.getLayer( layerId ) ) { // console.debug( "- addLayer: " + pointLayerId ); self._map.addLayer( { "id": layerId, "type": "circle", "source": _tileSet.id, "paint": { "circle-opacity": 1 - ( _tileSet.transparency / 100.0 ), "circle-radius": 10, "circle-stroke-width": 0 } }, styleData.baseLayer ); self._addResource( { type: "layer", source: _tileSet.id, tileType: _tileSet.tileType, id: layerId } ); } // setup focus layer layerId = polyLayerId + "Focus"; if ( !self._map.getLayer( layerId ) ) { // console.debug( "- addLayer: " + pointLayerId ); self._map.addLayer( { "id": layerId, "type": "circle", "source": _tileSet.id, "paint": { "circle-opacity": 1 - ( _tileSet.transparency / 100.0 ), "circle-radius": 10, "circle-stroke-width": 0 } }, styleData.baseLayer ); self._addResource( { type: "layer", source: _tileSet.id, tileType: _tileSet.tileType, id: layerId } ); } // setup select layer layerId = polyLayerId + "Select"; if ( !self._map.getLayer( layerId ) ) { // console.debug( "- addLayer: " + layerId ); self._map.addLayer( { "id": layerId, "type": "circle", "source": _tileSet.id, "paint": { "circle-opacity": 0, "circle-radius": 10, "circle-stroke-width": 2 }, "filter": [ "==", _tileSet.property, FILTER_NONE ] }, styleData.baseLayer ); self._addResource( { type: "layer", source: _tileSet.id, tileType: _tileSet.tileType, id: layerId } ); } // setup hover layer layerId = polyLayerId + "Hover"; if ( !self._map.getLayer( layerId ) ) { // console.debug( "- addLayer: " + layerId ); self._map.addLayer( { "id": layerId, "type": "circle", "source": _tileSet.id, "paint": { "circle-opacity": 0, "circle-radius": 10, "circle-stroke-width": 2 }, "filter": [ "==", _tileSet.property, FILTER_NONE ] }, styleData.baseLayer ); self._addResource( { type: "layer", source: _tileSet.id, tileType: _tileSet.tileType, id: layerId } ); } } } // check for point if ( _tileSet.pointLayer ) { var pointLayerId = _tileSet.pointLayer; var layerDef; // add pointlayer if ( !self._map.getLayer( pointLayerId ) ) { // console.debug( "- addLayer: " + pointLayerId ); layerDef = { "id": pointLayerId, "type": "circle", "source": _tileSet.id, "paint": { "circle-opacity": 1 - ( _tileSet.transparency / 100.0 ), "circle-radius": 10, "circle-stroke-width": 2 } }; if ( _tileSet.sourceLayer ) layerDef[ "source-layer" ] = _tileSet.sourceLayer; self._map.addLayer( layerDef, styleData.baseLayer ); self._addResource( { type: "layer", source: _tileSet.id, tileType: _tileSet.tileType, id: pointLayerId } ); } // setup hover layer layerId = pointLayerId + "Hover"; if ( !self._map.getLayer( layerId ) ) { // console.debug( "- addLayer: " + layerId ); layerDef = { "id": layerId, "type": "circle", "source": _tileSet.id, "paint": { "circle-opacity": 0, "circle-radius": 10, "circle-stroke-width": 2 }, "filter": [ "==", _tileSet.property, FILTER_NONE ] }; if ( actionSourceId ) layerDef[ "source" ] = actionSourceId; else layerDef[ "source" ] = _tileSet.id; if ( _tileSet.sourceLayer ) layerDef[ "source-layer" ] = _tileSet.sourceLayer; self._map.addLayer( layerDef, styleData.baseLayer ); self._addResource( { type: "layer", source: layerDef[ "source" ], tileType: _tileSet.tileType, id: layerId } ); } } } ); } ); // setup the layer stops self._setupLayerStops(); // set the bounding box, only when the data (DataPoints and MapBox data) has changed and autoZoom is enabled // otherwise maintain the current zoom state. if ( this._autoZoom && this._mapboxDataDirty ) self._setBbox(); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._setBbox = function() { // console.debug( "TiledMap::_setBbox" ); var self = this; // determine if all tileSets have coordinates var allTileSetsHaveCoordinates = this._featureDataMap.getTileSets().every( function( _tileSet ) { if ( ( _tileSet.tileType === "geojson" ) || ( self._featureDataMap.getFeatures( _tileSet.id ).length > 0 ) ) return true; return false; } ); // zoom to world when there are features without coordinates if ( !allTileSetsHaveCoordinates ) this._map.setZoom(0); this._map.on('render',afterChangeComplete); function afterChangeComplete() { if( !self._map.loaded() ) return; // still not loaded // safe to query for features self._setBboxFeatures(); self._map.off( "render", afterChangeComplete ); // remove the handler we don't need it anymore } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._setBboxFeatures = function() { // console.debug( "TiledMap::_setBboxFeatures" ); var featureSet = []; var self = this; this._featureDataMap.getTileSets().forEach( function( _tileSet ) { // use the features of the geojson type tilesets directly, query mapbox for vector type tilesets var features = self._featureDataMap.getFeatures( _tileSet.id ); if ( _tileSet.tileType === "geojson" ) { featureSet = featureSet.concat( features ); } else { // if we have features, use them, otherwise query MapBox if ( features.length > 0 ) { featureSet = featureSet.concat( features ); } else { var ids = []; self._featureDataMap.filter( { type: _tileSet.type, tileSet: _tileSet.id, property: _tileSet.property } ).forEach( function( _item ) { if ( _item[ _tileSet.property ] !== null ) ids.push( _item[ _tileSet.property ] ); } ); if ( ids.length > 0 ) { var queriedFeatures = self._map.querySourceFeatures( _tileSet.id, { sourceLayer: _tileSet.sourceLayer, filter: [ "all", ["in", _tileSet.property].concat( ids ) ] } ); featureSet = featureSet.concat( queriedFeatures ); } } } } ); // quit when there are no featureSets if ( !featureSet.length ) return; // collect the geometry for all features var allFeatures = { "type": "FeatureCollection", "features": [] }; featureSet.forEach( function( f ) { allFeatures.features.push({ "type": "feature", "geometry": f.geometry } ); } ); // calculate the bounding box for all the features var bbox = getBalancedBoundingBox( allFeatures ); var mapBbox = [ [ bbox[0], bbox[1] ], [ bbox[2], bbox[3] ] ] this._fitBounds( mapBbox ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._addStop = function( _stopContainer, _stopKey, _stopValue ) { if ( !_stopContainer.has( _stopValue ) ) { _stopContainer.set( _stopValue, _stopKey ); } else { var currValue = _stopContainer.get( _stopValue ); if ( !Array.isArray( currValue ) ) _stopContainer.set( _stopValue, [ currValue, _stopKey ] ); else _stopContainer.get( _stopValue ).push( _stopKey ); } }, com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._buildStopsExpression = function( _property, _stops, _default ) { if ( !_stops || _stops.size() === 0 ) { return _default; } var expression = [ "match", [ "to-string", [ "get", _property ] ] ]; // expression uses this syntax - https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-match // where label is either a single item or an array. _stops.forEach( function( _key, _value ) { expression.push( _value ); expression.push( _key ); } ); // add default expression.push( _default ); return expression; }, com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._setupLayerStops = function() { // console.debug( "TiledMap::_setupLayerStops" ); var self = this; if ( this._featureDataMap.size() ) { // loop the tilesets self._featureDataMap.getTileSets().forEach( function( _tileSet ) { var fillStops = rave.map(); // Default colour used in the absence of a value. Should this be the "null" color? var fillDarkStops = rave.map(); var circleColorStops = rave.map(); var circleDarkColorStops = rave.map(); var circleHighlightStops = rave.map(); var circleSizeStops = rave.map(); var layerId = _tileSet[_tileSet.layer]; var property = _tileSet.property; // only add generate stops for tileSets with a propertyType if ( _tileSet.propertyType ) { // setup the stops for the data values of this var featureDataItems = self._featureDataMap.filter( { tileSet: _tileSet.id, type: _tileSet.type, layer: layerId }, property ); for ( var idx = 0, size = featureDataItems.length; idx < size; ++idx ) { var featureData = featureDataItems[ idx ]; var propertyVal = self._resolveProperty( featureData[ property ], featureData.propertyType ); // set region color stops if ( featureData.hasOwnProperty( "fillColor" ) ) { self._addStop( fillStops, propertyVal, featureData.fillColor ); self._addStop( fillDarkStops, propertyVal, "" + rave.rgb( featureData.fillColor ).darker() ); } // set point color and size if ( featureData.hasOwnProperty( "pointSize" ) ) { self._addStop( circleColorStops, propertyVal, featureData.pointColor ); var darker = rave.rgb( featureData.pointColor ).darker(); // skip dark color stop for points with staticZeroValuePointSize applied if ( !featureData.hasStaticZeroValuePointSize ) self._addStop( circleDarkColorStops, propertyVal, "" + darker ); self._addStop( circleHighlightStops, propertyVal, "" + darker.darker() ); self._addStop( circleSizeStops, propertyVal, featureData.pointSize ); } } } var fillStopsExpression = self._buildStopsExpression( property, fillStops, "transparent" ); var fillDarkStopsExpression = self._buildStopsExpression( property, fillDarkStops, "transparent" ); var circleColorStopsExpression = self._buildStopsExpression( property, circleColorStops, "transparent" ); var circleDarkColorStopsExpression = self._buildStopsExpression( property, circleDarkColorStops, "transparent" ); var circleHighlightStopsExpression = self._buildStopsExpression( property, circleHighlightStops, "transparent" ); var circleSizeStopsExpression = self._buildStopsExpression( property, circleSizeStops, 0 ); switch( _tileSet.type ) { case "region": if ( _tileSet.tileType === "vector" ) { // set stops for fill layer self._map.setPaintProperty( layerId, "fill-color", fillStopsExpression ); // set focus layer stops self._map.setPaintProperty( layerId + "Focus", "fill-color", fillStopsExpression ); // set stops for select layer self._map.setPaintProperty( layerId + "Select", "line-color", fillDarkStopsExpression ); // set stops for hover layer self._map.setPaintProperty( layerId + "Hover", "line-color", fillDarkStopsExpression ); } else if ( _tileSet.tileType === "geojson" ) { // set stops for point color self._map.setPaintProperty( layerId, "circle-color", fillStopsExpression); self._map.setPaintProperty( layerId, "circle-opacity", 1 - (_tileSet.transparency / 100.0) ); // set stops for point color self._map.setPaintProperty( layerId + "Focus", "circle-color", fillStopsExpression ); self._map.setPaintProperty( layerId + "Focus", "circle-opacity", 1 - (_tileSet.transparency / 100.0) ); // set stops for hover layer self._map.setPaintProperty( layerId + "Hover", "circle-stroke-color", fillDarkStopsExpression ); // set stops for select layer self._map.setPaintProperty( layerId + "Select", "circle-stroke-color", fillDarkStopsExpression ); } break; case "point": // set stops for point color self._map.setPaintProperty( layerId, "circle-color", circleColorStopsExpression ); self._map.setPaintProperty( layerId, "circle-opacity", 1 - (_tileSet.transparency / 100.0) ); // set stops for point border self._map.setPaintProperty( layerId, "circle-stroke-color", circleDarkColorStopsExpression ); // set stops for point size self._map.setPaintProperty( layerId, "circle-radius", circleSizeStopsExpression ); // set stops for hover layer self._map.setPaintProperty( layerId + "Hover", "circle-stroke-color", circleHighlightStopsExpression ); self._map.setPaintProperty( layerId + "Hover", "circle-radius", circleSizeStopsExpression ); break; } } ); } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._resolveProperty = function( _value, _type ) { if ( ( _value === null ) || ( typeof _value === "undefined" ) ) return _value; if ( _type === "string" ) return String( _value ); if ( _type === "numeric" ) return Number( _value ); return _value; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._clearMapsCache = function() { // console.debug( "TiledMap::_clearMapsCache" ); this._clearAddedResources(); this._featureDataMap.clear(); this._selectedItems = rave.set(); this._highlights = { items: [] }; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.accessToken = function(accessToken) { // console.debug( "TiledMap::accessToken" ); if (accessToken != this._mapboxToken) { this._mapboxToken = accessToken; } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.mapStyle = function(style) { // console.debug( "TiledMap::mapStyle" ); if ( style !== this._mapboxStyle ) { var self = this; this._mapboxStyle = style; this._mapboxStyleDirty = true; this._map.setStyle( style ); } else if ( !this._mapLoaded ) { this._map.once( "load", this._updateMapLayout.bind( this ) ); } else { this._updateMapLayout(); } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._updateMapLayout = function() { // console.debug( "TiledMap::_updateMapLayout" ); if ( this._addedResources.size() > 0 ) this._setupLayerStops(); else this._loadLayers(); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.deselectAllAction = function() { // console.debug( "TiledMap::deselectAllAction" ); if( !this._mapLoaded || !this._featureDataMap.size() ) return; var self = this; var type = "region"; this._featureDataMap.getTileSets( { type: type } ).forEach( function( _tileSet ) { var filter = [ "in", _tileSet.property, FILTER_NONE ]; self._map.setPaintProperty( _tileSet[_tileSet.layer], _tileSet.opacityProp, 1 - (_tileSet.transparency / 100.0) ); self._map.setFilter( _tileSet[_tileSet.layer] + "Select", filter ); self._map.setFilter( _tileSet[_tileSet.layer] + "Focus", filter ); } ); this._selectedItems = rave.set(); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.deselectAction = function( _deselections ) { // console.debug( "TiledMap::deselectAction" ); if ( !this._mapLoaded ) this._map.once( "load", this._toggleSelect.bind( this, _deselections, false ) ); else this._toggleSelect( _deselections, false ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._updateSelectedItemFilters = function() { // console.debug( "TiledMap::_updateSelectedItemFilters" ); var self = this; var type = "region"; this._featureDataMap.getTileSets( { type: type } ).forEach( function( _tileSet ) { var filter = [ "in", _tileSet.property ]; self._selectedItems.forEach( function( _id ) { var item = self._featureDataMap.getById( _id ); if ( item && ( _tileSet.id === item.tileSets[_tileSet.type].id ) ) filter.push( item[ _tileSet.property ] ); } ); if ( filter.length === 2 ) filter.push( FILTER_NONE ); self._map.setPaintProperty( _tileSet[_tileSet.layer], _tileSet.opacityProp, ( self._selectedItems.size() === 0 ) ? 1 - (_tileSet.transparency / 100.0) : 0.5 ); self._map.setFilter( _tileSet[_tileSet.layer] + "Select", filter ); self._map.setFilter( _tileSet[_tileSet.layer] + "Focus", filter ); } ); } //list of features to select or deselect com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._toggleSelect = function( _selections, _select ) { // console.debug( "TiledMap::_toggleSelect" ); if( !_selections || !_selections.items || !this._featureDataMap.size() ) return; // determine item by layer var itemsByLayer = this._getItemsByLayer( _selections ); if ( !itemsByLayer.size() ) return; var self = this; // update selected items // (currently only regions support selection) this._featureDataMap.getTileSets( { type: "region" } ).forEach( function( _tileSet ) { var itemList = itemsByLayer.get( _tileSet.type ); // we might have caught points as well, skip them if ( itemList ) { if ( _select ) { itemList.forEach( function( _item ) { if ( ( _tileSet.id === _item.tileSets[_tileSet.type].id ) && !self._selectedItems.has( _item.id ) ) self._selectedItems.add( _item.id ); } ); } else { itemList.forEach( function( _item ) { if ( ( _tileSet.id === _item.tileSets[_tileSet.type].id ) && self._selectedItems.has( _item.id ) ) self._selectedItems.remove( _item.id ); } ); } } } ); this._updateSelectedItemFilters(); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.selectAction = function( _selections ) { // console.debug( "TiledMap::selectAction" ); if ( !this._mapLoaded ) this._map.once( "load", this._toggleSelect.bind( this, _selections, true ) ); else this._toggleSelect( _selections, true ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.highlightAction = function( _highlights ) { // console.debug( "TiledMap::highlightAction" ); if ( !this._mapLoaded || !_highlights || !this._featureDataMap.size() ) return; var self = this; // determine items var itemsByLayer = this._getItemsByLayer( _highlights ); if ( ( itemsByLayer.size() === 0 ) && ( this._highlights.items.length === 0 ) ) return; // (un)highlight var baseFilter = [ "in" ]; var filter; var itemList; this._featureDataMap.getTileSets().forEach( function( _tileSet ) { filter = baseFilter.concat( _tileSet.property ); itemList = []; if ( itemsByLayer.has( _tileSet.type ) ) { itemsByLayer.get( _tileSet.type ).forEach( function( _item ) { if ( _item.tileSets[ _tileSet.type ] && ( _item.tileSets[ _tileSet.type ].id === _tileSet.id ) && ( _item[ _tileSet.property ] !== null ) ) { itemList.push( _item[ _tileSet.property ] ); } } ); } filter = filter.concat( itemList.length ? itemList : FILTER_NONE ); self._map.setFilter( _tileSet[_tileSet.layer] + "Hover", filter ); } ); // remember highlighted items this._highlights = _highlights; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._getItemsByLayer = function( _query ) { var self = this; var itemsByLayer = rave.map(); var itemList; if ( _query.items && _query.items.length ) { _query.items.forEach( function( _item ) { var dataLayer = self._getDataLayer( _item.dataSet ); // if there's no data layer, we're done if ( !dataLayer ) return; var layerType = dataLayer.getType(); var featureData = null; // attempt an item resolve by id first if ( _item.id ) featureData = self._featureDataMap.getById( _item.id ); // if featureData couldn't be retrieved by id, try to resolve by dataSet id and datum if ( !featureData && _item.datum ) featureData = self._featureDataMap.getByKey( self._getFeatureKeyFromAssignedSlots( dataLayer, _item.datum ) ); if ( featureData ) { dataLayer.typeData.forEach( function( _type, _typeData ) { // check if there's a tile registered for this data layer if ( featureData.tileSets[ _type ] ) { if ( itemsByLayer.has( _type ) ) { itemList = itemsByLayer.get( _type ); } else { itemList = []; itemsByLayer.set( _type, itemList ) } itemList.push( featureData ); } } ); } } ); } return itemsByLayer; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.setup = function( _node, _nls ) { // console.debug( "TiledMap::setup" ); var self = this; this._nls = _nls; // TODO: "resizeVizContainer" (I suspect) is a Dashboards-specific event name. This should be handled the same way all other bundles are resized (i.e. bundle should call resize() on a new render() call. _node[0][0].addEventListener( "resizeVisContainer", function() { if (self._map) { window.setTimeout( function() { self._map.resize(); }, 10 ); } } ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.off = function( _eventName, _callback ) { // console.debug( "TiledMap::off - " + eventName ); // check eventName switch ( _eventName ) { case "maxZoomReached": // remove callback from register var pos = this._maxZoomCallbacks.indexOf( _callback ); if ( pos !== -1 ) { this._maxZoomCallbacks.splice( pos, 1 ); // clean up if this was the last if ( this._maxZoomCallbacks.length === 0 ) { // unregister this._map.off( "zoomstart", this._zoomStartHandler ); this._map.off( "zoomend", this._zoomEndHandler ); this._zoomStartHandler = null; this._zoomEndHandler = null; } } break; case "mappingError": // remove callback from register var pos = this._mappingErrorCallbacks.indexOf( _callback ); if ( pos !== -1 ) this._mappingErrorCallbacks.splice( pos, 1 ); // remove map listeners if ( this._mappingErrorCallbacks.length === 0 ) { this._map.off( "error", this._onMapError ); this._map.off( "data", this._onMapData ); } break; default: this._map.off( _eventName, _callback ); break; } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.on = function( _eventName, _callback ) { // console.debug( "TiledMap::on - " + eventName ); // this._map.on(eventName, callback); var self = this; // check eventName switch ( _eventName ) { case "maxZoomReached": // setup zoom handlers if this is the first callback if ( !this._maxZoomCallbacks.length ) { this._zoomStartHandler = function() { // mark zoom start self._zoomStart = self._map.getZoom(); } this._zoomEndHandler = function() { var zoomEnd = self._map.getZoom(); // invoke registered callbacks when maxZoom reached if ( ( zoomEnd === self._zoomStart ) && ( zoomEnd === self._maxZoom ) ) self._maxZoomCallbacks.forEach( function( _clb ) { _clb(); } ); self._zoomStart = null; } // register handlers this._map.on( "zoomstart", this._zoomStartHandler ); this._map.on( "zoomend", this._zoomEndHandler ); } // register callback if ( this._maxZoomCallbacks.indexOf( _callback ) === -1 ) this._maxZoomCallbacks.push( _callback ); break; case "mappingError": // register callback if ( this._mappingErrorCallbacks.indexOf( _callback ) === -1 ) this._mappingErrorCallbacks.push( _callback ); if ( this._mappingErrorCallbacks.length === 1 ) { this._map.on( "error", this._onMapError.bind( this ) ); this._map.on( "data", this._onMapData.bind( this ) ); } break; case "load": case "style.load": this._map.on( _eventName, _callback ); break; default: this._map.on( _eventName, function( _event ) { var items = []; if ( self._mapLoaded ) items = self._queryRenderedFeatures( _event.point ); _callback( { items: items, // List of data/id combo's _mapboxEvent: _event, // The mapbox event (TODO: Will this be necessary for anything?) originalEvent: _event.originalEvent // The DOM event, useful for checking "if ctrl was held down", etc. }); } ); break; } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.emit = function( _eventName, _data ) { // check eventName switch ( _eventName ) { case "mappingError": // invoke registered callbacks this._mappingErrorCallbacks.forEach( function( _callback ) { _callback( _data ); } ); break; } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.setMaxBounds = function( _lnglat ) { // console.debug( "TiledMap::setMaxBounds" ); return; // this._map.setMaxBounds(lnglat); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.setContainerRect = function( _rect ) { // console.debug( "TiledMap::setContainerRect - [x: " + rect.x + ", y: " + rect.y + ", width: " + rect.width + ", height: " + rect.height + "]" ); this._containerRect = _rect; // Update container dimensions if (this._map) { var self = this; this._mapContainer .style("left", this._containerRect.x + "px") .style("top", this._containerRect.y + "px") .style("width", this._containerRect.width + "px") .style("height", this._containerRect.height + "px"); window.setTimeout( function() { self._map.resize(); }, 10); } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.setMaxZoom = function( _maxZoom ) { // console.debug( "TiledMap::setMaxZoom" ); this._maxZoom = _maxZoom; this._map.setMaxZoom( _maxZoom ); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.setMaxPointSize = function( _maxPointSize ) { // console.debug( "TiledMap::setMaxZoom" ); this._maxPointSize = _maxPointSize; } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.setMapLocale = function( _mapLocale ) { // console.debug( "TiledMap::setMapLocale" ); if ( _mapLocale ) { var mapLocale = _mapLocale.toLowerCase(); var pos = mapLocale.indexOf( "-" ); if ( pos > -1 ) mapLocale = mapLocale.substr( 0, pos ); switch ( mapLocale ) { case "es": case "fr": case "de": case "pt": case "ru": case "zh": this._mapLocale = mapLocale; break case "en": default: this._mapLocale = "en"; break; } } else { this._mapLocale = "en"; } // set country labels if ( this._mapLoaded ) this._applyMapLocale(); } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._applyMapLocale = function() { if ( this._map.style.stylesheet ) { var self = this; var localizedField = "{name_" + this._mapLocale + "}"; var styleData = this._styleDataCache.get( this._mapboxStyle ); // collect style data if ( !styleData ) { styleData = { baseLayer: "", symbolLayers: [] }; this._map.style.stylesheet.layers.forEach( function( _layer ) { if ( _layer.type === "symbol" ) { // for baseLayer, we need the first symbol layer of the last consecutive symbol layers block. if ( !styleData.baseLayer.length ) styleData.baseLayer = _layer.id; styleData.symbolLayers.push( _layer.id ); self._setLocalizedField( _layer, localizedField ); } else { // reset baseLayer, we've encountered a, none symbol layer after we set the baseLayer. if ( styleData.baseLayer.length ) styleData.baseLayer = ""; } } ); this._styleDataCache.set( this._mapboxStyle, styleData ); } else { this._map.style.stylesheet.layers.forEach( function( _layer ) { if ( _layer.type === "symbol" ) self._setLocalizedField( _layer, localizedField ); } ); } } } /** * Localize a text field in a map layer * @param {Object} _layer A serialized MapBox layer * @param {String} _localizedField The localized field */ com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype._setLocalizedField = function( _layer, _localizedField ) { var textField = ( _layer.layout && _layer.layout[ "text-field" ] ) || null; // quit when textField doesn't exist if ( !textField ) return; // patch textfield if ( ( typeof textField === "string" ) && reNameField.test( textField ) ) { this._map.setLayoutProperty( _layer.id, "text-field", _localizedField ); } else if ( ( typeof textField === "object" ) && textField.hasOwnProperty( "stops" ) ) { var replacedStops = false; var patchedStops = textField.stops.map( function( _stop ) { if ( reNameField.test( _stop[1] ) ) { replacedStops = true; _stop[1] = _localizedField; } return _stop; } ); if ( replacedStops ) { textField.stops = patchedStops; this._map.setLayoutProperty( _layer.id, "text-field", textField ); } } } com_ibm_rave_bundles_nativeImpl_components_TiledmapV2NativeSubComponentImpl.prototype.bindHandlers = function(context) { // console.debug( "TiledMap::bindHandlers" ); var self = this; function eventName(name) { return name + ".mapboxRebind" } var mouseEvents = [ "click", "contextmenu", "dblclick", "mousedown", "mousemove", "mouseout", "mouseup" ]; var touchEvents = [ "touchcancel", "touchend", "touchmove", "touchstart" ]; var wheelEvents = [ "mousewheel", "wheel" ]; for (var e=0; e