UNPKG

257 kBJavaScriptView Raw
1/*
2 * Power BI Visualizations
3 *
4 * Copyright (c) Microsoft Corporation
5 * All rights reserved.
6 * MIT License
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the ""Software""), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26///<reference path="../../Typedefs/jquery/jquery.d.ts"/>
27///<reference path="../../Typedefs/d3/d3.d.ts"/>
28///<reference path="../../Typedefs/lodash/lodash.d.ts"/>
29/*
30 * Power BI Visualizations
31 *
32 * Copyright (c) Microsoft Corporation
33 * All rights reserved.
34 * MIT License
35 *
36 * Permission is hereby granted, free of charge, to any person obtaining a copy
37 * of this software and associated documentation files (the ""Software""), to deal
38 * in the Software without restriction, including without limitation the rights
39 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
40 * copies of the Software, and to permit persons to whom the Software is
41 * furnished to do so, subject to the following conditions:
42 *
43 * The above copyright notice and this permission notice shall be included in
44 * all copies or substantial portions of the Software.
45 *
46 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
52 * THE SOFTWARE.
53 */
54var jsCommon;
55(function (jsCommon) {
56 /**
57 * DOM constants.
58 */
59 var DOMConstants;
60 (function (DOMConstants) {
61 /**
62 * Integer codes corresponding to individual keys on the keyboard.
63 */
64 DOMConstants.escKeyCode = 27;
65 DOMConstants.enterKeyCode = 13;
66 DOMConstants.tabKeyCode = 9;
67 DOMConstants.upArrowKeyCode = 38;
68 DOMConstants.downArrowKeyCode = 40;
69 DOMConstants.leftArrowKeyCode = 37;
70 DOMConstants.rightArrowKeyCode = 39;
71 DOMConstants.homeKeyCode = 36;
72 DOMConstants.endKeyCode = 35;
73 DOMConstants.backSpaceKeyCode = 8;
74 DOMConstants.deleteKeyCode = 46;
75 DOMConstants.spaceKeyCode = 32;
76 DOMConstants.shiftKeyCode = 16;
77 DOMConstants.ctrlKeyCode = 17;
78 DOMConstants.altKeyCode = 18;
79 DOMConstants.aKeyCode = 65;
80 DOMConstants.cKeyCode = 67;
81 DOMConstants.sKeyCode = 83;
82 DOMConstants.vKeyCode = 86;
83 DOMConstants.wKeyCode = 87;
84 DOMConstants.xKeyCode = 88;
85 DOMConstants.yKeyCode = 89;
86 DOMConstants.zKeyCode = 90;
87 /**
88 * DOM Elements.
89 */
90 DOMConstants.DocumentBody = 'body';
91 DOMConstants.Anchor = 'a';
92 DOMConstants.EditableTextElements = ':text, textarea';
93 DOMConstants.EditableNumericElements = '[type="number"]';
94 /**
95 * DOM Attributes and values.
96 */
97 DOMConstants.disabledAttributeOrValue = 'disabled';
98 DOMConstants.readonlyAttributeOrValue = 'readonly';
99 DOMConstants.idAttribute = 'id';
100 DOMConstants.styleAttribute = 'style';
101 DOMConstants.hrefAttribute = 'href';
102 DOMConstants.targetAttribute = 'target';
103 DOMConstants.blankValue = '_blank';
104 DOMConstants.selfValue = '_self';
105 DOMConstants.classAttribute = 'class';
106 DOMConstants.titleAttribute = 'title';
107 DOMConstants.srcAttribute = 'src';
108 /**
109 * DOM event names.
110 */
111 DOMConstants.contextmenuEventName = 'contextmenu';
112 DOMConstants.blurEventName = 'blur';
113 DOMConstants.keyUpEventName = 'keyup';
114 DOMConstants.inputEventName = 'input';
115 DOMConstants.changeEventName = 'change';
116 DOMConstants.cutEventName = 'cut';
117 DOMConstants.keyDownEventName = 'keydown';
118 DOMConstants.mouseMoveEventName = 'mousemove';
119 DOMConstants.mouseDownEventName = 'mousedown';
120 DOMConstants.mouseEnterEventName = 'mouseenter';
121 DOMConstants.mouseLeaveEventName = 'mouseleave';
122 DOMConstants.mouseOverEventName = 'mouseover';
123 DOMConstants.mouseOutEventName = 'mouseout';
124 DOMConstants.mouseClickEventName = 'click';
125 DOMConstants.pasteEventName = 'paste';
126 DOMConstants.scrollEventName = 'scroll';
127 DOMConstants.dropEventName = 'drop';
128 DOMConstants.focusEventName = 'focus';
129 DOMConstants.focusInEventName = 'focusin';
130 DOMConstants.focusOutEventName = 'focusout';
131 DOMConstants.selectEventName = 'select';
132 DOMConstants.messageEventName = 'message';
133 DOMConstants.loadEventName = 'load';
134 DOMConstants.beforeUnload = 'beforeunload';
135 /**
136 * Common DOM event combination names.
137 */
138 DOMConstants.inputAndSelectEventNames = 'input, select';
139 })(DOMConstants = jsCommon.DOMConstants || (jsCommon.DOMConstants = {}));
140})(jsCommon || (jsCommon = {}));
141/*
142 * Power BI Visualizations
143 *
144 * Copyright (c) Microsoft Corporation
145 * All rights reserved.
146 * MIT License
147 *
148 * Permission is hereby granted, free of charge, to any person obtaining a copy
149 * of this software and associated documentation files (the ""Software""), to deal
150 * in the Software without restriction, including without limitation the rights
151 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
152 * copies of the Software, and to permit persons to whom the Software is
153 * furnished to do so, subject to the following conditions:
154 *
155 * The above copyright notice and this permission notice shall be included in
156 * all copies or substantial portions of the Software.
157 *
158 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
159 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
160 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
161 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
162 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
163 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
164 * THE SOFTWARE.
165 */
166var powerbi;
167(function (powerbi) {
168 (function (PowerBIErrorResourceType) {
169 PowerBIErrorResourceType[PowerBIErrorResourceType["ResourceCodeReference"] = 0] = "ResourceCodeReference";
170 PowerBIErrorResourceType[PowerBIErrorResourceType["EmbeddedString"] = 1] = "EmbeddedString";
171 })(powerbi.PowerBIErrorResourceType || (powerbi.PowerBIErrorResourceType = {}));
172 var PowerBIErrorResourceType = powerbi.PowerBIErrorResourceType;
173 var ServiceErrorToClientError = (function () {
174 function ServiceErrorToClientError(serviceError) {
175 this.m_serviceError = serviceError;
176 }
177 Object.defineProperty(ServiceErrorToClientError.prototype, "code", {
178 get: function () {
179 return ServiceErrorToClientError.codeName;
180 },
181 enumerable: true,
182 configurable: true
183 });
184 Object.defineProperty(ServiceErrorToClientError.prototype, "ignorable", {
185 get: function () {
186 return false;
187 },
188 enumerable: true,
189 configurable: true
190 });
191 Object.defineProperty(ServiceErrorToClientError.prototype, "requestId", {
192 get: function () {
193 return this.httpRequestId;
194 },
195 set: function (value) {
196 this.httpRequestId = value;
197 },
198 enumerable: true,
199 configurable: true
200 });
201 ServiceErrorToClientError.prototype.getDetails = function (resourceProvider) {
202 var errorDetails;
203 if (this.m_serviceError.statusCode === 6 /* ExecuteSemanticQueryTransformError */) {
204 errorDetails = PowerBIErrorDetailHelper.GetDetailsFromTransformError(resourceProvider, this.m_serviceError);
205 }
206 else {
207 errorDetails = PowerBIErrorDetailHelper.GetDetailsFromServerErrorStatusCode(resourceProvider, this.m_serviceError.statusCode);
208 }
209 PowerBIErrorDetailHelper.addAdditionalInfo(errorDetails, this.m_serviceError.errorDetails, resourceProvider);
210 PowerBIErrorDetailHelper.addMessageAndStackTrace(errorDetails, this.m_serviceError.message || null, this.m_serviceError.stackTrace || null, resourceProvider);
211 return errorDetails;
212 };
213 ServiceErrorToClientError.codeName = 'ServiceErrorToClientError';
214 return ServiceErrorToClientError;
215 }());
216 powerbi.ServiceErrorToClientError = ServiceErrorToClientError;
217 var PowerBIErrorDetailHelper = (function () {
218 function PowerBIErrorDetailHelper() {
219 }
220 PowerBIErrorDetailHelper.addAdditionalInfo = function (errorDetails, pbiErrorDetails, localize) {
221 if (pbiErrorDetails) {
222 for (var i = 0; i < pbiErrorDetails.length; i++) {
223 var element = pbiErrorDetails[i];
224 var localizedCode = localize.getOptional(PowerBIErrorDetailHelper.serverErrorPrefix + element.code);
225 var additionErrorInfoKeyValuePair = {
226 errorInfoKey: localizedCode ? localizedCode : element.code,
227 errorInfoValue: element.detail.type === PowerBIErrorResourceType.ResourceCodeReference ? localize.get(PowerBIErrorDetailHelper.serverErrorPrefix + element.detail.value) : element.detail.value
228 };
229 errorDetails.additionalErrorInfo.push(additionErrorInfoKeyValuePair);
230 }
231 }
232 return errorDetails;
233 };
234 PowerBIErrorDetailHelper.addMessageAndStackTrace = function (errorDetails, message, stackTrace, localize) {
235 if (message) {
236 var additionErrorInfoKeyValuePair = {
237 errorInfoKey: localize.get("AdditionalErrorInfo_ErrorDetailsText"),
238 errorInfoValue: message
239 };
240 errorDetails.additionalErrorInfo.push(additionErrorInfoKeyValuePair);
241 }
242 if (stackTrace) {
243 var additionErrorInfoKeyValuePair = {
244 errorInfoKey: localize.get("AdditionalErrorInfo_StackTraceText"),
245 errorInfoValue: stackTrace
246 };
247 errorDetails.additionalErrorInfo.push(additionErrorInfoKeyValuePair);
248 }
249 return errorDetails;
250 };
251 PowerBIErrorDetailHelper.GetDetailsFromTransformError = function (localize, serviceError) {
252 var message = localize.get('ServiceError_CannotLoadVisual');
253 var key = localize.get('ServiceError_CannotLoadVisual');
254 var val = serviceError.message;
255 var additionalInfo = [];
256 additionalInfo.push({ errorInfoKey: key, errorInfoValue: val, });
257 var errorDetails = {
258 message: message,
259 additionalErrorInfo: additionalInfo,
260 };
261 return errorDetails;
262 };
263 PowerBIErrorDetailHelper.GetDetailsFromServerErrorStatusCode = function (localize, statusCode) {
264 // TODO: Localize
265 var message = "";
266 var key = "";
267 var val = "";
268 switch (statusCode) {
269 case 2 /* CsdlConvertXmlToConceptualSchema */:
270 message = localize.get('ServiceError_ModelCannotLoad');
271 key = localize.get('ServiceError_ModelConvertFailureKey');
272 val = localize.get('ServiceError_ModelConvertFailureValue');
273 break;
274 case 3 /* CsdlCreateClientSchema */:
275 message = localize.get('ServiceError_ModelCannotLoad');
276 key = localize.get('ServiceError_ModelCreationFailureKey');
277 val = localize.get('ServiceError_ModelCreationFailureValue');
278 break;
279 case 1 /* CsdlFetching */:
280 message = localize.get('ServiceError_ModelCannotLoad');
281 key = localize.get('ServiceError_ModelFetchingFailureKey');
282 val = localize.get('ServiceError_ModelFetchingFailureValue');
283 break;
284 case 4 /* ExecuteSemanticQueryError */:
285 message = localize.get('ServiceError_CannotLoadVisual');
286 key = localize.get('ServiceError_ExecuteSemanticQueryErrorKey');
287 val = localize.get('ServiceError_ExecuteSemanticQueryErrorValue');
288 break;
289 case 5 /* ExecuteSemanticQueryInvalidStreamFormat */:
290 message = localize.get('ServiceError_CannotLoadVisual');
291 key = localize.get('ServiceError_ExecuteSemanticQueryInvalidStreamFormatKey');
292 val = localize.get('ServiceError_ExecuteSemanticQueryInvalidStreamFormatValue');
293 break;
294 case 0 /* GeneralError */:
295 default:
296 message = localize.get('ServiceError_GeneralError');
297 key = localize.get('ServiceError_GeneralErrorKey');
298 val = localize.get('ServiceError_GeneralErrorValue');
299 break;
300 }
301 var additionalInfo = [];
302 additionalInfo.push({ errorInfoKey: key, errorInfoValue: val, });
303 var errorDetails = {
304 message: message,
305 additionalErrorInfo: additionalInfo,
306 };
307 return errorDetails;
308 };
309 PowerBIErrorDetailHelper.serverErrorPrefix = "ServerError_";
310 return PowerBIErrorDetailHelper;
311 }());
312 powerbi.PowerBIErrorDetailHelper = PowerBIErrorDetailHelper;
313})(powerbi || (powerbi = {}));
314/*
315 * Power BI Visualizations
316 *
317 * Copyright (c) Microsoft Corporation
318 * All rights reserved.
319 * MIT License
320 *
321 * Permission is hereby granted, free of charge, to any person obtaining a copy
322 * of this software and associated documentation files (the ""Software""), to deal
323 * in the Software without restriction, including without limitation the rights
324 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
325 * copies of the Software, and to permit persons to whom the Software is
326 * furnished to do so, subject to the following conditions:
327 *
328 * The above copyright notice and this permission notice shall be included in
329 * all copies or substantial portions of the Software.
330 *
331 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
332 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
333 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
334 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
335 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
336 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
337 * THE SOFTWARE.
338 */
339var powerbi;
340(function (powerbi) {
341})(powerbi || (powerbi = {}));
342/*
343 * Power BI Visualizations
344 *
345 * Copyright (c) Microsoft Corporation
346 * All rights reserved.
347 * MIT License
348 *
349 * Permission is hereby granted, free of charge, to any person obtaining a copy
350 * of this software and associated documentation files (the ""Software""), to deal
351 * in the Software without restriction, including without limitation the rights
352 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
353 * copies of the Software, and to permit persons to whom the Software is
354 * furnished to do so, subject to the following conditions:
355 *
356 * The above copyright notice and this permission notice shall be included in
357 * all copies or substantial portions of the Software.
358 *
359 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
360 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
361 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
362 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
363 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
364 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
365 * THE SOFTWARE.
366 */
367var powerbi;
368(function (powerbi) {
369 powerbi.CategoryTypes = {
370 Address: "Address",
371 City: "City",
372 Continent: "Continent",
373 CountryRegion: "Country",
374 County: "County",
375 Longitude: "Longitude",
376 Latitude: "Latitude",
377 Place: "Place",
378 PostalCode: "PostalCode",
379 StateOrProvince: "StateOrProvince"
380 };
381 function createGeoTaggingAnalyzerService(getLocalized) {
382 return new GeoTaggingAnalyzerService(getLocalized);
383 }
384 powerbi.createGeoTaggingAnalyzerService = createGeoTaggingAnalyzerService;
385 var EnglishBackup = {
386 GeotaggingString_Continent: "continent",
387 GeotaggingString_Continents: "continents",
388 GeotaggingString_Country: "country",
389 GeotaggingString_Countries: "countries",
390 GeotaggingString_State: "state",
391 GeotaggingString_States: "states",
392 GeotaggingString_City: "city",
393 GeotaggingString_Cities: "cities",
394 GeotaggingString_Town: "town",
395 GeotaggingString_Towns: "towns",
396 GeotaggingString_Province: "province",
397 GeotaggingString_Provinces: "provinces",
398 GeotaggingString_County: "county",
399 GeotaggingString_Counties: "counties",
400 GeotaggingString_Village: "village",
401 GeotaggingString_Villages: "villages",
402 GeotaggingString_Post: "post",
403 GeotaggingString_Zip: "zip",
404 GeotaggingString_Code: "code",
405 GeotaggingString_Place: "place",
406 GeotaggingString_Places: "places",
407 GeotaggingString_Address: "address",
408 GeotaggingString_Addresses: "addresses",
409 GeotaggingString_Street: "street",
410 GeotaggingString_Streets: "streets",
411 GeotaggingString_Longitude: "longitude",
412 GeotaggingString_Longitude_Short: "lon",
413 GeotaggingString_Latitude: "latitude",
414 GeotaggingString_Latitude_Short: "lat",
415 GeotaggingString_PostalCode: "postal code",
416 GeotaggingString_PostalCodes: "postal codes",
417 GeotaggingString_ZipCode: "zip code",
418 GeotaggingString_ZipCodes: "zip codes",
419 GeotaggingString_Territory: "territory",
420 GeotaggingString_Territories: "territories",
421 GeotaggingString_VRMBackCompat_CountryRegion: "CountryRegion",
422 GeotaggingString_VRMBackCompat_StateOrProvince: "StateOrProvince",
423 };
424 var GeoTaggingAnalyzerService = (function () {
425 function GeoTaggingAnalyzerService(getLocalized) {
426 this.GeotaggingString_VRMBackCompat_CountryRegion = "CountryRegion";
427 this.GeotaggingString_VRMBackCompat_StateOrProvince = "StateOrProvince";
428 this.GeotaggingString_Continent = getLocalized("GeotaggingString_Continent").toLowerCase();
429 this.GeotaggingString_Continents = getLocalized("GeotaggingString_Continents").toLowerCase();
430 this.GeotaggingString_Country = getLocalized("GeotaggingString_Country").toLowerCase();
431 this.GeotaggingString_Countries = getLocalized("GeotaggingString_Countries").toLowerCase();
432 this.GeotaggingString_State = getLocalized("GeotaggingString_State").toLowerCase();
433 this.GeotaggingString_States = getLocalized("GeotaggingString_States").toLowerCase();
434 this.GeotaggingString_City = getLocalized("GeotaggingString_City").toLowerCase();
435 this.GeotaggingString_Cities = getLocalized("GeotaggingString_Cities").toLowerCase();
436 this.GeotaggingString_Town = getLocalized("GeotaggingString_Town").toLowerCase();
437 this.GeotaggingString_Towns = getLocalized("GeotaggingString_Towns").toLowerCase();
438 this.GeotaggingString_Province = getLocalized("GeotaggingString_Province").toLowerCase();
439 this.GeotaggingString_Provinces = getLocalized("GeotaggingString_Provinces").toLowerCase();
440 this.GeotaggingString_County = getLocalized("GeotaggingString_County").toLowerCase();
441 this.GeotaggingString_Counties = getLocalized("GeotaggingString_Counties").toLowerCase();
442 this.GeotaggingString_Village = getLocalized("GeotaggingString_Village").toLowerCase();
443 this.GeotaggingString_Villages = getLocalized("GeotaggingString_Villages").toLowerCase();
444 this.GeotaggingString_Post = getLocalized("GeotaggingString_Post").toLowerCase();
445 this.GeotaggingString_Zip = getLocalized("GeotaggingString_Zip").toLowerCase();
446 this.GeotaggingString_Code = getLocalized("GeotaggingString_Code").toLowerCase();
447 this.GeotaggingString_Place = getLocalized("GeotaggingString_Place").toLowerCase();
448 this.GeotaggingString_Places = getLocalized("GeotaggingString_Places").toLowerCase();
449 this.GeotaggingString_Address = getLocalized("GeotaggingString_Address").toLowerCase();
450 this.GeotaggingString_Addresses = getLocalized("GeotaggingString_Addresses").toLowerCase();
451 this.GeotaggingString_Street = getLocalized("GeotaggingString_Street").toLowerCase();
452 this.GeotaggingString_Streets = getLocalized("GeotaggingString_Streets").toLowerCase();
453 this.GeotaggingString_Longitude = getLocalized("GeotaggingString_Longitude").toLowerCase();
454 this.GeotaggingString_Longitude_Short = getLocalized("GeotaggingString_Longitude_Short").toLowerCase();
455 this.GeotaggingString_Latitude = getLocalized("GeotaggingString_Latitude").toLowerCase();
456 this.GeotaggingString_Latitude_Short = getLocalized("GeotaggingString_Latitude_Short").toLowerCase();
457 this.GeotaggingString_PostalCode = getLocalized("GeotaggingString_PostalCode").toLowerCase();
458 this.GeotaggingString_PostalCodes = getLocalized("GeotaggingString_PostalCodes").toLowerCase();
459 this.GeotaggingString_ZipCode = getLocalized("GeotaggingString_ZipCode").toLowerCase();
460 this.GeotaggingString_ZipCodes = getLocalized("GeotaggingString_ZipCodes").toLowerCase();
461 this.GeotaggingString_Territory = getLocalized("GeotaggingString_Territory").toLowerCase();
462 this.GeotaggingString_Territories = getLocalized("GeotaggingString_Territories").toLowerCase();
463 }
464 GeoTaggingAnalyzerService.prototype.isLongitudeOrLatitude = function (fieldRefName) {
465 return this.isLongitude(fieldRefName) ||
466 this.isLatitude(fieldRefName);
467 };
468 GeoTaggingAnalyzerService.prototype.isGeographic = function (fieldRefName) {
469 return this.isLongitudeOrLatitude(fieldRefName) ||
470 this.isGeocodable(fieldRefName);
471 };
472 GeoTaggingAnalyzerService.prototype.isGeocodable = function (fieldRefName) {
473 return this.isAddress(fieldRefName) ||
474 this.isCity(fieldRefName) ||
475 this.isContinent(fieldRefName) ||
476 this.isCountry(fieldRefName) ||
477 this.isCounty(fieldRefName) ||
478 this.isStateOrProvince(fieldRefName) ||
479 this.isPlace(fieldRefName) ||
480 this.isPostalCode(fieldRefName) ||
481 this.isTerritory(fieldRefName);
482 };
483 GeoTaggingAnalyzerService.prototype.isGeoshapable = function (fieldRefName) {
484 return this.isCity(fieldRefName) ||
485 this.isCountry(fieldRefName) ||
486 this.isCounty(fieldRefName) ||
487 this.isStateOrProvince(fieldRefName) ||
488 this.isPostalCode(fieldRefName) ||
489 this.isTerritory(fieldRefName) ||
490 this.isGeoshapableEnglish(fieldRefName);
491 };
492 GeoTaggingAnalyzerService.prototype.isGeoshapableEnglish = function (fieldRefName) {
493 return this.isEnglishCity(fieldRefName) ||
494 this.isEnglishCountry(fieldRefName) ||
495 this.isEnglishCounty(fieldRefName) ||
496 this.isEnglishStateOrProvince(fieldRefName) ||
497 this.isEnglishPostalCode(fieldRefName) ||
498 this.isEnglishTerritory(fieldRefName);
499 };
500 GeoTaggingAnalyzerService.prototype.isAddress = function (fieldRefName) {
501 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
502 this.GeotaggingString_Address,
503 this.GeotaggingString_Addresses,
504 this.GeotaggingString_Street,
505 this.GeotaggingString_Streets
506 ]);
507 };
508 GeoTaggingAnalyzerService.prototype.isPlace = function (fieldRefName) {
509 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
510 this.GeotaggingString_Place,
511 this.GeotaggingString_Places
512 ]);
513 };
514 GeoTaggingAnalyzerService.prototype.isCity = function (fieldRefName) {
515 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
516 this.GeotaggingString_City,
517 this.GeotaggingString_Cities,
518 this.GeotaggingString_Town,
519 this.GeotaggingString_Towns,
520 this.GeotaggingString_Village,
521 this.GeotaggingString_Villages
522 ]);
523 };
524 GeoTaggingAnalyzerService.prototype.isStateOrProvince = function (fieldRefName) {
525 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
526 this.GeotaggingString_State,
527 this.GeotaggingString_States,
528 this.GeotaggingString_Province,
529 this.GeotaggingString_Provinces,
530 this.GeotaggingString_VRMBackCompat_StateOrProvince,
531 ]);
532 };
533 GeoTaggingAnalyzerService.prototype.isCountry = function (fieldRefName) {
534 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
535 this.GeotaggingString_Country,
536 this.GeotaggingString_Countries,
537 this.GeotaggingString_VRMBackCompat_CountryRegion
538 ]);
539 };
540 GeoTaggingAnalyzerService.prototype.isCounty = function (fieldRefName) {
541 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
542 this.GeotaggingString_County,
543 this.GeotaggingString_Counties
544 ]);
545 };
546 GeoTaggingAnalyzerService.prototype.isContinent = function (fieldRefName) {
547 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
548 this.GeotaggingString_Continent,
549 this.GeotaggingString_Continents
550 ]);
551 };
552 GeoTaggingAnalyzerService.prototype.isPostalCode = function (fieldRefName) {
553 var result = (GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
554 this.GeotaggingString_Post,
555 this.GeotaggingString_Zip])
556 && GeoTaggingAnalyzerService.hasMatches(fieldRefName, [this.GeotaggingString_Code])) ||
557 GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
558 this.GeotaggingString_PostalCode,
559 this.GeotaggingString_PostalCodes,
560 this.GeotaggingString_ZipCode,
561 this.GeotaggingString_ZipCodes
562 ]);
563 //Check again for strings without whitespace
564 if (!result) {
565 var whiteSpaceRegex = /\s+/;
566 var fieldNameWithoutWhitespace = fieldRefName.replace(whiteSpaceRegex, "");
567 result = GeoTaggingAnalyzerService.hasMatches(fieldNameWithoutWhitespace, [
568 this.GeotaggingString_PostalCode.replace(whiteSpaceRegex, ''),
569 this.GeotaggingString_PostalCodes.replace(whiteSpaceRegex, ''),
570 this.GeotaggingString_ZipCode.replace(whiteSpaceRegex, ''),
571 this.GeotaggingString_ZipCodes.replace(whiteSpaceRegex, '')
572 ]);
573 }
574 return result;
575 };
576 GeoTaggingAnalyzerService.prototype.isLongitude = function (fieldRefName) {
577 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [this.GeotaggingString_Longitude])
578 || GeoTaggingAnalyzerService.hasMatches(fieldRefName, [this.GeotaggingString_Longitude_Short], true /* useStrict */);
579 };
580 GeoTaggingAnalyzerService.prototype.isLatitude = function (fieldRefName) {
581 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [this.GeotaggingString_Latitude])
582 || GeoTaggingAnalyzerService.hasMatches(fieldRefName, [this.GeotaggingString_Latitude_Short], true /* useStrict */);
583 };
584 GeoTaggingAnalyzerService.prototype.isTerritory = function (fieldRefName) {
585 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
586 this.GeotaggingString_Territory,
587 this.GeotaggingString_Territories
588 ]);
589 };
590 GeoTaggingAnalyzerService.hasMatches = function (fieldName, possibleMatches, useStrict) {
591 var nonWordRegex = /\W/;
592 var value = fieldName.toLowerCase();
593 for (var i = 0, len = possibleMatches.length; i < len; i++) {
594 var possibleMatch = possibleMatches[i].toLowerCase();
595 if (!useStrict) {
596 if (value.indexOf(possibleMatch) > -1)
597 return true;
598 }
599 else {
600 var indexofpossibleMatch = value.indexOf(possibleMatch);
601 if (indexofpossibleMatch > -1) {
602 var wordEndFlag = void 0, wordBeginFlag = void 0;
603 wordEndFlag = wordBeginFlag = true;
604 if (indexofpossibleMatch - 1 > 0)
605 wordBeginFlag = nonWordRegex.test(value[indexofpossibleMatch - 1]);
606 if (indexofpossibleMatch + possibleMatch.length < value.length)
607 wordEndFlag = nonWordRegex.test(value[indexofpossibleMatch + possibleMatch.length]);
608 if (wordBeginFlag && wordEndFlag)
609 return true;
610 }
611 }
612 }
613 return false;
614 };
615 GeoTaggingAnalyzerService.prototype.getFieldType = function (fieldName) {
616 if (fieldName == null)
617 return undefined;
618 if (this.isLatitude(fieldName))
619 return powerbi.CategoryTypes.Latitude;
620 if (this.isLongitude(fieldName))
621 return powerbi.CategoryTypes.Longitude;
622 if (this.isPostalCode(fieldName))
623 return powerbi.CategoryTypes.PostalCode;
624 if (this.isAddress(fieldName))
625 return powerbi.CategoryTypes.Address;
626 if (this.isPlace(fieldName))
627 return powerbi.CategoryTypes.Place;
628 if (this.isCity(fieldName))
629 return powerbi.CategoryTypes.City;
630 if (this.isCountry(fieldName))
631 return powerbi.CategoryTypes.CountryRegion;
632 if (this.isCounty(fieldName))
633 return powerbi.CategoryTypes.County;
634 if (this.isStateOrProvince(fieldName))
635 return powerbi.CategoryTypes.StateOrProvince;
636 if (this.isContinent(fieldName))
637 return powerbi.CategoryTypes.Continent;
638 return this.getEnglishFieldType(fieldName);
639 };
640 GeoTaggingAnalyzerService.prototype.isEnglishAddress = function (fieldRefName) {
641 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
642 EnglishBackup.GeotaggingString_Address,
643 EnglishBackup.GeotaggingString_Addresses,
644 EnglishBackup.GeotaggingString_Street,
645 EnglishBackup.GeotaggingString_Streets
646 ]);
647 };
648 GeoTaggingAnalyzerService.prototype.isEnglishPlace = function (fieldRefName) {
649 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
650 EnglishBackup.GeotaggingString_Place,
651 EnglishBackup.GeotaggingString_Places
652 ]);
653 };
654 GeoTaggingAnalyzerService.prototype.isEnglishCity = function (fieldRefName) {
655 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
656 EnglishBackup.GeotaggingString_City,
657 EnglishBackup.GeotaggingString_Cities,
658 EnglishBackup.GeotaggingString_Town,
659 EnglishBackup.GeotaggingString_Towns,
660 EnglishBackup.GeotaggingString_Village,
661 EnglishBackup.GeotaggingString_Villages
662 ]);
663 };
664 GeoTaggingAnalyzerService.prototype.isEnglishStateOrProvince = function (fieldRefName) {
665 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
666 EnglishBackup.GeotaggingString_State,
667 EnglishBackup.GeotaggingString_States,
668 EnglishBackup.GeotaggingString_Province,
669 EnglishBackup.GeotaggingString_Provinces,
670 EnglishBackup.GeotaggingString_VRMBackCompat_StateOrProvince,
671 ]);
672 };
673 GeoTaggingAnalyzerService.prototype.isEnglishCountry = function (fieldRefName) {
674 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
675 EnglishBackup.GeotaggingString_Country,
676 EnglishBackup.GeotaggingString_Countries,
677 EnglishBackup.GeotaggingString_VRMBackCompat_CountryRegion
678 ]);
679 };
680 GeoTaggingAnalyzerService.prototype.isEnglishCounty = function (fieldRefName) {
681 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
682 EnglishBackup.GeotaggingString_County,
683 EnglishBackup.GeotaggingString_Counties
684 ]);
685 };
686 GeoTaggingAnalyzerService.prototype.isEnglishContinent = function (fieldRefName) {
687 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
688 EnglishBackup.GeotaggingString_Continent,
689 EnglishBackup.GeotaggingString_Continents
690 ]);
691 };
692 GeoTaggingAnalyzerService.prototype.isEnglishPostalCode = function (fieldRefName) {
693 var result = (GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
694 EnglishBackup.GeotaggingString_Post,
695 EnglishBackup.GeotaggingString_Zip])
696 && GeoTaggingAnalyzerService.hasMatches(fieldRefName, [this.GeotaggingString_Code])) ||
697 GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
698 EnglishBackup.GeotaggingString_PostalCode,
699 EnglishBackup.GeotaggingString_PostalCodes,
700 EnglishBackup.GeotaggingString_ZipCode,
701 EnglishBackup.GeotaggingString_ZipCodes
702 ]);
703 //Check again for strings without whitespace
704 if (!result) {
705 var whiteSpaceRegexPattern = new RegExp('\s');
706 result = GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
707 EnglishBackup.GeotaggingString_PostalCode.replace(whiteSpaceRegexPattern, ''),
708 EnglishBackup.GeotaggingString_PostalCodes.replace(whiteSpaceRegexPattern, ''),
709 EnglishBackup.GeotaggingString_ZipCode.replace(whiteSpaceRegexPattern, ''),
710 EnglishBackup.GeotaggingString_ZipCodes.replace(whiteSpaceRegexPattern, '')
711 ]);
712 }
713 return result;
714 };
715 GeoTaggingAnalyzerService.prototype.isEnglishLongitude = function (fieldRefName) {
716 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [EnglishBackup.GeotaggingString_Longitude])
717 || GeoTaggingAnalyzerService.hasMatches(fieldRefName, [EnglishBackup.GeotaggingString_Longitude_Short], true /* useStrict */);
718 };
719 GeoTaggingAnalyzerService.prototype.isEnglishLatitude = function (fieldRefName) {
720 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [EnglishBackup.GeotaggingString_Latitude])
721 || GeoTaggingAnalyzerService.hasMatches(fieldRefName, [EnglishBackup.GeotaggingString_Latitude_Short], true /* useStrict */);
722 };
723 GeoTaggingAnalyzerService.prototype.isEnglishTerritory = function (fieldRefName) {
724 return GeoTaggingAnalyzerService.hasMatches(fieldRefName, [
725 EnglishBackup.GeotaggingString_Territory,
726 EnglishBackup.GeotaggingString_Territories
727 ]);
728 };
729 GeoTaggingAnalyzerService.prototype.getEnglishFieldType = function (fieldName) {
730 if (fieldName == null)
731 return undefined;
732 if (this.isEnglishLatitude(fieldName))
733 return powerbi.CategoryTypes.Latitude;
734 if (this.isEnglishLongitude(fieldName))
735 return powerbi.CategoryTypes.Longitude;
736 if (this.isEnglishPostalCode(fieldName))
737 return powerbi.CategoryTypes.PostalCode;
738 if (this.isEnglishAddress(fieldName))
739 return powerbi.CategoryTypes.Address;
740 if (this.isEnglishPlace(fieldName))
741 return powerbi.CategoryTypes.Place;
742 if (this.isEnglishCity(fieldName))
743 return powerbi.CategoryTypes.City;
744 if (this.isEnglishCountry(fieldName))
745 return powerbi.CategoryTypes.CountryRegion;
746 if (this.isEnglishCounty(fieldName))
747 return powerbi.CategoryTypes.County;
748 if (this.isEnglishStateOrProvince(fieldName))
749 return powerbi.CategoryTypes.StateOrProvince;
750 if (this.isEnglishContinent(fieldName))
751 return powerbi.CategoryTypes.Continent;
752 return undefined;
753 };
754 return GeoTaggingAnalyzerService;
755 }());
756 powerbi.GeoTaggingAnalyzerService = GeoTaggingAnalyzerService;
757})(powerbi || (powerbi = {}));
758/*
759 * Power BI Visualizations
760 *
761 * Copyright (c) Microsoft Corporation
762 * All rights reserved.
763 * MIT License
764 *
765 * Permission is hereby granted, free of charge, to any person obtaining a copy
766 * of this software and associated documentation files (the ""Software""), to deal
767 * in the Software without restriction, including without limitation the rights
768 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
769 * copies of the Software, and to permit persons to whom the Software is
770 * furnished to do so, subject to the following conditions:
771 *
772 * The above copyright notice and this permission notice shall be included in
773 * all copies or substantial portions of the Software.
774 *
775 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
776 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
777 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
778 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
779 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
780 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
781 * THE SOFTWARE.
782 */
783if (typeof DEBUG === 'undefined')
784 var DEBUG = true;
785/*
786 * Power BI Visualizations
787 *
788 * Copyright (c) Microsoft Corporation
789 * All rights reserved.
790 * MIT License
791 *
792 * Permission is hereby granted, free of charge, to any person obtaining a copy
793 * of this software and associated documentation files (the ""Software""), to deal
794 * in the Software without restriction, including without limitation the rights
795 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
796 * copies of the Software, and to permit persons to whom the Software is
797 * furnished to do so, subject to the following conditions:
798 *
799 * The above copyright notice and this permission notice shall be included in
800 * all copies or substantial portions of the Software.
801 *
802 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
803 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
804 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
805 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
806 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
807 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
808 * THE SOFTWARE.
809 */
810var powerbi;
811(function (powerbi) {
812 /**
813 this base class should be derived to give a generic error message but with a unique error code.
814 */
815 var UnknownClientError = (function () {
816 function UnknownClientError(code) {
817 debug.assertValue(code, 'code');
818 this.errorCode = code;
819 }
820 Object.defineProperty(UnknownClientError.prototype, "code", {
821 get: function () {
822 return this.errorCode;
823 },
824 enumerable: true,
825 configurable: true
826 });
827 Object.defineProperty(UnknownClientError.prototype, "ignorable", {
828 get: function () {
829 return false;
830 },
831 enumerable: true,
832 configurable: true
833 });
834 UnknownClientError.prototype.getDetails = function (resourceProvider) {
835 var details = {
836 message: resourceProvider.get('ClientError_UnknownClientErrorValue'),
837 additionalErrorInfo: [{ errorInfoKey: resourceProvider.get('ClientError_UnknownClientErrorKey'), errorInfoValue: resourceProvider.get('ClientError_UnknownClientErrorValue'), }],
838 };
839 return details;
840 };
841 return UnknownClientError;
842 }());
843 powerbi.UnknownClientError = UnknownClientError;
844 var HttpClientError = (function () {
845 function HttpClientError(httpStatusCode, requestId) {
846 debug.assertValue(httpStatusCode, 'httpStatusCode');
847 debug.assertValue(requestId, 'requestId');
848 this.httpStatusCode = httpStatusCode;
849 this.httpRequestId = requestId;
850 }
851 Object.defineProperty(HttpClientError.prototype, "code", {
852 get: function () {
853 return 'HttpClientError';
854 },
855 enumerable: true,
856 configurable: true
857 });
858 Object.defineProperty(HttpClientError.prototype, "ignorable", {
859 get: function () {
860 return false;
861 },
862 enumerable: true,
863 configurable: true
864 });
865 Object.defineProperty(HttpClientError.prototype, "requestId", {
866 get: function () {
867 return this.httpRequestId;
868 },
869 enumerable: true,
870 configurable: true
871 });
872 HttpClientError.prototype.getDetails = function (resourceProvider) {
873 // Use a general error message for a HTTP request failure, since we currently do not know of any specifc error cases at this point in time.
874 var details = {
875 message: null,
876 additionalErrorInfo: [
877 { errorInfoKey: resourceProvider.get('DsrError_Key'), errorInfoValue: resourceProvider.get('DsrError_UnknownErrorValue') },
878 { errorInfoKey: resourceProvider.get('ClientError_HttpResponseStatusCodeKey'), errorInfoValue: this.httpStatusCode.toString() }],
879 };
880 return details;
881 };
882 return HttpClientError;
883 }());
884 powerbi.HttpClientError = HttpClientError;
885 var IgnorableClientError = (function () {
886 function IgnorableClientError() {
887 }
888 Object.defineProperty(IgnorableClientError.prototype, "code", {
889 get: function () {
890 return 'IgnorableClientError';
891 },
892 enumerable: true,
893 configurable: true
894 });
895 Object.defineProperty(IgnorableClientError.prototype, "ignorable", {
896 get: function () {
897 return true;
898 },
899 enumerable: true,
900 configurable: true
901 });
902 IgnorableClientError.prototype.getDetails = function (resourceProvider) {
903 var details = {
904 message: '',
905 additionalErrorInfo: [],
906 };
907 return details;
908 };
909 return IgnorableClientError;
910 }());
911 powerbi.IgnorableClientError = IgnorableClientError;
912})(powerbi || (powerbi = {}));
913/*
914 * Power BI Visualizations
915 *
916 * Copyright (c) Microsoft Corporation
917 * All rights reserved.
918 * MIT License
919 *
920 * Permission is hereby granted, free of charge, to any person obtaining a copy
921 * of this software and associated documentation files (the ""Software""), to deal
922 * in the Software without restriction, including without limitation the rights
923 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
924 * copies of the Software, and to permit persons to whom the Software is
925 * furnished to do so, subject to the following conditions:
926 *
927 * The above copyright notice and this permission notice shall be included in
928 * all copies or substantial portions of the Software.
929 *
930 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
931 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
932 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
933 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
934 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
935 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
936 * THE SOFTWARE.
937 */
938var jsCommon;
939(function (jsCommon) {
940 var ArrayExtensions;
941 (function (ArrayExtensions) {
942 /**
943 * Returns items that exist in target and other.
944 */
945 function intersect(target, other) {
946 var result = [];
947 for (var i = target.length - 1; i >= 0; --i) {
948 if (other.indexOf(target[i]) !== -1) {
949 result.push(target[i]);
950 }
951 }
952 return result;
953 }
954 ArrayExtensions.intersect = intersect;
955 /**
956 * Return elements exists in target but not exists in other.
957 */
958 function diff(target, other) {
959 var result = [];
960 for (var i = target.length - 1; i >= 0; --i) {
961 var value = target[i];
962 if (other.indexOf(value) === -1) {
963 result.push(value);
964 }
965 }
966 return result;
967 }
968 ArrayExtensions.diff = diff;
969 /**
970 * Return an array with only the distinct items in the source.
971 */
972 function distinct(source) {
973 var result = [];
974 for (var i = 0, len = source.length; i < len; i++) {
975 var value = source[i];
976 if (result.indexOf(value) === -1) {
977 result.push(value);
978 }
979 }
980 return result;
981 }
982 ArrayExtensions.distinct = distinct;
983 /**
984 * Pushes content of source onto target,
985 * for parts of course that do not already exist in target.
986 */
987 function union(target, source) {
988 for (var i = 0, len = source.length; i < len; ++i) {
989 unionSingle(target, source[i]);
990 }
991 }
992 ArrayExtensions.union = union;
993 /**
994 * Pushes value onto target, if value does not already exist in target.
995 */
996 function unionSingle(target, value) {
997 if (target.indexOf(value) < 0) {
998 target.push(value);
999 }
1000 }
1001 ArrayExtensions.unionSingle = unionSingle;
1002 /**
1003 * Returns an array with a range of items from source,
1004 * including the startIndex & endIndex.
1005 */
1006 function range(source, startIndex, endIndex) {
1007 debug.assert(startIndex >= 0 && startIndex < source.length, 'startIndex is out of range.');
1008 debug.assert(endIndex >= 0 && endIndex < source.length, 'endIndex is out of range.');
1009 var result = [];
1010 for (var i = startIndex; i <= endIndex; ++i) {
1011 result.push(source[i]);
1012 }
1013 return result;
1014 }
1015 ArrayExtensions.range = range;
1016 /**
1017 * Returns an array that includes items from source, up to the specified count.
1018 */
1019 function take(source, count) {
1020 debug.assert(count >= 0, 'Count is negative.');
1021 debug.assert(count <= source.length, 'Count is too large.');
1022 var result = [];
1023 for (var i = 0; i < count; ++i) {
1024 result.push(source[i]);
1025 }
1026 return result;
1027 }
1028 ArrayExtensions.take = take;
1029 function copy(source) {
1030 debug.assertValue(source, 'source');
1031 return take(source, source.length);
1032 }
1033 ArrayExtensions.copy = copy;
1034 /**
1035 * Returns a value indicating whether the arrays have the same values in the same sequence.
1036 */
1037 function sequenceEqual(left, right, comparison) {
1038 debug.assertValue(comparison, 'comparison');
1039 if (left === right) {
1040 return true;
1041 }
1042 if (!!left !== !!right) {
1043 return false;
1044 }
1045 var len = left.length;
1046 if (len !== right.length) {
1047 return false;
1048 }
1049 var i = 0;
1050 while (i < len && comparison(left[i], right[i])) {
1051 ++i;
1052 }
1053 return i === len;
1054 }
1055 ArrayExtensions.sequenceEqual = sequenceEqual;
1056 /**
1057 * Returns null if the specified array is empty.
1058 * Otherwise returns the specified array.
1059 */
1060 function emptyToNull(array) {
1061 if (array && array.length === 0) {
1062 return null;
1063 }
1064 return array;
1065 }
1066 ArrayExtensions.emptyToNull = emptyToNull;
1067 function indexOf(array, predicate) {
1068 debug.assertValue(array, 'array');
1069 debug.assertValue(predicate, 'predicate');
1070 for (var i = 0, len = array.length; i < len; ++i) {
1071 if (predicate(array[i])) {
1072 return i;
1073 }
1074 }
1075 return -1;
1076 }
1077 ArrayExtensions.indexOf = indexOf;
1078 /**
1079 * Returns a copy of the array rotated by the specified offset.
1080 */
1081 function rotate(array, offset) {
1082 if (offset === 0)
1083 return array.slice();
1084 var rotated = array.slice(offset);
1085 Array.prototype.push.apply(rotated, array.slice(0, offset));
1086 return rotated;
1087 }
1088 ArrayExtensions.rotate = rotate;
1089 function createWithId() {
1090 return extendWithId([]);
1091 }
1092 ArrayExtensions.createWithId = createWithId;
1093 function extendWithId(array) {
1094 debug.assertValue(array, 'array');
1095 var extended = array;
1096 extended.withId = withId;
1097 return extended;
1098 }
1099 ArrayExtensions.extendWithId = extendWithId;
1100 /**
1101 * Finds and returns the first item with a matching ID.
1102 */
1103 function findWithId(array, id) {
1104 for (var i = 0, len = array.length; i < len; i++) {
1105 var item = array[i];
1106 if (item.id === id)
1107 return item;
1108 }
1109 }
1110 ArrayExtensions.findWithId = findWithId;
1111 function withId(id) {
1112 return ArrayExtensions.findWithId(this, id);
1113 }
1114 function createWithName() {
1115 return extendWithName([]);
1116 }
1117 ArrayExtensions.createWithName = createWithName;
1118 function extendWithName(array) {
1119 debug.assertValue(array, 'array');
1120 var extended = array;
1121 extended.withName = withName;
1122 return extended;
1123 }
1124 ArrayExtensions.extendWithName = extendWithName;
1125 function findItemWithName(array, name) {
1126 var index = indexWithName(array, name);
1127 if (index >= 0)
1128 return array[index];
1129 }
1130 ArrayExtensions.findItemWithName = findItemWithName;
1131 function indexWithName(array, name) {
1132 for (var i = 0, len = array.length; i < len; i++) {
1133 var item = array[i];
1134 if (item.name === name)
1135 return i;
1136 }
1137 return -1;
1138 }
1139 ArrayExtensions.indexWithName = indexWithName;
1140 /**
1141 * Inserts a number in sorted order into a list of numbers already in sorted order.
1142 * @returns True if the item was added, false if it already existed.
1143 */
1144 function insertSorted(list, value) {
1145 debug.assertValue(list, 'list');
1146 debug.assertValue(value, 'value');
1147 var len = list.length;
1148 // NOTE: iterate backwards because incoming values tend to be sorted already.
1149 for (var i = len - 1; i >= 0; i--) {
1150 var diff_1 = list[i] - value;
1151 if (diff_1 === 0)
1152 return false;
1153 if (diff_1 > 0)
1154 continue;
1155 // diff < 0
1156 list.splice(i + 1, 0, value);
1157 return true;
1158 }
1159 list.unshift(value);
1160 return true;
1161 }
1162 ArrayExtensions.insertSorted = insertSorted;
1163 /**
1164 * Removes the first occurrence of a value from a list if it exists.
1165 * @returns True if the value was removed, false if it did not exist in the list.
1166 */
1167 function removeFirst(list, value) {
1168 var index = list.indexOf(value);
1169 if (index < 0)
1170 return false;
1171 list.splice(index, 1);
1172 return true;
1173 }
1174 ArrayExtensions.removeFirst = removeFirst;
1175 /**
1176 * Finds and returns the first item with a matching name.
1177 */
1178 function withName(name) {
1179 var array = this;
1180 return findItemWithName(array, name);
1181 }
1182 /**
1183 * Deletes all items from the array.
1184 */
1185 function clear(array) {
1186 if (!array)
1187 return;
1188 while (array.length > 0)
1189 array.pop();
1190 }
1191 ArrayExtensions.clear = clear;
1192 function isUndefinedOrEmpty(array) {
1193 if (!array || array.length === 0) {
1194 return true;
1195 }
1196 return false;
1197 }
1198 ArrayExtensions.isUndefinedOrEmpty = isUndefinedOrEmpty;
1199 function swap(array, firstIndex, secondIndex) {
1200 var temp = array[firstIndex];
1201 array[firstIndex] = array[secondIndex];
1202 array[secondIndex] = temp;
1203 }
1204 ArrayExtensions.swap = swap;
1205 function isInArray(array, lookupItem, compareCallback) {
1206 return _.any(array, function (item) { return compareCallback(item, lookupItem); });
1207 }
1208 ArrayExtensions.isInArray = isInArray;
1209 /** Checks if the given object is an Array, and looking all the way up the prototype chain. */
1210 function isArrayOrInheritedArray(obj) {
1211 debug.assertValue(obj, 'obj');
1212 var nextPrototype = obj;
1213 while (nextPrototype != null) {
1214 if (_.isArray(nextPrototype))
1215 return true;
1216 nextPrototype = Object.getPrototypeOf(nextPrototype);
1217 }
1218 return false;
1219 }
1220 ArrayExtensions.isArrayOrInheritedArray = isArrayOrInheritedArray;
1221 })(ArrayExtensions = jsCommon.ArrayExtensions || (jsCommon.ArrayExtensions = {}));
1222})(jsCommon || (jsCommon = {}));
1223/*
1224 * Power BI Visualizations
1225 *
1226 * Copyright (c) Microsoft Corporation
1227 * All rights reserved.
1228 * MIT License
1229 *
1230 * Permission is hereby granted, free of charge, to any person obtaining a copy
1231 * of this software and associated documentation files (the ""Software""), to deal
1232 * in the Software without restriction, including without limitation the rights
1233 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1234 * copies of the Software, and to permit persons to whom the Software is
1235 * furnished to do so, subject to the following conditions:
1236 *
1237 * The above copyright notice and this permission notice shall be included in
1238 * all copies or substantial portions of the Software.
1239 *
1240 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1241 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1242 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1243 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1244 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1245 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1246 * THE SOFTWARE.
1247 */
1248var InJs;
1249(function (InJs) {
1250 var DomFactory;
1251 (function (DomFactory) {
1252 function div() {
1253 return $('<div/>');
1254 }
1255 DomFactory.div = div;
1256 function span() {
1257 return $('<span/>');
1258 }
1259 DomFactory.span = span;
1260 function checkbox() {
1261 return $('<input type="checkbox"/>');
1262 }
1263 DomFactory.checkbox = checkbox;
1264 function ul() {
1265 return $('<ul/>');
1266 }
1267 DomFactory.ul = ul;
1268 function li() {
1269 return $('<li/>');
1270 }
1271 DomFactory.li = li;
1272 function button() {
1273 return $('<input type="button"/>');
1274 }
1275 DomFactory.button = button;
1276 function select() {
1277 return $('<select/>');
1278 }
1279 DomFactory.select = select;
1280 function textBox() {
1281 return $('<input type="text"/>');
1282 }
1283 DomFactory.textBox = textBox;
1284 function img() {
1285 return $('<img/>');
1286 }
1287 DomFactory.img = img;
1288 function iframe() {
1289 return $('<iframe/>');
1290 }
1291 DomFactory.iframe = iframe;
1292 })(DomFactory = InJs.DomFactory || (InJs.DomFactory = {}));
1293})(InJs || (InJs = {}));
1294/*
1295 * Power BI Visualizations
1296 *
1297 * Copyright (c) Microsoft Corporation
1298 * All rights reserved.
1299 * MIT License
1300 *
1301 * Permission is hereby granted, free of charge, to any person obtaining a copy
1302 * of this software and associated documentation files (the ""Software""), to deal
1303 * in the Software without restriction, including without limitation the rights
1304 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1305 * copies of the Software, and to permit persons to whom the Software is
1306 * furnished to do so, subject to the following conditions:
1307 *
1308 * The above copyright notice and this permission notice shall be included in
1309 * all copies or substantial portions of the Software.
1310 *
1311 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1312 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1313 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1314 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1315 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1316 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1317 * THE SOFTWARE.
1318 */
1319var powerbi;
1320(function (powerbi) {
1321 /**
1322 * Module Double contains a set of constants and precision based utility methods
1323 * for dealing with doubles and their decimal garbage in the javascript.
1324 */
1325 var Double;
1326 (function (Double) {
1327 // Constants.
1328 Double.MIN_VALUE = -Number.MAX_VALUE;
1329 Double.MAX_VALUE = Number.MAX_VALUE;
1330 Double.MIN_EXP = -308;
1331 Double.MAX_EXP = 308;
1332 Double.EPSILON = 1E-323;
1333 Double.DEFAULT_PRECISION = 0.0001;
1334 Double.DEFAULT_PRECISION_IN_DECIMAL_DIGITS = 12;
1335 Double.LOG_E_10 = Math.log(10);
1336 Double.POSITIVE_POWERS = [
1337 1E0, 1E1, 1E2, 1E3, 1E4, 1E5, 1E6, 1E7, 1E8, 1E9, 1E10, 1E11, 1E12, 1E13, 1E14, 1E15, 1E16, 1E17, 1E18, 1E19, 1E20, 1E21, 1E22, 1E23, 1E24, 1E25, 1E26, 1E27, 1E28, 1E29, 1E30, 1E31, 1E32, 1E33, 1E34, 1E35, 1E36, 1E37, 1E38, 1E39, 1E40, 1E41, 1E42, 1E43, 1E44, 1E45, 1E46, 1E47, 1E48, 1E49, 1E50, 1E51, 1E52, 1E53, 1E54, 1E55, 1E56, 1E57, 1E58, 1E59, 1E60, 1E61, 1E62, 1E63, 1E64, 1E65, 1E66, 1E67, 1E68, 1E69, 1E70, 1E71, 1E72, 1E73, 1E74, 1E75, 1E76, 1E77, 1E78, 1E79, 1E80, 1E81, 1E82, 1E83, 1E84, 1E85, 1E86, 1E87, 1E88, 1E89, 1E90, 1E91, 1E92, 1E93, 1E94, 1E95, 1E96, 1E97, 1E98, 1E99,
1338 1E100, 1E101, 1E102, 1E103, 1E104, 1E105, 1E106, 1E107, 1E108, 1E109, 1E110, 1E111, 1E112, 1E113, 1E114, 1E115, 1E116, 1E117, 1E118, 1E119, 1E120, 1E121, 1E122, 1E123, 1E124, 1E125, 1E126, 1E127, 1E128, 1E129, 1E130, 1E131, 1E132, 1E133, 1E134, 1E135, 1E136, 1E137, 1E138, 1E139, 1E140, 1E141, 1E142, 1E143, 1E144, 1E145, 1E146, 1E147, 1E148, 1E149, 1E150, 1E151, 1E152, 1E153, 1E154, 1E155, 1E156, 1E157, 1E158, 1E159, 1E160, 1E161, 1E162, 1E163, 1E164, 1E165, 1E166, 1E167, 1E168, 1E169, 1E170, 1E171, 1E172, 1E173, 1E174, 1E175, 1E176, 1E177, 1E178, 1E179, 1E180, 1E181, 1E182, 1E183, 1E184, 1E185, 1E186, 1E187, 1E188, 1E189, 1E190, 1E191, 1E192, 1E193, 1E194, 1E195, 1E196, 1E197, 1E198, 1E199,
1339 1E200, 1E201, 1E202, 1E203, 1E204, 1E205, 1E206, 1E207, 1E208, 1E209, 1E210, 1E211, 1E212, 1E213, 1E214, 1E215, 1E216, 1E217, 1E218, 1E219, 1E220, 1E221, 1E222, 1E223, 1E224, 1E225, 1E226, 1E227, 1E228, 1E229, 1E230, 1E231, 1E232, 1E233, 1E234, 1E235, 1E236, 1E237, 1E238, 1E239, 1E240, 1E241, 1E242, 1E243, 1E244, 1E245, 1E246, 1E247, 1E248, 1E249, 1E250, 1E251, 1E252, 1E253, 1E254, 1E255, 1E256, 1E257, 1E258, 1E259, 1E260, 1E261, 1E262, 1E263, 1E264, 1E265, 1E266, 1E267, 1E268, 1E269, 1E270, 1E271, 1E272, 1E273, 1E274, 1E275, 1E276, 1E277, 1E278, 1E279, 1E280, 1E281, 1E282, 1E283, 1E284, 1E285, 1E286, 1E287, 1E288, 1E289, 1E290, 1E291, 1E292, 1E293, 1E294, 1E295, 1E296, 1E297, 1E298, 1E299,
1340 1E300, 1E301, 1E302, 1E303, 1E304, 1E305, 1E306, 1E307, 1E308];
1341 Double.NEGATIVE_POWERS = [
1342 1E0, 1E-1, 1E-2, 1E-3, 1E-4, 1E-5, 1E-6, 1E-7, 1E-8, 1E-9, 1E-10, 1E-11, 1E-12, 1E-13, 1E-14, 1E-15, 1E-16, 1E-17, 1E-18, 1E-19, 1E-20, 1E-21, 1E-22, 1E-23, 1E-24, 1E-25, 1E-26, 1E-27, 1E-28, 1E-29, 1E-30, 1E-31, 1E-32, 1E-33, 1E-34, 1E-35, 1E-36, 1E-37, 1E-38, 1E-39, 1E-40, 1E-41, 1E-42, 1E-43, 1E-44, 1E-45, 1E-46, 1E-47, 1E-48, 1E-49, 1E-50, 1E-51, 1E-52, 1E-53, 1E-54, 1E-55, 1E-56, 1E-57, 1E-58, 1E-59, 1E-60, 1E-61, 1E-62, 1E-63, 1E-64, 1E-65, 1E-66, 1E-67, 1E-68, 1E-69, 1E-70, 1E-71, 1E-72, 1E-73, 1E-74, 1E-75, 1E-76, 1E-77, 1E-78, 1E-79, 1E-80, 1E-81, 1E-82, 1E-83, 1E-84, 1E-85, 1E-86, 1E-87, 1E-88, 1E-89, 1E-90, 1E-91, 1E-92, 1E-93, 1E-94, 1E-95, 1E-96, 1E-97, 1E-98, 1E-99,
1343 1E-100, 1E-101, 1E-102, 1E-103, 1E-104, 1E-105, 1E-106, 1E-107, 1E-108, 1E-109, 1E-110, 1E-111, 1E-112, 1E-113, 1E-114, 1E-115, 1E-116, 1E-117, 1E-118, 1E-119, 1E-120, 1E-121, 1E-122, 1E-123, 1E-124, 1E-125, 1E-126, 1E-127, 1E-128, 1E-129, 1E-130, 1E-131, 1E-132, 1E-133, 1E-134, 1E-135, 1E-136, 1E-137, 1E-138, 1E-139, 1E-140, 1E-141, 1E-142, 1E-143, 1E-144, 1E-145, 1E-146, 1E-147, 1E-148, 1E-149, 1E-150, 1E-151, 1E-152, 1E-153, 1E-154, 1E-155, 1E-156, 1E-157, 1E-158, 1E-159, 1E-160, 1E-161, 1E-162, 1E-163, 1E-164, 1E-165, 1E-166, 1E-167, 1E-168, 1E-169, 1E-170, 1E-171, 1E-172, 1E-173, 1E-174, 1E-175, 1E-176, 1E-177, 1E-178, 1E-179, 1E-180, 1E-181, 1E-182, 1E-183, 1E-184, 1E-185, 1E-186, 1E-187, 1E-188, 1E-189, 1E-190, 1E-191, 1E-192, 1E-193, 1E-194, 1E-195, 1E-196, 1E-197, 1E-198, 1E-199,
1344 1E-200, 1E-201, 1E-202, 1E-203, 1E-204, 1E-205, 1E-206, 1E-207, 1E-208, 1E-209, 1E-210, 1E-211, 1E-212, 1E-213, 1E-214, 1E-215, 1E-216, 1E-217, 1E-218, 1E-219, 1E-220, 1E-221, 1E-222, 1E-223, 1E-224, 1E-225, 1E-226, 1E-227, 1E-228, 1E-229, 1E-230, 1E-231, 1E-232, 1E-233, 1E-234, 1E-235, 1E-236, 1E-237, 1E-238, 1E-239, 1E-240, 1E-241, 1E-242, 1E-243, 1E-244, 1E-245, 1E-246, 1E-247, 1E-248, 1E-249, 1E-250, 1E-251, 1E-252, 1E-253, 1E-254, 1E-255, 1E-256, 1E-257, 1E-258, 1E-259, 1E-260, 1E-261, 1E-262, 1E-263, 1E-264, 1E-265, 1E-266, 1E-267, 1E-268, 1E-269, 1E-270, 1E-271, 1E-272, 1E-273, 1E-274, 1E-275, 1E-276, 1E-277, 1E-278, 1E-279, 1E-280, 1E-281, 1E-282, 1E-283, 1E-284, 1E-285, 1E-286, 1E-287, 1E-288, 1E-289, 1E-290, 1E-291, 1E-292, 1E-293, 1E-294, 1E-295, 1E-296, 1E-297, 1E-298, 1E-299,
1345 1E-300, 1E-301, 1E-302, 1E-303, 1E-304, 1E-305, 1E-306, 1E-307, 1E-308, 1E-309, 1E-310, 1E-311, 1E-312, 1E-313, 1E-314, 1E-315, 1E-316, 1E-317, 1E-318, 1E-319, 1E-320, 1E-321, 1E-322, 1E-323, 1E-324];
1346 /**
1347 * Returns powers of 10.
1348 * Unlike the Math.pow this function produces no decimal garbage.
1349 * @param exp Exponent.
1350 */
1351 function pow10(exp) {
1352 debug.assertValue(exp, "exp");
1353 // Positive & zero
1354 if (exp >= 0) {
1355 if (exp < Double.POSITIVE_POWERS.length) {
1356 return Double.POSITIVE_POWERS[exp];
1357 }
1358 else {
1359 return Infinity;
1360 }
1361 }
1362 // Negative
1363 exp = -exp;
1364 if (exp > 0 && exp < Double.NEGATIVE_POWERS.length) {
1365 return Double.NEGATIVE_POWERS[exp];
1366 }
1367 else {
1368 return 0;
1369 }
1370 }
1371 Double.pow10 = pow10;
1372 /**
1373 * Returns the 10 base logarithm of the number.
1374 * Unlike Math.log function this produces integer results with no decimal garbage.
1375 * @param val Positive value or zero.
1376 */
1377 function log10(val) {
1378 debug.assert(val >= 0, "val");
1379 // Fast Log10() algorithm
1380 if (val > 1 && val < 1E16) {
1381 if (val < 1E8) {
1382 if (val < 1E4) {
1383 if (val < 1E2) {
1384 if (val < 1E1) {
1385 return 0;
1386 }
1387 else {
1388 return 1;
1389 }
1390 }
1391 else {
1392 if (val < 1E3) {
1393 return 2;
1394 }
1395 else {
1396 return 3;
1397 }
1398 }
1399 }
1400 else {
1401 if (val < 1E6) {
1402 if (val < 1E5) {
1403 return 4;
1404 }
1405 else {
1406 return 5;
1407 }
1408 }
1409 else {
1410 if (val < 1E7) {
1411 return 6;
1412 }
1413 else {
1414 return 7;
1415 }
1416 }
1417 }
1418 }
1419 else {
1420 if (val < 1E12) {
1421 if (val < 1E10) {
1422 if (val < 1E9) {
1423 return 8;
1424 }
1425 else {
1426 return 9;
1427 }
1428 }
1429 else {
1430 if (val < 1E11) {
1431 return 10;
1432 }
1433 else {
1434 return 11;
1435 }
1436 }
1437 }
1438 else {
1439 if (val < 1E14) {
1440 if (val < 1E13) {
1441 return 12;
1442 }
1443 else {
1444 return 13;
1445 }
1446 }
1447 else {
1448 if (val < 1E15) {
1449 return 14;
1450 }
1451 else {
1452 return 15;
1453 }
1454 }
1455 }
1456 }
1457 }
1458 if (val > 1E-16 && val < 1) {
1459 if (val < 1E-8) {
1460 if (val < 1E-12) {
1461 if (val < 1E-14) {
1462 if (val < 1E-15) {
1463 return -16;
1464 }
1465 else {
1466 return -15;
1467 }
1468 }
1469 else {
1470 if (val < 1E-13) {
1471 return -14;
1472 }
1473 else {
1474 return -13;
1475 }
1476 }
1477 }
1478 else {
1479 if (val < 1E-10) {
1480 if (val < 1E-11) {
1481 return -12;
1482 }
1483 else {
1484 return -11;
1485 }
1486 }
1487 else {
1488 if (val < 1E-9) {
1489 return -10;
1490 }
1491 else {
1492 return -9;
1493 }
1494 }
1495 }
1496 }
1497 else {
1498 if (val < 1E-4) {
1499 if (val < 1E-6) {
1500 if (val < 1E-7) {
1501 return -8;
1502 }
1503 else {
1504 return -7;
1505 }
1506 }
1507 else {
1508 if (val < 1E-5) {
1509 return -6;
1510 }
1511 else {
1512 return -5;
1513 }
1514 }
1515 }
1516 else {
1517 if (val < 1E-2) {
1518 if (val < 1E-3) {
1519 return -4;
1520 }
1521 else {
1522 return -3;
1523 }
1524 }
1525 else {
1526 if (val < 1E-1) {
1527 return -2;
1528 }
1529 else {
1530 return -1;
1531 }
1532 }
1533 }
1534 }
1535 }
1536 // JS Math provides only natural log function so we need to calc the 10 base logarithm:
1537 // logb(x) = logk(x)/logk(b);
1538 var log10 = Math.log(val) / Double.LOG_E_10;
1539 return Double.floorWithPrecision(log10);
1540 }
1541 Double.log10 = log10;
1542 /**
1543 * Returns a power of 10 representing precision of the number based on the number of meaningful decimal digits.
1544 * For example the precision of 56,263.3767 with the 6 meaningful decimal digit is 0.1.
1545 * @param x Value.
1546 * @param decimalDigits How many decimal digits are meaningfull.
1547 */
1548 function getPrecision(x, decimalDigits) {
1549 if (decimalDigits === undefined) {
1550 decimalDigits = Double.DEFAULT_PRECISION_IN_DECIMAL_DIGITS;
1551 }
1552 else {
1553 debug.assert(decimalDigits >= 0, "decimalDigits");
1554 }
1555 if (!x) {
1556 return undefined;
1557 }
1558 var exp = Double.log10(Math.abs(x));
1559 if (exp < Double.MIN_EXP) {
1560 return 0;
1561 }
1562 var precisionExp = Math.max(exp - decimalDigits, -Double.NEGATIVE_POWERS.length + 1);
1563 return Double.pow10(precisionExp);
1564 }
1565 Double.getPrecision = getPrecision;
1566 /**
1567 * Checks if a delta between 2 numbers is less than provided precision.
1568 * @param x One value.
1569 * @param y Another value.
1570 * @param precision Precision value.
1571 */
1572 function equalWithPrecision(x, y, precision) {
1573 precision = applyDefault(precision, Double.DEFAULT_PRECISION);
1574 debug.assert(precision >= 0, "precision");
1575 return x === y || Math.abs(x - y) < precision;
1576 }
1577 Double.equalWithPrecision = equalWithPrecision;
1578 /**
1579 * Checks if a first value is less than another taking
1580 * into account the loose precision based equality.
1581 * @param x One value.
1582 * @param y Another value.
1583 * @param precision Precision value.
1584 */
1585 function lessWithPrecision(x, y, precision) {
1586 precision = applyDefault(precision, Double.DEFAULT_PRECISION);
1587 debug.assert(precision >= 0, "precision");
1588 return x < y && Math.abs(x - y) > precision;
1589 }
1590 Double.lessWithPrecision = lessWithPrecision;
1591 /**
1592 * Checks if a first value is less or equal than another taking
1593 * into account the loose precision based equality.
1594 * @param x One value.
1595 * @param y Another value.
1596 * @param precision Precision value.
1597 */
1598 function lessOrEqualWithPrecision(x, y, precision) {
1599 precision = applyDefault(precision, Double.DEFAULT_PRECISION);
1600 debug.assert(precision >= 0, "precision");
1601 return x < y || Math.abs(x - y) < precision;
1602 }
1603 Double.lessOrEqualWithPrecision = lessOrEqualWithPrecision;
1604 /**
1605 * Checks if a first value is greater than another taking
1606 * into account the loose precision based equality.
1607 * @param x One value.
1608 * @param y Another value.
1609 * @param precision Precision value.
1610 */
1611 function greaterWithPrecision(x, y, precision) {
1612 precision = applyDefault(precision, Double.DEFAULT_PRECISION);
1613 debug.assert(precision >= 0, "precision");
1614 return x > y && Math.abs(x - y) > precision;
1615 }
1616 Double.greaterWithPrecision = greaterWithPrecision;
1617 /**
1618 * Checks if a first value is greater or equal to another taking
1619 * into account the loose precision based equality.
1620 * @param x One value.
1621 * @param y Another value.
1622 * @param precision Precision value.
1623 */
1624 function greaterOrEqualWithPrecision(x, y, precision) {
1625 precision = applyDefault(precision, Double.DEFAULT_PRECISION);
1626 debug.assert(precision >= 0, "precision");
1627 return x > y || Math.abs(x - y) < precision;
1628 }
1629 Double.greaterOrEqualWithPrecision = greaterOrEqualWithPrecision;
1630 /**
1631 * Floors the number unless it's withing the precision distance from the higher int.
1632 * @param x One value.
1633 * @param precision Precision value.
1634 */
1635 function floorWithPrecision(x, precision) {
1636 precision = applyDefault(precision, Double.DEFAULT_PRECISION);
1637 debug.assert(precision >= 0, "precision");
1638 var roundX = Math.round(x);
1639 if (Math.abs(x - roundX) < precision) {
1640 return roundX;
1641 }
1642 else {
1643 return Math.floor(x);
1644 }
1645 }
1646 Double.floorWithPrecision = floorWithPrecision;
1647 /**
1648 * Ceils the number unless it's withing the precision distance from the lower int.
1649 * @param x One value.
1650 * @param precision Precision value.
1651 */
1652 function ceilWithPrecision(x, precision) {
1653 precision = applyDefault(precision, Double.DEFAULT_PRECISION);
1654 debug.assert(precision >= 0, "precision");
1655 var roundX = Math.round(x);
1656 if (Math.abs(x - roundX) < precision) {
1657 return roundX;
1658 }
1659 else {
1660 return Math.ceil(x);
1661 }
1662 }
1663 Double.ceilWithPrecision = ceilWithPrecision;
1664 /**
1665 * Floors the number to the provided precision.
1666 * For example 234,578 floored to 1,000 precision is 234,000.
1667 * @param x One value.
1668 * @param precision Precision value.
1669 */
1670 function floorToPrecision(x, precision) {
1671 precision = applyDefault(precision, Double.DEFAULT_PRECISION);
1672 debug.assert(precision >= 0, "precision");
1673 if (precision === 0 || x === 0) {
1674 return x;
1675 }
1676 //Precision must be a Power of 10
1677 return Math.floor(x / precision) * precision;
1678 }
1679 Double.floorToPrecision = floorToPrecision;
1680 /**
1681 * Ceils the number to the provided precision.
1682 * For example 234,578 floored to 1,000 precision is 235,000.
1683 * @param x One value.
1684 * @param precision Precision value.
1685 */
1686 function ceilToPrecision(x, precision) {
1687 precision = applyDefault(precision, Double.DEFAULT_PRECISION);
1688 debug.assert(precision >= 0, "precision");
1689 if (precision === 0 || x === 0) {
1690 return x;
1691 }
1692 //Precision must be a Power of 10
1693 return Math.ceil(x / precision) * precision;
1694 }
1695 Double.ceilToPrecision = ceilToPrecision;
1696 /**
1697 * Rounds the number to the provided precision.
1698 * For example 234,578 floored to 1,000 precision is 235,000.
1699 * @param x One value.
1700 * @param precision Precision value.
1701 */
1702 function roundToPrecision(x, precision) {
1703 precision = applyDefault(precision, Double.DEFAULT_PRECISION);
1704 debug.assert(precision >= 0, "precision");
1705 if (precision === 0 || x === 0) {
1706 return x;
1707 }
1708 //Precision must be a Power of 10
1709 var result = Math.round(x / precision) * precision;
1710 var decimalDigits = Math.round(Double.log10(Math.abs(x)) - Double.log10(precision)) + 1;
1711 if (decimalDigits > 0 && decimalDigits < 16) {
1712 result = parseFloat(result.toPrecision(decimalDigits));
1713 }
1714 return result;
1715 }
1716 Double.roundToPrecision = roundToPrecision;
1717 /**
1718 * Returns the value making sure that it's restricted to the provided range.
1719 * @param x One value.
1720 * @param min Range min boundary.
1721 * @param max Range max boundary.
1722 */
1723 function ensureInRange(x, min, max) {
1724 debug.assert(min <= max, "min must be less or equal to max");
1725 if (x === undefined || x === null) {
1726 return x;
1727 }
1728 if (x < min) {
1729 return min;
1730 }
1731 if (x > max) {
1732 return max;
1733 }
1734 return x;
1735 }
1736 Double.ensureInRange = ensureInRange;
1737 /**
1738 * Rounds the value - this method is actually faster than Math.round - used in the graphics utils.
1739 * @param x Value to round.
1740 */
1741 function round(x) {
1742 debug.assert(x >= 0, "x must be greater or equal to 0");
1743 return (0.5 + x) << 0;
1744 }
1745 Double.round = round;
1746 /**
1747 * Projects the value from the source range into the target range.
1748 * @param value Value to project.
1749 * @param fromMin Minimum of the source range.
1750 * @param toMin Minimum of the target range.
1751 * @param toMax Maximum of the target range.
1752 */
1753 function project(value, fromMin, fromSize, toMin, toSize) {
1754 if (fromSize === 0 || toSize === 0) {
1755 if (fromMin <= value && value <= fromMin + fromSize) {
1756 return toMin;
1757 }
1758 else {
1759 return NaN;
1760 }
1761 }
1762 var relativeX = (value - fromMin) / fromSize;
1763 var projectedX = toMin + relativeX * toSize;
1764 return projectedX;
1765 }
1766 Double.project = project;
1767 /**
1768 * Removes decimal noise.
1769 * @param value Value to be processed.
1770 */
1771 function removeDecimalNoise(value) {
1772 return roundToPrecision(value, getPrecision(value));
1773 }
1774 Double.removeDecimalNoise = removeDecimalNoise;
1775 /**
1776 * Checks whether the number is integer.
1777 * @param value Value to be checked.
1778 */
1779 function isInteger(value) {
1780 return value !== null && value % 1 === 0;
1781 }
1782 Double.isInteger = isInteger;
1783 /**
1784 * Dividing by increment will give us count of increments
1785 * Round out the rough edges into even integer
1786 * Multiply back by increment to get rounded value
1787 * e.g. Rounder.toIncrement(0.647291, 0.05) => 0.65
1788 * @param value - value to round to nearest increment
1789 * @param increment - smallest increment to round toward
1790 */
1791 function toIncrement(value, increment) {
1792 return Math.round(value / increment) * increment;
1793 }
1794 Double.toIncrement = toIncrement;
1795 })(Double = powerbi.Double || (powerbi.Double = {}));
1796 function applyDefault(value, defaultValue) {
1797 return value !== undefined ? value : defaultValue;
1798 }
1799})(powerbi || (powerbi = {}));
1800/*
1801 * Power BI Visualizations
1802 *
1803 * Copyright (c) Microsoft Corporation
1804 * All rights reserved.
1805 * MIT License
1806 *
1807 * Permission is hereby granted, free of charge, to any person obtaining a copy
1808 * of this software and associated documentation files (the ""Software""), to deal
1809 * in the Software without restriction, including without limitation the rights
1810 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1811 * copies of the Software, and to permit persons to whom the Software is
1812 * furnished to do so, subject to the following conditions:
1813 *
1814 * The above copyright notice and this permission notice shall be included in
1815 * all copies or substantial portions of the Software.
1816 *
1817 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1818 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1819 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1820 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1821 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1822 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1823 * THE SOFTWARE.
1824 */
1825var jsCommon;
1826(function (jsCommon) {
1827 var Double = powerbi.Double;
1828 var Color;
1829 (function (Color) {
1830 function rotate(rgbString, rotateFactor) {
1831 if (rotateFactor === 0)
1832 return rgbString;
1833 var originalRgb = parseColorString(rgbString);
1834 var originalHsv = rgbToHsv(originalRgb);
1835 var rotatedHsv = rotateHsv(originalHsv, rotateFactor);
1836 var rotatedRgb = hsvToRgb(rotatedHsv);
1837 return hexString(rotatedRgb);
1838 }
1839 Color.rotate = rotate;
1840 function normalizeToHexString(color) {
1841 var rgb = parseColorString(color);
1842 return hexString(rgb);
1843 }
1844 Color.normalizeToHexString = normalizeToHexString;
1845 function parseColorString(color) {
1846 debug.assertValue(color, 'color');
1847 if (color.indexOf('#') >= 0) {
1848 if (color.length === 7) {
1849 // #RRGGBB
1850 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(color);
1851 if (result == null || result.length < 4)
1852 return;
1853 return {
1854 R: parseInt(result[1], 16),
1855 G: parseInt(result[2], 16),
1856 B: parseInt(result[3], 16),
1857 };
1858 }
1859 else if (color.length === 4) {
1860 // #RGB
1861 var result = /^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(color);
1862 if (result == null || result.length < 4)
1863 return;
1864 return {
1865 R: parseInt(result[1] + result[1], 16),
1866 G: parseInt(result[2] + result[2], 16),
1867 B: parseInt(result[3] + result[3], 16),
1868 };
1869 }
1870 }
1871 else if (color.indexOf('rgb(') >= 0) {
1872 // rgb(R, G, B)
1873 var result = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/.exec(color);
1874 if (result == null || result.length < 4)
1875 return;
1876 return {
1877 R: parseInt(result[1], 10),
1878 G: parseInt(result[2], 10),
1879 B: parseInt(result[3], 10),
1880 };
1881 }
1882 else if (color.indexOf('rgba(') >= 0) {
1883 // rgba(R, G, B, A)
1884 var result = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d*(?:\.\d+)?)\)$/.exec(color);
1885 if (result == null || result.length < 5)
1886 return;
1887 return {
1888 R: parseInt(result[1], 10),
1889 G: parseInt(result[2], 10),
1890 B: parseInt(result[3], 10),
1891 A: parseFloat(result[4]),
1892 };
1893 }
1894 }
1895 Color.parseColorString = parseColorString;
1896 function rgbToHsv(rgbColor) {
1897 var s, h;
1898 var r = rgbColor.R / 255, g = rgbColor.G / 255, b = rgbColor.B / 255;
1899 var min = Math.min(r, Math.min(g, b));
1900 var max = Math.max(r, Math.max(g, b));
1901 var v = max;
1902 var delta = max - min;
1903 if (max === 0 || delta === 0) {
1904 // R, G, and B must be 0.0, or all the same.
1905 // In this case, S is 0.0, and H is undefined.
1906 // Using H = 0.0 is as good as any...
1907 s = 0;
1908 h = 0;
1909 }
1910 else {
1911 s = delta / max;
1912 if (r === max) {
1913 // Between Yellow and Magenta
1914 h = (g - b) / delta;
1915 }
1916 else if (g === max) {
1917 // Between Cyan and Yellow
1918 h = 2 + (b - r) / delta;
1919 }
1920 else {
1921 // Between Magenta and Cyan
1922 h = 4 + (r - g) / delta;
1923 }
1924 }
1925 // Scale h to be between 0.0 and 1.
1926 // This may require adding 1, if the value
1927 // is negative.
1928 h /= 6;
1929 if (h < 0) {
1930 h += 1;
1931 }
1932 return {
1933 H: h,
1934 S: s,
1935 V: v,
1936 };
1937 }
1938 function hsvToRgb(hsvColor) {
1939 var r, g, b;
1940 var h = hsvColor.H, s = hsvColor.S, v = hsvColor.V;
1941 if (s === 0) {
1942 // If s is 0, all colors are the same.
1943 // This is some flavor of gray.
1944 r = v;
1945 g = v;
1946 b = v;
1947 }
1948 else {
1949 var p = void 0, q = void 0, t = void 0, fractionalSector = void 0, sectorNumber = void 0, sectorPos = void 0;
1950 // The color wheel consists of 6 sectors.
1951 // Figure out which sector you//re in.
1952 sectorPos = h * 6;
1953 sectorNumber = Math.floor(sectorPos);
1954 // get the fractional part of the sector.
1955 // That is, how many degrees into the sector
1956 // are you?
1957 fractionalSector = sectorPos - sectorNumber;
1958 // Calculate values for the three axes
1959 // of the color.
1960 p = v * (1.0 - s);
1961 q = v * (1.0 - (s * fractionalSector));
1962 t = v * (1.0 - (s * (1 - fractionalSector)));
1963 // Assign the fractional colors to r, g, and b
1964 // based on the sector the angle is in.
1965 switch (sectorNumber) {
1966 case 0:
1967 r = v;
1968 g = t;
1969 b = p;
1970 break;
1971 case 1:
1972 r = q;
1973 g = v;
1974 b = p;
1975 break;
1976 case 2:
1977 r = p;
1978 g = v;
1979 b = t;
1980 break;
1981 case 3:
1982 r = p;
1983 g = q;
1984 b = v;
1985 break;
1986 case 4:
1987 r = t;
1988 g = p;
1989 b = v;
1990 break;
1991 case 5:
1992 r = v;
1993 g = p;
1994 b = q;
1995 break;
1996 }
1997 }
1998 return {
1999 R: Math.floor(r * 255),
2000 G: Math.floor(g * 255),
2001 B: Math.floor(b * 255),
2002 };
2003 }
2004 function rotateHsv(hsvColor, rotateFactor) {
2005 var newH = hsvColor.H + rotateFactor;
2006 return {
2007 H: newH > 1 ? newH - 1 : newH,
2008 S: hsvColor.S,
2009 V: hsvColor.V,
2010 };
2011 }
2012 function darken(color, diff) {
2013 var flooredNumber = Math.floor(diff);
2014 return {
2015 R: Math.max(0, color.R - flooredNumber),
2016 G: Math.max(0, color.G - flooredNumber),
2017 B: Math.max(0, color.B - flooredNumber),
2018 };
2019 }
2020 Color.darken = darken;
2021 function rgbString(color) {
2022 if (color.A == null)
2023 return "rgb(" + color.R + "," + color.G + "," + color.B + ")";
2024 return "rgba(" + color.R + "," + color.G + "," + color.B + "," + color.A + ")";
2025 }
2026 Color.rgbString = rgbString;
2027 function hexString(color) {
2028 return "#" + componentToHex(color.R) + componentToHex(color.G) + componentToHex(color.B);
2029 }
2030 Color.hexString = hexString;
2031 function componentToHex(hexComponent) {
2032 var clamped = Double.ensureInRange(hexComponent, 0, 255);
2033 var hex = clamped.toString(16).toUpperCase();
2034 return hex.length === 1 ? "0" + hex : hex;
2035 }
2036 })(Color = jsCommon.Color || (jsCommon.Color = {}));
2037})(jsCommon || (jsCommon = {}));
2038/*
2039 * Power BI Visualizations
2040 *
2041 * Copyright (c) Microsoft Corporation
2042 * All rights reserved.
2043 * MIT License
2044 *
2045 * Permission is hereby granted, free of charge, to any person obtaining a copy
2046 * of this software and associated documentation files (the ""Software""), to deal
2047 * in the Software without restriction, including without limitation the rights
2048 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2049 * copies of the Software, and to permit persons to whom the Software is
2050 * furnished to do so, subject to the following conditions:
2051 *
2052 * The above copyright notice and this permission notice shall be included in
2053 * all copies or substantial portions of the Software.
2054 *
2055 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2056 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2057 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2058 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2059 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2060 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2061 * THE SOFTWARE.
2062 */
2063var jsCommon;
2064(function (jsCommon) {
2065 /**
2066 * CSS constants.
2067 */
2068 var CssConstants;
2069 (function (CssConstants) {
2070 function createClassAndSelector(className) {
2071 return {
2072 class: className,
2073 selector: '.' + className,
2074 };
2075 }
2076 CssConstants.createClassAndSelector = createClassAndSelector;
2077 CssConstants.styleAttribute = 'style';
2078 CssConstants.pixelUnits = 'px';
2079 CssConstants.heightProperty = 'height';
2080 CssConstants.widthProperty = 'width';
2081 CssConstants.topProperty = 'top';
2082 CssConstants.bottomProperty = 'bottom';
2083 CssConstants.leftProperty = 'left';
2084 CssConstants.rightProperty = 'right';
2085 CssConstants.marginTopProperty = 'margin-top';
2086 CssConstants.marginLeftProperty = 'margin-left';
2087 CssConstants.displayProperty = 'display';
2088 CssConstants.backgroundProperty = 'background';
2089 CssConstants.backgroundColorProperty = 'background-color';
2090 CssConstants.backgroundRepeatProperty = 'background-repeat';
2091 CssConstants.backgroundSizeProperty = 'background-size';
2092 CssConstants.backgroundImageProperty = 'background-image';
2093 CssConstants.textShadowProperty = 'text-shadow';
2094 CssConstants.textAlignProperty = 'text-align';
2095 CssConstants.borderTopWidthProperty = 'border-top-width';
2096 CssConstants.borderBottomWidthProperty = 'border-bottom-width';
2097 CssConstants.borderLeftWidthProperty = 'border-left-width';
2098 CssConstants.borderRightWidthProperty = 'border-right-width';
2099 CssConstants.fontSizeProperty = 'font-size';
2100 CssConstants.fontWeightProperty = 'font-weight';
2101 CssConstants.colorProperty = 'color';
2102 CssConstants.opacityProperty = 'opacity';
2103 CssConstants.paddingLeftProperty = 'padding-left';
2104 CssConstants.paddingRightProperty = 'padding-right';
2105 CssConstants.positionProperty = 'position';
2106 CssConstants.maxWidthProperty = 'max-width';
2107 CssConstants.minWidthProperty = 'min-width';
2108 CssConstants.overflowProperty = 'overflow';
2109 CssConstants.overflowXProperty = 'overflow-x';
2110 CssConstants.overflowYProperty = 'overflow-y';
2111 CssConstants.transformProperty = 'transform';
2112 CssConstants.webkitTransformProperty = '-webkit-transform';
2113 CssConstants.cursorProperty = 'cursor';
2114 CssConstants.visibilityProperty = 'visibility';
2115 CssConstants.absoluteValue = 'absolute';
2116 CssConstants.zeroPixelValue = '0px';
2117 CssConstants.autoValue = 'auto';
2118 CssConstants.hiddenValue = 'hidden';
2119 CssConstants.noneValue = 'none';
2120 CssConstants.blockValue = 'block';
2121 CssConstants.inlineBlockValue = 'inline-block';
2122 CssConstants.transparentValue = 'transparent';
2123 CssConstants.boldValue = 'bold';
2124 CssConstants.visibleValue = 'visible';
2125 CssConstants.tableRowValue = 'table-row';
2126 CssConstants.coverValue = 'cover';
2127 CssConstants.pointerValue = 'pointer';
2128 CssConstants.scrollValue = 'scroll';
2129 })(CssConstants = jsCommon.CssConstants || (jsCommon.CssConstants = {}));
2130})(jsCommon || (jsCommon = {}));
2131/*
2132 * Power BI Visualizations
2133 *
2134 * Copyright (c) Microsoft Corporation
2135 * All rights reserved.
2136 * MIT License
2137 *
2138 * Permission is hereby granted, free of charge, to any person obtaining a copy
2139 * of this software and associated documentation files (the ""Software""), to deal
2140 * in the Software without restriction, including without limitation the rights
2141 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2142 * copies of the Software, and to permit persons to whom the Software is
2143 * furnished to do so, subject to the following conditions:
2144 *
2145 * The above copyright notice and this permission notice shall be included in
2146 * all copies or substantial portions of the Software.
2147 *
2148 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2149 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2150 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2151 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2152 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2153 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2154 * THE SOFTWARE.
2155 */
2156/**
2157 * Defines a Debug object. Calls to any functions in this object removed by the minifier.
2158 * The functions within this class are not minified away, so we use the preprocessor-style
2159 * comments to have the minifier remove those as well.
2160 */
2161///#DEBUG
2162var debug;
2163(function (debug) {
2164 /**
2165 * Asserts that the condition is true, fails otherwise.
2166 */
2167 function assert(condition, message) {
2168 if (condition !== true) {
2169 assertFail(message || ('condition: ' + condition));
2170 }
2171 }
2172 debug.assert = assert;
2173 /**
2174 * Asserts that the value is neither null nor undefined, fails otherwise.
2175 */
2176 function assertValue(value, message) {
2177 if (value === null || value === undefined) {
2178 assertFail(message || ('condition: ' + value));
2179 }
2180 }
2181 debug.assertValue = assertValue;
2182 /**
2183 * Asserts that the value is neither null nor undefined, and has a length property that returns greater than zero, fails otherwise.
2184 */
2185 function assertNonEmpty(value, message) {
2186 if (!(value != null && value.length > 0)) {
2187 assertFail(message || ('condition: ' + value));
2188 }
2189 }
2190 debug.assertNonEmpty = assertNonEmpty;
2191 /**
2192 * Makes no assertion on the given value.
2193 * This is documentation/placeholder that a value is possibly null or undefined (unlike assertValue).
2194 */
2195 function assertAnyValue(value, message) {
2196 }
2197 debug.assertAnyValue = assertAnyValue;
2198 function assertFail(message) {
2199 (debug.assertFailFunction || alert)('Debug Assert failed: ' + message);
2200 }
2201 debug.assertFail = assertFail;
2202})(debug || (debug = {}));
2203///#ENDDEBUG
2204/*
2205 * Power BI Visualizations
2206 *
2207 * Copyright (c) Microsoft Corporation
2208 * All rights reserved.
2209 * MIT License
2210 *
2211 * Permission is hereby granted, free of charge, to any person obtaining a copy
2212 * of this software and associated documentation files (the ""Software""), to deal
2213 * in the Software without restriction, including without limitation the rights
2214 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2215 * copies of the Software, and to permit persons to whom the Software is
2216 * furnished to do so, subject to the following conditions:
2217 *
2218 * The above copyright notice and this permission notice shall be included in
2219 * all copies or substantial portions of the Software.
2220 *
2221 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2222 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2223 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2224 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2225 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2226 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2227 * THE SOFTWARE.
2228 */
2229var jsCommon;
2230(function (jsCommon) {
2231 var Errors;
2232 (function (Errors) {
2233 function infoNavAppAlreadyPresent() {
2234 return {
2235 name: 'infoNavAppAlreadyPresent',
2236 message: 'Cannot initialize embedded scenario when the InfoNav App is already present in this context',
2237 stack: getExceptionStackTrace()
2238 };
2239 }
2240 Errors.infoNavAppAlreadyPresent = infoNavAppAlreadyPresent;
2241 function invalidOperation(message) {
2242 return {
2243 name: 'invalidOperation',
2244 message: message,
2245 stack: getExceptionStackTrace()
2246 };
2247 }
2248 Errors.invalidOperation = invalidOperation;
2249 function argument(argumentName, message) {
2250 return {
2251 name: 'invalidArgumentError',
2252 argument: argumentName,
2253 message: message,
2254 stack: getExceptionStackTrace()
2255 };
2256 }
2257 Errors.argument = argument;
2258 function argumentNull(argumentName) {
2259 return {
2260 name: 'argumentNull',
2261 argument: argumentName,
2262 message: 'Argument was null',
2263 stack: getExceptionStackTrace()
2264 };
2265 }
2266 Errors.argumentNull = argumentNull;
2267 function argumentUndefined(argumentName) {
2268 return {
2269 name: 'argumentUndefined',
2270 argument: argumentName,
2271 message: 'Argument was undefined',
2272 stack: getExceptionStackTrace()
2273 };
2274 }
2275 Errors.argumentUndefined = argumentUndefined;
2276 function argumentOutOfRange(argumentName) {
2277 return {
2278 name: 'argumentOutOfRange',
2279 argument: argumentName,
2280 message: 'Argument was out of range',
2281 stack: getExceptionStackTrace()
2282 };
2283 }
2284 Errors.argumentOutOfRange = argumentOutOfRange;
2285 function pureVirtualMethodException(className, methodName) {
2286 return {
2287 name: 'pureVirtualMethodException',
2288 message: 'This method must be overriden by the derived class:' + className + '.' + methodName,
2289 stack: getExceptionStackTrace()
2290 };
2291 }
2292 Errors.pureVirtualMethodException = pureVirtualMethodException;
2293 function notImplementedException(message) {
2294 return {
2295 name: 'notImplementedException',
2296 message: message,
2297 stack: getExceptionStackTrace()
2298 };
2299 }
2300 Errors.notImplementedException = notImplementedException;
2301 function getExceptionStackTrace() {
2302 return getStackTrace(/*leadingFramesToRemove*/ 2);
2303 }
2304 })(Errors = jsCommon.Errors || (jsCommon.Errors = {}));
2305 /**
2306 * Captures the stack trace, if available.
2307 * It optionally takes the number of frames to remove from the stack trace.
2308 * By default, it removes the last frame to consider the calling type's
2309 * constructor and the temporary error used to capture the stack trace (below).
2310 * More levels can be requested as needed e..g. when an error is created
2311 * from a helper method. <Min requirement: IE10, Chrome, Firefox, Opera>.
2312 */
2313 function getStackTrace(leadingFramesToRemove) {
2314 if (leadingFramesToRemove === void 0) { leadingFramesToRemove = 1; }
2315 var stackTrace, stackSegments;
2316 try {
2317 // needs to throw for stack trace to work in IE
2318 throw new Error();
2319 }
2320 catch (error) {
2321 stackTrace = error.stack;
2322 if (stackTrace != null) {
2323 stackSegments = stackTrace.split('\n');
2324 stackSegments.splice(1, leadingFramesToRemove);
2325 // Finally
2326 stackTrace = stackSegments.join('\n');
2327 }
2328 }
2329 return stackTrace;
2330 }
2331 jsCommon.getStackTrace = getStackTrace;
2332})(jsCommon || (jsCommon = {}));
2333/*
2334 * Power BI Visualizations
2335 *
2336 * Copyright (c) Microsoft Corporation
2337 * All rights reserved.
2338 * MIT License
2339 *
2340 * Permission is hereby granted, free of charge, to any person obtaining a copy
2341 * of this software and associated documentation files (the ""Software""), to deal
2342 * in the Software without restriction, including without limitation the rights
2343 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2344 * copies of the Software, and to permit persons to whom the Software is
2345 * furnished to do so, subject to the following conditions:
2346 *
2347 * The above copyright notice and this permission notice shall be included in
2348 * all copies or substantial portions of the Software.
2349 *
2350 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2351 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2352 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2353 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2354 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2355 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2356 * THE SOFTWARE.
2357 */
2358$.fn.multiline = function (text) {
2359 this.text(text);
2360 this.html(this.html().replace(/\n/g, '<br/>'));
2361 return this;
2362};
2363$.fn.togglePanelControl = function () {
2364 return this.each(function () {
2365 $(this).addClass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset")
2366 .find(".accordionHeader")
2367 .addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom")
2368 .hover(function () {
2369 $(this).toggleClass("ui-state-hover");
2370 })
2371 .prepend('<span class="ui-icon ui-icon-triangle-1-e"></span>')
2372 .click(function () {
2373 $(this)
2374 .toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom")
2375 .find("> .ui-icon").toggleClass("ui-icon-triangle-1-e ui-icon-triangle-1-s").end()
2376 .next().slideToggle();
2377 return false;
2378 })
2379 .next()
2380 .addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom")
2381 .hide();
2382 });
2383};
2384var jsCommon;
2385(function (jsCommon) {
2386 var JQueryConstants;
2387 (function (JQueryConstants) {
2388 JQueryConstants.VisibleSelector = ':visible';
2389 })(JQueryConstants = jsCommon.JQueryConstants || (jsCommon.JQueryConstants = {}));
2390})(jsCommon || (jsCommon = {}));
2391/*
2392 * Power BI Visualizations
2393 *
2394 * Copyright (c) Microsoft Corporation
2395 * All rights reserved.
2396 * MIT License
2397 *
2398 * Permission is hereby granted, free of charge, to any person obtaining a copy
2399 * of this software and associated documentation files (the ""Software""), to deal
2400 * in the Software without restriction, including without limitation the rights
2401 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2402 * copies of the Software, and to permit persons to whom the Software is
2403 * furnished to do so, subject to the following conditions:
2404 *
2405 * The above copyright notice and this permission notice shall be included in
2406 * all copies or substantial portions of the Software.
2407 *
2408 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2409 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2410 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2411 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2412 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2413 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2414 * THE SOFTWARE.
2415 */
2416var jsCommon;
2417(function (jsCommon) {
2418 /**
2419 * Represents a lazily instantiated value.
2420 */
2421 var Lazy = (function () {
2422 function Lazy(factoryMethod) {
2423 jsCommon.Utility.throwIfNullOrUndefined(factoryMethod, this, 'constructor', 'factoryMethod');
2424 this.factoryMethod = factoryMethod;
2425 }
2426 Lazy.prototype.getValue = function () {
2427 if (this.factoryMethod !== null) {
2428 this.value = this.factoryMethod();
2429 // Optimization: Release the factoryMethod, as it could be holding a large object graph.
2430 this.factoryMethod = null;
2431 }
2432 return this.value;
2433 };
2434 return Lazy;
2435 }());
2436 jsCommon.Lazy = Lazy;
2437})(jsCommon || (jsCommon = {}));
2438/*
2439 * Power BI Visualizations
2440 *
2441 * Copyright (c) Microsoft Corporation
2442 * All rights reserved.
2443 * MIT License
2444 *
2445 * Permission is hereby granted, free of charge, to any person obtaining a copy
2446 * of this software and associated documentation files (the ""Software""), to deal
2447 * in the Software without restriction, including without limitation the rights
2448 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2449 * copies of the Software, and to permit persons to whom the Software is
2450 * furnished to do so, subject to the following conditions:
2451 *
2452 * The above copyright notice and this permission notice shall be included in
2453 * all copies or substantial portions of the Software.
2454 *
2455 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2456 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2457 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2458 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2459 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2460 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2461 * THE SOFTWARE.
2462 */
2463var powerbi;
2464(function (powerbi) {
2465 var Prototype;
2466 (function (Prototype) {
2467 /**
2468 * Returns a new object with the provided obj as its prototype.
2469 */
2470 function inherit(obj, extension) {
2471 debug.assertValue(obj, 'obj');
2472 function wrapCtor() { }
2473 ;
2474 wrapCtor.prototype = obj;
2475 var inherited = new wrapCtor();
2476 if (extension)
2477 extension(inherited);
2478 return inherited;
2479 }
2480 Prototype.inherit = inherit;
2481 /**
2482 * Returns a new object with the provided obj as its prototype
2483 * if, and only if, the prototype has not been previously set
2484 */
2485 function inheritSingle(obj) {
2486 debug.assertValue(obj, 'obj');
2487 var proto = Object.getPrototypeOf(obj);
2488 if (proto === Object.prototype || proto === Array.prototype)
2489 obj = inherit(obj);
2490 return obj;
2491 }
2492 Prototype.inheritSingle = inheritSingle;
2493 /**
2494 * Uses the provided callback function to selectively replace contents in the provided array.
2495 * @return A new array with those values overriden
2496 * or undefined if no overrides are necessary.
2497 */
2498 function overrideArray(prototype, override) {
2499 if (!prototype)
2500 return;
2501 var overwritten;
2502 for (var i = 0, len = prototype.length; i < len; i++) {
2503 var value = override(prototype[i]);
2504 if (value) {
2505 if (!overwritten)
2506 overwritten = inherit(prototype);
2507 overwritten[i] = value;
2508 }
2509 }
2510 return overwritten;
2511 }
2512 Prototype.overrideArray = overrideArray;
2513 })(Prototype = powerbi.Prototype || (powerbi.Prototype = {}));
2514})(powerbi || (powerbi = {}));
2515/*
2516 * Power BI Visualizations
2517 *
2518 * Copyright (c) Microsoft Corporation
2519 * All rights reserved.
2520 * MIT License
2521 *
2522 * Permission is hereby granted, free of charge, to any person obtaining a copy
2523 * of this software and associated documentation files (the ""Software""), to deal
2524 * in the Software without restriction, including without limitation the rights
2525 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2526 * copies of the Software, and to permit persons to whom the Software is
2527 * furnished to do so, subject to the following conditions:
2528 *
2529 * The above copyright notice and this permission notice shall be included in
2530 * all copies or substantial portions of the Software.
2531 *
2532 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2533 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2534 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2535 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2536 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2537 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2538 * THE SOFTWARE.
2539 */
2540/*
2541 * Power BI Visualizations
2542 *
2543 * Copyright (c) Microsoft Corporation
2544 * All rights reserved.
2545 * MIT License
2546 *
2547 * Permission is hereby granted, free of charge, to any person obtaining a copy
2548 * of this software and associated documentation files (the ""Software""), to deal
2549 * in the Software without restriction, including without limitation the rights
2550 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2551 * copies of the Software, and to permit persons to whom the Software is
2552 * furnished to do so, subject to the following conditions:
2553 *
2554 * The above copyright notice and this permission notice shall be included in
2555 * all copies or substantial portions of the Software.
2556 *
2557 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2558 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2559 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2560 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2561 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2562 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2563 * THE SOFTWARE.
2564 */
2565/*
2566 * Power BI Visualizations
2567 *
2568 * Copyright (c) Microsoft Corporation
2569 * All rights reserved.
2570 * MIT License
2571 *
2572 * Permission is hereby granted, free of charge, to any person obtaining a copy
2573 * of this software and associated documentation files (the ""Software""), to deal
2574 * in the Software without restriction, including without limitation the rights
2575 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2576 * copies of the Software, and to permit persons to whom the Software is
2577 * furnished to do so, subject to the following conditions:
2578 *
2579 * The above copyright notice and this permission notice shall be included in
2580 * all copies or substantial portions of the Software.
2581 *
2582 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2583 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2584 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2585 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2586 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2587 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2588 * THE SOFTWARE.
2589 */
2590var jsCommon;
2591(function (jsCommon) {
2592 var Formatting;
2593 (function (Formatting) {
2594 var regexCache;
2595 /**
2596 * Translate .NET format into something supported by jQuery.Globalize.
2597 */
2598 function findDateFormat(value, format, cultureName) {
2599 switch (format) {
2600 case "m":
2601 // Month + day
2602 format = "M";
2603 break;
2604 case "O":
2605 case "o":
2606 // Roundtrip
2607 format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'0000'";
2608 break;
2609 case "R":
2610 case "r":
2611 // RFC1123 pattern - - time must be converted to UTC before formatting
2612 value = new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate(), value.getUTCHours(), value.getUTCMinutes(), value.getUTCSeconds(), value.getUTCMilliseconds());
2613 format = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'";
2614 break;
2615 case "s":
2616 // Sortable - should use invariant culture
2617 format = "S";
2618 break;
2619 case "u":
2620 // Universal sortable - should convert to UTC before applying the "yyyy'-'MM'-'dd HH':'mm':'ss'Z' format.
2621 value = new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate(), value.getUTCHours(), value.getUTCMinutes(), value.getUTCSeconds(), value.getUTCMilliseconds());
2622 format = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'";
2623 break;
2624 case "U":
2625 // Universal full - the pattern is same as F but the time must be converted to UTC before formatting
2626 value = new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate(), value.getUTCHours(), value.getUTCMinutes(), value.getUTCSeconds(), value.getUTCMilliseconds());
2627 format = "F";
2628 break;
2629 case "y":
2630 case "Y":
2631 // Year and month
2632 switch (cultureName) {
2633 case "default":
2634 case "en":
2635 case "en-US":
2636 format = "MMMM, yyyy"; // Fix the default year-month pattern for english
2637 break;
2638 default:
2639 format = "Y"; // For other cultures - use the localized pattern
2640 }
2641 break;
2642 }
2643 return { value: value, format: format };
2644 }
2645 Formatting.findDateFormat = findDateFormat;
2646 /**
2647 * Translates unsupported .NET custom format expressions to the custom expressions supported by JQuery.Globalize.
2648 */
2649 function fixDateTimeFormat(format) {
2650 // Fix for the "K" format (timezone):
2651 //The js dates don't have a kind property so we'll support only local kind which is equavalent to zzz format.
2652 format = format.replace(/%K/g, "zzz");
2653 format = format.replace(/K/g, "zzz");
2654 format = format.replace(/fffffff/g, "fff0000");
2655 format = format.replace(/ffffff/g, "fff000");
2656 format = format.replace(/fffff/g, "fff00");
2657 format = format.replace(/ffff/g, "fff0");
2658 // Fix for the 5 digit year: "yyyyy" format.
2659 //The Globalize doesn't support dates greater than 9999 so we replace the "yyyyy" with "0yyyy".
2660 format = format.replace(/yyyyy/g, "0yyyy");
2661 // Fix for the 3 digit year: "yyy" format.
2662 //The Globalize doesn't support this formatting so we need to replace it with the 4 digit year "yyyy" format.
2663 format = format.replace(/(^y|^)yyy(^y|$)/g, "yyyy");
2664 if (!regexCache) {
2665 // Creating Regexes for cases "Using single format specifier"
2666 //- http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx#UsingSingleSpecifiers
2667 // This is not supported from The Globalize.
2668 // The case covers all single "%" lead specifier (like "%d" but not %dd)
2669 // The cases as single "%d" are filtered in if the bellow.
2670 // (?!S) where S is the specifier make sure that we only one symbol for specifier.
2671 regexCache = ["d", "f", "F", "g", "h", "H", "K", "m", "M", "s", "t", "y", "z", ":", "/"].map(function (s) {
2672 return { r: new RegExp("\%" + s + "(?!" + s + ")", "g"), s: s };
2673 });
2674 }
2675 if (format.indexOf("%") !== -1 && format.length > 2) {
2676 for (var i = 0; i < regexCache.length; i++) {
2677 format = format.replace(regexCache[i].r, regexCache[i].s);
2678 }
2679 }
2680 return format;
2681 }
2682 Formatting.fixDateTimeFormat = fixDateTimeFormat;
2683 })(Formatting = jsCommon.Formatting || (jsCommon.Formatting = {}));
2684})(jsCommon || (jsCommon = {}));
2685/*
2686 * Power BI Visualizations
2687 *
2688 * Copyright (c) Microsoft Corporation
2689 * All rights reserved.
2690 * MIT License
2691 *
2692 * Permission is hereby granted, free of charge, to any person obtaining a copy
2693 * of this software and associated documentation files (the ""Software""), to deal
2694 * in the Software without restriction, including without limitation the rights
2695 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2696 * copies of the Software, and to permit persons to whom the Software is
2697 * furnished to do so, subject to the following conditions:
2698 *
2699 * The above copyright notice and this permission notice shall be included in
2700 * all copies or substantial portions of the Software.
2701 *
2702 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2703 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2704 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2705 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2706 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2707 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2708 * THE SOFTWARE.
2709 */
2710var jsCommon;
2711(function (jsCommon) {
2712 var doc = document, headElement = doc.head, firstScriptInHeadElement = headElement.getElementsByTagName('script')[0], linkElement = doc.createElement('link'), scriptElement = doc.createElement('script'), styleSheetLoaded = [], javaScriptFilesLoaded = [], javaScriptFilesLoading = [];
2713 linkElement.setAttribute('rel', 'stylesheet');
2714 function requires(dependency, to) {
2715 if (to === void 0) { to = $.noop; }
2716 loadStyleSheets(dependency.cssFiles || []);
2717 var scriptsToRun = dependency.javaScriptFilesWithCallback || [];
2718 if (dependency.javaScriptFiles) {
2719 for (var i = 0, len = dependency.javaScriptFiles.length; i < len; ++i) {
2720 scriptsToRun.push({ javascriptFile: dependency.javaScriptFiles[i] });
2721 }
2722 }
2723 loadJavaScriptFiles(scriptsToRun, to);
2724 }
2725 jsCommon.requires = requires;
2726 /**
2727 * Private Helpers.
2728 */
2729 function loadStyleSheets(hrefList) {
2730 hrefList.forEach(function (href) {
2731 if (styleSheetLoaded.indexOf(href) === -1) {
2732 styleSheetLoaded.push(href);
2733 loadStyleSheet(href);
2734 }
2735 });
2736 }
2737 function loadJavaScriptFiles(scripts, callback) {
2738 var loadingCount = scripts.length, parsingCount = loadingCount, sourceCodeList = [];
2739 function parseIfLoadingComplete() {
2740 if (!--loadingCount) {
2741 parseJavaScriptSourceCodes(scripts, sourceCodeList);
2742 }
2743 }
2744 function makeCallbackIfParsingComplete() {
2745 if (!--parsingCount) {
2746 callback();
2747 }
2748 }
2749 scripts.forEach(function (script, index) {
2750 var file = script.javascriptFile;
2751 if (javaScriptFilesLoaded.indexOf(file) === -1) {
2752 if (file in javaScriptFilesLoading) {
2753 javaScriptFilesLoading[file].push(function () {
2754 parseIfLoadingComplete();
2755 makeCallbackIfParsingComplete();
2756 });
2757 }
2758 else {
2759 javaScriptFilesLoading[file] = [function () {
2760 makeCallbackIfParsingComplete();
2761 }];
2762 if (isExternalUrl(file)) {
2763 sourceCodeList[index] = script;
2764 parseIfLoadingComplete();
2765 }
2766 else {
2767 loadJavaScriptSourceCode(file, function (sourceCode) {
2768 sourceCodeList[index] = { javascriptFile: sourceCode };
2769 parseIfLoadingComplete();
2770 });
2771 }
2772 }
2773 }
2774 else {
2775 parseIfLoadingComplete();
2776 makeCallbackIfParsingComplete();
2777 }
2778 });
2779 }
2780 function loadStyleSheet(href) {
2781 var link = linkElement.cloneNode();
2782 link.href = href;
2783 if (firstScriptInHeadElement) {
2784 headElement.insertBefore(link, firstScriptInHeadElement);
2785 }
2786 else {
2787 headElement.appendChild(link);
2788 }
2789 }
2790 function loadJavaScriptSourceCode(src, onload) {
2791 webGet(src, function () {
2792 onload(this.responseText);
2793 });
2794 }
2795 function parseJavaScript(script, onComplete) {
2796 if (onComplete === void 0) { onComplete = $.noop; }
2797 if (!script) {
2798 onComplete();
2799 return;
2800 }
2801 var sourceCodeOrFileName = script.javascriptFile;
2802 var targetCallback = onComplete;
2803 if (script.onLoadCallback) {
2804 var promiseAsCallback = function () {
2805 script.onLoadCallback().then(onComplete);
2806 };
2807 targetCallback = promiseAsCallback;
2808 }
2809 isExternalUrl(sourceCodeOrFileName)
2810 ? loadExternalJavaScriptFile(sourceCodeOrFileName, targetCallback)
2811 : parseInternalJavaScriptCode(sourceCodeOrFileName, targetCallback);
2812 }
2813 function parseInternalJavaScriptCode(sourceCode, onComplete) {
2814 if (onComplete === void 0) { onComplete = $.noop; }
2815 var script;
2816 if (sourceCode) {
2817 script = scriptElement.cloneNode();
2818 script.setAttribute('type', 'text/javascript');
2819 script.innerHTML = sourceCode;
2820 headElement.appendChild(script);
2821 }
2822 setTimeout(onComplete, 0);
2823 }
2824 function loadExternalJavaScriptFile(src, onload) {
2825 var script;
2826 if (src) {
2827 script = scriptElement.cloneNode();
2828 script.setAttribute('src', src);
2829 script.setAttribute('charset', 'utf-8');
2830 script.onload = onload;
2831 headElement.appendChild(script);
2832 }
2833 }
2834 function parseJavaScriptSourceCodes(scripts, sourceCodeList) {
2835 asyncLoop(sourceCodeList, parseJavaScript, /*on all files parsed*/ function () {
2836 scripts.forEach(function (script) {
2837 var file = script.javascriptFile;
2838 var listeners = javaScriptFilesLoading[file];
2839 if (listeners) {
2840 listeners.forEach(function (listener) {
2841 listener();
2842 });
2843 }
2844 delete javaScriptFilesLoading[file];
2845 if (javaScriptFilesLoaded.indexOf(file) === -1) {
2846 javaScriptFilesLoaded.push(file);
2847 }
2848 });
2849 });
2850 }
2851 function webGet(src, onload, onerror) {
2852 var xhr = new XMLHttpRequest();
2853 try {
2854 xhr.open('GET', src, true);
2855 xhr.onload = onload;
2856 xhr.onerror = onerror;
2857 xhr.send(null);
2858 }
2859 catch (e) {
2860 }
2861 }
2862 function isExternalUrl(url) {
2863 var origin = location.protocol + '//' + location.host + '/';
2864 return /^http[s]?:\/\/.+/i.test(url) && url.indexOf(origin) !== 0;
2865 }
2866 function _() {
2867 var args = [];
2868 for (var _i = 0; _i < arguments.length; _i++) {
2869 args[_i - 0] = arguments[_i];
2870 }
2871 }
2872 function asyncSteps() {
2873 var args = [];
2874 for (var _i = 0; _i < arguments.length; _i++) {
2875 args[_i - 0] = arguments[_i];
2876 }
2877 if (args.length === 0) {
2878 return;
2879 }
2880 var steps = [], i = args.length;
2881 while (i--) {
2882 (function (j) {
2883 steps[j] = function () {
2884 args[j](steps[j + 1] || _);
2885 };
2886 })(i);
2887 }
2888 steps[0]();
2889 }
2890 function asyncLoop(enumerable, func, callback) {
2891 var steps = [], i = 0, len = enumerable.length;
2892 for (; i < len - 1; i++) {
2893 (function (i) {
2894 steps[i] = function (next) {
2895 func(enumerable[i], next);
2896 };
2897 }(i));
2898 }
2899 steps[len - 1] = function (next) {
2900 func(enumerable[len - 1], callback);
2901 };
2902 asyncSteps.apply(null, steps);
2903 }
2904})(jsCommon || (jsCommon = {}));
2905/*
2906 * Power BI Visualizations
2907 *
2908 * Copyright (c) Microsoft Corporation
2909 * All rights reserved.
2910 * MIT License
2911 *
2912 * Permission is hereby granted, free of charge, to any person obtaining a copy
2913 * of this software and associated documentation files (the ""Software""), to deal
2914 * in the Software without restriction, including without limitation the rights
2915 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2916 * copies of the Software, and to permit persons to whom the Software is
2917 * furnished to do so, subject to the following conditions:
2918 *
2919 * The above copyright notice and this permission notice shall be included in
2920 * all copies or substantial portions of the Software.
2921 *
2922 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2923 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2924 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2925 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2926 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2927 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2928 * THE SOFTWARE.
2929 */
2930var powerbi;
2931(function (powerbi) {
2932 function createJQueryPromiseFactory() {
2933 return new JQueryPromiseFactory();
2934 }
2935 powerbi.createJQueryPromiseFactory = createJQueryPromiseFactory;
2936 /**
2937 * jQuery-based implementation of IPromiseFactory.
2938 * This is useful for cases when Angular is not present, or when immediate promise resolving (not tied to Angular digest cycle) is desired.
2939 */
2940 var JQueryPromiseFactory = (function () {
2941 function JQueryPromiseFactory() {
2942 }
2943 JQueryPromiseFactory.prototype.defer = function () {
2944 return new JQueryDeferredWrapper($.Deferred());
2945 };
2946 JQueryPromiseFactory.prototype.reject = function (reason) {
2947 var deferred = this.defer();
2948 deferred.reject(reason);
2949 return deferred.promise;
2950 };
2951 JQueryPromiseFactory.prototype.resolve = function (value) {
2952 var deferred = this.defer();
2953 deferred.resolve(value);
2954 return deferred.promise;
2955 };
2956 JQueryPromiseFactory.prototype.all = function (promises) {
2957 var unwrappedPromises = jQuery.map(promises, function (value) {
2958 return value && value.promise ? value.promise : value;
2959 });
2960 return new JQueryPromiseWrapper($.when.apply($, unwrappedPromises));
2961 };
2962 JQueryPromiseFactory.prototype.when = function (value) {
2963 var unwrappedPromise = value && value.promise ? value.promise : value;
2964 return new JQueryPromiseWrapper($.when(unwrappedPromise));
2965 };
2966 return JQueryPromiseFactory;
2967 }());
2968 /**
2969 * Implements IDeferred via a wrapped a jQuery Deferred.
2970 */
2971 var JQueryDeferredWrapper = (function () {
2972 function JQueryDeferredWrapper(deferred) {
2973 debug.assertValue(deferred, 'deferred');
2974 this.deferred = deferred;
2975 this.promise = new JQueryPromiseWrapper(deferred.promise());
2976 }
2977 JQueryDeferredWrapper.prototype.resolve = function (value) {
2978 this.deferred.resolve(value);
2979 };
2980 JQueryDeferredWrapper.prototype.reject = function (reason) {
2981 this.deferred.reject(reason);
2982 };
2983 return JQueryDeferredWrapper;
2984 }());
2985 /**
2986 * Implements IDeferred via a wrapped a jQuery Promise.
2987 */
2988 var JQueryPromiseWrapper = (function () {
2989 function JQueryPromiseWrapper(promise) {
2990 debug.assertValue(promise, 'promise');
2991 this.promise = promise;
2992 }
2993 JQueryPromiseWrapper.prototype.then = function (a, b) {
2994 return new JQueryPromiseWrapper(this.promise.then(JQueryPromiseWrapper.wrapCallback(a), JQueryPromiseWrapper.wrapCallback(b)));
2995 };
2996 JQueryPromiseWrapper.prototype.catch = function (callback) {
2997 return this.then(null, callback);
2998 };
2999 JQueryPromiseWrapper.prototype.finally = function (callback) {
3000 this.promise.always(JQueryPromiseWrapper.wrapCallback(callback));
3001 return this;
3002 };
3003 /**
3004 * Wraps a callback, which may return a IPromise.
3005 */
3006 JQueryPromiseWrapper.wrapCallback = function (callback) {
3007 if (callback)
3008 return function (arg) {
3009 var value = callback(arg);
3010 // If the callback returns a Promise, unwrap that to allow jQuery to chain.
3011 if (value instanceof JQueryPromiseWrapper)
3012 return value.promise;
3013 return value;
3014 };
3015 return callback;
3016 };
3017 return JQueryPromiseWrapper;
3018 }());
3019})(powerbi || (powerbi = {}));
3020/*
3021 * Power BI Visualizations
3022 *
3023 * Copyright (c) Microsoft Corporation
3024 * All rights reserved.
3025 * MIT License
3026 *
3027 * Permission is hereby granted, free of charge, to any person obtaining a copy
3028 * of this software and associated documentation files (the ""Software""), to deal
3029 * in the Software without restriction, including without limitation the rights
3030 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3031 * copies of the Software, and to permit persons to whom the Software is
3032 * furnished to do so, subject to the following conditions:
3033 *
3034 * The above copyright notice and this permission notice shall be included in
3035 * all copies or substantial portions of the Software.
3036 *
3037 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3038 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3039 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3040 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3041 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3042 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3043 * THE SOFTWARE.
3044 */
3045var powerbi;
3046(function (powerbi) {
3047 var LocalStorageService = (function () {
3048 function LocalStorageService() {
3049 }
3050 LocalStorageService.prototype.getData = function (key) {
3051 try {
3052 if (localStorage) {
3053 var value = localStorage[key];
3054 if (value) {
3055 return JSON.parse(value);
3056 }
3057 }
3058 }
3059 catch (exception) { }
3060 return null;
3061 };
3062 LocalStorageService.prototype.setData = function (key, data) {
3063 try {
3064 if (localStorage) {
3065 localStorage[key] = JSON.stringify(data);
3066 }
3067 }
3068 catch (e) { }
3069 };
3070 return LocalStorageService;
3071 }());
3072 var EphemeralStorageService = (function () {
3073 function EphemeralStorageService(clearCacheInterval) {
3074 this.cache = {};
3075 this.clearCacheInterval = (clearCacheInterval != null)
3076 ? clearCacheInterval
3077 : EphemeralStorageService.defaultClearCacheInterval;
3078 this.clearCache();
3079 }
3080 EphemeralStorageService.prototype.getData = function (key) {
3081 return this.cache[key];
3082 };
3083 EphemeralStorageService.prototype.setData = function (key, data) {
3084 var _this = this;
3085 this.cache[key] = data;
3086 if (this.clearCacheTimerId == null) {
3087 this.clearCacheTimerId = setTimeout(function () { return _this.clearCache(); }, this.clearCacheInterval);
3088 }
3089 };
3090 EphemeralStorageService.prototype.clearCache = function () {
3091 this.cache = {};
3092 this.clearCacheTimerId = undefined;
3093 };
3094 EphemeralStorageService.defaultClearCacheInterval = (1000 * 60 * 60 * 24); // 1 day
3095 return EphemeralStorageService;
3096 }());
3097 powerbi.EphemeralStorageService = EphemeralStorageService;
3098 powerbi.localStorageService = new LocalStorageService();
3099 powerbi.ephemeralStorageService = new EphemeralStorageService();
3100})(powerbi || (powerbi = {}));
3101/*
3102 * Power BI Visualizations
3103 *
3104 * Copyright (c) Microsoft Corporation
3105 * All rights reserved.
3106 * MIT License
3107 *
3108 * Permission is hereby granted, free of charge, to any person obtaining a copy
3109 * of this software and associated documentation files (the ""Software""), to deal
3110 * in the Software without restriction, including without limitation the rights
3111 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3112 * copies of the Software, and to permit persons to whom the Software is
3113 * furnished to do so, subject to the following conditions:
3114 *
3115 * The above copyright notice and this permission notice shall be included in
3116 * all copies or substantial portions of the Software.
3117 *
3118 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3119 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3120 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3121 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3122 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3123 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3124 * THE SOFTWARE.
3125 */
3126var jsCommon;
3127(function (jsCommon) {
3128 var WordBreaker;
3129 (function (WordBreaker) {
3130 var SPACE = ' ';
3131 var BREAKERS_REGEX = /[\s\n]+/g;
3132 function search(index, content, backward) {
3133 if (backward) {
3134 for (var i = index - 1; i > -1; i--) {
3135 if (hasBreakers(content[i]))
3136 return i + 1;
3137 }
3138 }
3139 else {
3140 for (var i = index, ilen = content.length; i < ilen; i++) {
3141 if (hasBreakers(content[i]))
3142 return i;
3143 }
3144 }
3145 return backward ? 0 : content.length;
3146 }
3147 /**
3148 * Find the word nearest the cursor specified within content
3149 * @param index - point within content to search forward/backward from
3150 * @param content - string to search
3151 */
3152 function find(index, content) {
3153 debug.assert(index >= 0 && index <= content.length, 'index within content string bounds');
3154 var result = { start: 0, end: 0 };
3155 if (content.length === 0)
3156 return result;
3157 result.start = search(index, content, true);
3158 result.end = search(index, content, false);
3159 return result;
3160 }
3161 WordBreaker.find = find;
3162 /**
3163 * Test for presence of breakers within content
3164 * @param content - string to test
3165 */
3166 function hasBreakers(content) {
3167 BREAKERS_REGEX.lastIndex = 0;
3168 return BREAKERS_REGEX.test(content);
3169 }
3170 WordBreaker.hasBreakers = hasBreakers;
3171 /**
3172 * Count the number of pieces when broken by BREAKERS_REGEX
3173 * ~2.7x faster than WordBreaker.split(content).length
3174 * @param content - string to break and count
3175 */
3176 function wordCount(content) {
3177 var count = 1;
3178 BREAKERS_REGEX.lastIndex = 0;
3179 BREAKERS_REGEX.exec(content);
3180 while (BREAKERS_REGEX.lastIndex !== 0) {
3181 count++;
3182 BREAKERS_REGEX.exec(content);
3183 }
3184 return count;
3185 }
3186 WordBreaker.wordCount = wordCount;
3187 function getMaxWordWidth(content, textWidthMeasurer, properties) {
3188 var words = split(content);
3189 var maxWidth = 0;
3190 for (var _i = 0, words_1 = words; _i < words_1.length; _i++) {
3191 var w = words_1[_i];
3192 properties.text = w;
3193 maxWidth = Math.max(maxWidth, textWidthMeasurer(properties));
3194 }
3195 return maxWidth;
3196 }
3197 WordBreaker.getMaxWordWidth = getMaxWordWidth;
3198 function split(content) {
3199 return content.split(BREAKERS_REGEX);
3200 }
3201 function getWidth(content, properties, textWidthMeasurer) {
3202 properties.text = content;
3203 return textWidthMeasurer(properties);
3204 }
3205 function truncate(content, properties, truncator, maxWidth) {
3206 properties.text = content;
3207 return truncator(properties, maxWidth);
3208 }
3209 /**
3210 * Split content by breakers (words) and greedy fit as many words
3211 * into each index in the result based on max width and number of lines
3212 * e.g. Each index in result corresponds to a line of content
3213 * when used by AxisHelper.LabelLayoutStrategy.wordBreak
3214 * @param content - string to split
3215 * @param properties - text properties to be used by @param:textWidthMeasurer
3216 * @param textWidthMeasurer - function to calculate width of given text content
3217 * @param maxWidth - maximum allowed width of text content in each result
3218 * @param maxNumLines - maximum number of results we will allow, valid values must be greater than 0
3219 * @param truncator - (optional) if specified, used as a function to truncate content to a given width
3220 */
3221 function splitByWidth(content, properties, textWidthMeasurer, maxWidth, maxNumLines, truncator) {
3222 // Default truncator returns string as-is
3223 truncator = truncator ? truncator : function (properties, maxWidth) { return properties.text; };
3224 var result = [];
3225 var words = split(content);
3226 var usedWidth = 0;
3227 var wordsInLine = [];
3228 for (var _i = 0, words_2 = words; _i < words_2.length; _i++) {
3229 var word = words_2[_i];
3230 // Last line? Just add whatever is left
3231 if ((maxNumLines > 0) && (result.length >= maxNumLines - 1)) {
3232 wordsInLine.push(word);
3233 continue;
3234 }
3235 // Determine width if we add this word
3236 // Account for SPACE we will add when joining...
3237 var wordWidth = wordsInLine.length === 0
3238 ? getWidth(word, properties, textWidthMeasurer)
3239 : getWidth(SPACE + word, properties, textWidthMeasurer);
3240 // If width would exceed max width,
3241 // then push used words and start new split result
3242 if (usedWidth + wordWidth > maxWidth) {
3243 // Word alone exceeds max width, just add it.
3244 if (wordsInLine.length === 0) {
3245 result.push(truncate(word, properties, truncator, maxWidth));
3246 usedWidth = 0;
3247 wordsInLine = [];
3248 continue;
3249 }
3250 result.push(truncate(wordsInLine.join(SPACE), properties, truncator, maxWidth));
3251 usedWidth = 0;
3252 wordsInLine = [];
3253 }
3254 // ...otherwise, add word and continue
3255 wordsInLine.push(word);
3256 usedWidth += wordWidth;
3257 }
3258 // Push remaining words onto result
3259 result.push(truncate(wordsInLine.join(SPACE), properties, truncator, maxWidth));
3260 return result;
3261 }
3262 WordBreaker.splitByWidth = splitByWidth;
3263 })(WordBreaker = jsCommon.WordBreaker || (jsCommon.WordBreaker = {}));
3264})(jsCommon || (jsCommon = {}));
3265/*
3266 * Power BI Visualizations
3267 *
3268 * Copyright (c) Microsoft Corporation
3269 * All rights reserved.
3270 * MIT License
3271 *
3272 * Permission is hereby granted, free of charge, to any person obtaining a copy
3273 * of this software and associated documentation files (the ""Software""), to deal
3274 * in the Software without restriction, including without limitation the rights
3275 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3276 * copies of the Software, and to permit persons to whom the Software is
3277 * furnished to do so, subject to the following conditions:
3278 *
3279 * The above copyright notice and this permission notice shall be included in
3280 * all copies or substantial portions of the Software.
3281 *
3282 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3283 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3284 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3285 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3286 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3287 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3288 * THE SOFTWARE.
3289 */
3290var powerbi;
3291(function (powerbi) {
3292 var TextMeasurementService;
3293 (function (TextMeasurementService) {
3294 var ellipsis = '…';
3295 var OverflowingText = jsCommon.CssConstants.createClassAndSelector('overflowingText');
3296 var spanElement;
3297 var svgTextElement;
3298 var canvasCtx;
3299 var fallbackFontFamily;
3300 /**
3301 * Idempotent function for adding the elements to the DOM.
3302 */
3303 function ensureDOM() {
3304 if (spanElement)
3305 return;
3306 spanElement = $('<span/>');
3307 $('body').append(spanElement);
3308 //The style hides the svg element from the canvas, preventing canvas from scrolling down to show svg black square.
3309 svgTextElement = d3.select($('body').get(0))
3310 .append('svg')
3311 .style({
3312 'height': '0px',
3313 'width': '0px',
3314 'position': 'absolute'
3315 })
3316 .append('text');
3317 canvasCtx = $('<canvas/>').get(0).getContext("2d");
3318 fallbackFontFamily = window.getComputedStyle(svgTextElement.node()).fontFamily;
3319 }
3320 /**
3321 * Removes spanElement from DOM.
3322 */
3323 function removeSpanElement() {
3324 if (spanElement && spanElement.remove) {
3325 spanElement.remove();
3326 }
3327 spanElement = null;
3328 }
3329 TextMeasurementService.removeSpanElement = removeSpanElement;
3330 /**
3331 * This method measures the width of the text with the given SVG text properties.
3332 * @param textProperties The text properties to use for text measurement.
3333 */
3334 function measureSvgTextWidth(textProperties) {
3335 debug.assertValue(textProperties, 'textProperties');
3336 debug.assert(_.isEmpty(textProperties.fontSize) || textProperties.fontSize.indexOf("px") !== -1, "TextProperties' text size should be in px.");
3337 ensureDOM();
3338 canvasCtx.font =
3339 (textProperties.fontStyle || "") + " " +
3340 (textProperties.fontVariant || "") + " " +
3341 (textProperties.fontWeight || "") + " " +
3342 textProperties.fontSize + " " +
3343 (textProperties.fontFamily || fallbackFontFamily);
3344 return canvasCtx.measureText(textProperties.text).width;
3345 }
3346 TextMeasurementService.measureSvgTextWidth = measureSvgTextWidth;
3347 /**
3348 * This method return the rect with the given SVG text properties.
3349 * @param textProperties The text properties to use for text measurement.
3350 */
3351 function measureSvgTextRect(textProperties) {
3352 debug.assertValue(textProperties, 'textProperties');
3353 debug.assert(_.isEmpty(textProperties.fontSize) || textProperties.fontSize.indexOf("px") !== -1, "TextProperties' text size should be in px.");
3354 ensureDOM();
3355 svgTextElement.style(null);
3356 svgTextElement
3357 .text(textProperties.text)
3358 .attr({
3359 'visibility': 'hidden',
3360 'font-family': textProperties.fontFamily || fallbackFontFamily,
3361 'font-variant': textProperties.fontVariant,
3362 'font-size': textProperties.fontSize,
3363 'font-weight': textProperties.fontWeight,
3364 'font-style': textProperties.fontStyle,
3365 'white-space': textProperties.whiteSpace || 'nowrap'
3366 });
3367 // We're expecting the browser to give a synchronous measurement here
3368 // We're using SVGTextElement because it works across all browsers
3369 return svgTextElement.node().getBBox();
3370 }
3371 TextMeasurementService.measureSvgTextRect = measureSvgTextRect;
3372 /**
3373 * This method measures the height of the text with the given SVG text properties.
3374 * @param textProperties The text properties to use for text measurement.
3375 */
3376 function measureSvgTextHeight(textProperties) {
3377 return measureSvgTextRect(textProperties).height;
3378 }
3379 TextMeasurementService.measureSvgTextHeight = measureSvgTextHeight;
3380 /**
3381 * This method returns the text Rect with the given SVG text properties.
3382 * Does NOT return text width; obliterates text value
3383 * @param {TextProperties} textProperties - The text properties to use for text measurement
3384 */
3385 function estimateSvgTextRect(textProperties) {
3386 debug.assertValue(textProperties, 'textProperties');
3387 debug.assert(_.isEmpty(textProperties.fontSize) || textProperties.fontSize.indexOf("px") !== -1, "TextProperties' text size should be in px.");
3388 var propertiesKey = textProperties.fontFamily + textProperties.fontSize;
3389 var rect = powerbi.ephemeralStorageService.getData(propertiesKey);
3390 if (rect == null) {
3391 // To estimate we check the height of a particular character, once it is cached, subsequent
3392 // calls should always get the height from the cache (regardless of the text).
3393 var estimatedTextProperties = {
3394 fontFamily: textProperties.fontFamily,
3395 fontSize: textProperties.fontSize,
3396 text: "M",
3397 };
3398 rect = TextMeasurementService.measureSvgTextRect(estimatedTextProperties);
3399 // NOTE: In some cases (disconnected/hidden DOM) we may provide incorrect measurement results (zero sized bounding-box), so
3400 // we only store values in the cache if we are confident they are correct.
3401 if (rect.height > 0)
3402 powerbi.ephemeralStorageService.setData(propertiesKey, rect);
3403 }
3404 return rect;
3405 }
3406 /**
3407 * This method returns the text Rect with the given SVG text properties.
3408 * @param {TextProperties} textProperties - The text properties to use for text measurement
3409 */
3410 function estimateSvgTextBaselineDelta(textProperties) {
3411 var rect = estimateSvgTextRect(textProperties);
3412 return rect.y + rect.height;
3413 }
3414 TextMeasurementService.estimateSvgTextBaselineDelta = estimateSvgTextBaselineDelta;
3415 /**
3416 * This method estimates the height of the text with the given SVG text properties.
3417 * @param {TextProperties} textProperties - The text properties to use for text measurement
3418 */
3419 function estimateSvgTextHeight(textProperties, tightFightForNumeric) {
3420 if (tightFightForNumeric === void 0) { tightFightForNumeric = false; }
3421 var height = estimateSvgTextRect(textProperties).height;
3422 //TODO: replace it with new baseline calculation
3423 if (tightFightForNumeric)
3424 height *= 0.7;
3425 return height;
3426 }
3427 TextMeasurementService.estimateSvgTextHeight = estimateSvgTextHeight;
3428 /**
3429 * This method measures the width of the svgElement.
3430 * @param svgElement The SVGTextElement to be measured.
3431 */
3432 function measureSvgTextElementWidth(svgElement) {
3433 debug.assertValue(svgElement, 'svgElement');
3434 return measureSvgTextWidth(getSvgMeasurementProperties(svgElement));
3435 }
3436 TextMeasurementService.measureSvgTextElementWidth = measureSvgTextElementWidth;
3437 /**
3438 * This method fetches the text measurement properties of the given DOM element.
3439 * @param element The selector for the DOM Element.
3440 */
3441 function getMeasurementProperties(element) {
3442 debug.assertValue(element, 'element');
3443 return {
3444 text: element.val() || element.text(),
3445 fontFamily: element.css('font-family'),
3446 fontSize: element.css('font-size'),
3447 fontWeight: element.css('font-weight'),
3448 fontStyle: element.css('font-style'),
3449 fontVariant: element.css('font-variant'),
3450 whiteSpace: element.css('white-space')
3451 };
3452 }
3453 TextMeasurementService.getMeasurementProperties = getMeasurementProperties;
3454 /**
3455 * This method fetches the text measurement properties of the given SVG text element.
3456 * @param svgElement The SVGTextElement to be measured.
3457 */
3458 function getSvgMeasurementProperties(svgElement) {
3459 debug.assertValue(svgElement, 'svgElement');
3460 var style = window.getComputedStyle(svgElement, null);
3461 return {
3462 text: svgElement.textContent,
3463 fontFamily: style.fontFamily,
3464 fontSize: style.fontSize,
3465 fontWeight: style.fontWeight,
3466 fontStyle: style.fontStyle,
3467 fontVariant: style.fontVariant,
3468 whiteSpace: style.whiteSpace
3469 };
3470 }
3471 TextMeasurementService.getSvgMeasurementProperties = getSvgMeasurementProperties;
3472 /**
3473 * This method returns the width of a div element.
3474 * @param element The div element.
3475 */
3476 function getDivElementWidth(element) {
3477 debug.assert(element.is('div'), 'Given element is not a div type. Cannot get width');
3478 return getComputedStyle(element[0]).width;
3479 }
3480 TextMeasurementService.getDivElementWidth = getDivElementWidth;
3481 /**
3482 * Compares labels text size to the available size and renders ellipses when the available size is smaller.
3483 * @param textProperties The text properties (including text content) to use for text measurement.
3484 * @param maxWidth The maximum width available for rendering the text.
3485 */
3486 function getTailoredTextOrDefault(textProperties, maxWidth) {
3487 debug.assertValue(textProperties, 'properties');
3488 debug.assertValue(textProperties.text, 'properties.text');
3489 debug.assert(_.isEmpty(textProperties.fontSize) || textProperties.fontSize.indexOf("px") !== -1, "TextProperties' text size should be in px.");
3490 ensureDOM();
3491 var strLength = textProperties.text.length;
3492 if (strLength === 0)
3493 return textProperties.text;
3494 var width = measureSvgTextWidth(textProperties);
3495 if (width < maxWidth)
3496 return textProperties.text;
3497 // Create a copy of the textProperties so we don't modify the one that's passed in.
3498 var copiedTextProperties = powerbi.Prototype.inherit(textProperties);
3499 // Take the properties and apply them to svgTextElement
3500 // Then, do the binary search to figure out the substring we want
3501 // Set the substring on textElement argument
3502 var text = copiedTextProperties.text = ellipsis + copiedTextProperties.text;
3503 var min = 1;
3504 var max = text.length;
3505 var i = ellipsis.length;
3506 while (min <= max) {
3507 // num | 0 prefered to Math.floor(num) for performance benefits
3508 i = (min + max) / 2 | 0;
3509 copiedTextProperties.text = text.substr(0, i);
3510 width = measureSvgTextWidth(copiedTextProperties);
3511 if (maxWidth > width)
3512 min = i + 1;
3513 else if (maxWidth < width)
3514 max = i - 1;
3515 else
3516 break;
3517 }
3518 // Since the search algorithm almost never finds an exact match,
3519 // it will pick one of the closest two, which could result in a
3520 // value bigger with than 'maxWidth' thus we need to go back by
3521 // one to guarantee a smaller width than 'maxWidth'.
3522 copiedTextProperties.text = text.substr(0, i);
3523 width = measureSvgTextWidth(copiedTextProperties);
3524 if (width > maxWidth)
3525 i--;
3526 return text.substr(ellipsis.length, i - ellipsis.length) + ellipsis;
3527 }
3528 TextMeasurementService.getTailoredTextOrDefault = getTailoredTextOrDefault;
3529 /**
3530 * Compares labels text size to the available size and renders ellipses when the available size is smaller.
3531 * @param textElement The SVGTextElement containing the text to render.
3532 * @param maxWidth The maximum width available for rendering the text.
3533 */
3534 function svgEllipsis(textElement, maxWidth) {
3535 debug.assertValue(textElement, 'textElement');
3536 var properties = getSvgMeasurementProperties(textElement);
3537 var originalText = properties.text;
3538 var tailoredText = getTailoredTextOrDefault(properties, maxWidth);
3539 if (originalText !== tailoredText) {
3540 textElement.textContent = tailoredText;
3541 }
3542 }
3543 TextMeasurementService.svgEllipsis = svgEllipsis;
3544 /**
3545 * Word break textContent of <text> SVG element into <tspan>s
3546 * Each tspan will be the height of a single line of text
3547 * @param textElement - the SVGTextElement containing the text to wrap
3548 * @param maxWidth - the maximum width available
3549 * @param maxHeight - the maximum height available (defaults to single line)
3550 * @param linePadding - (optional) padding to add to line height
3551 */
3552 function wordBreak(textElement, maxWidth, maxHeight, linePadding) {
3553 if (linePadding === void 0) { linePadding = 0; }
3554 debug.assertValue(textElement, 'textElement');
3555 var properties = getSvgMeasurementProperties(textElement);
3556 var height = estimateSvgTextHeight(properties) + linePadding;
3557 var maxNumLines = Math.max(1, Math.floor(maxHeight / height));
3558 var node = d3.select(textElement);
3559 // Save y of parent textElement to apply as first tspan dy
3560 var firstDY = node.attr('y');
3561 // Store and clear text content
3562 var labelText = textElement.textContent;
3563 textElement.textContent = null;
3564 // Append a tspan for each word broken section
3565 var words = jsCommon.WordBreaker.splitByWidth(labelText, properties, measureSvgTextWidth, maxWidth, maxNumLines);
3566 for (var i = 0, ilen = words.length; i < ilen; i++) {
3567 properties.text = words[i];
3568 node
3569 .append('tspan')
3570 .attr({
3571 'x': 0,
3572 'dy': i === 0 ? firstDY : height,
3573 })
3574 .text(getTailoredTextOrDefault(properties, maxWidth));
3575 }
3576 }
3577 TextMeasurementService.wordBreak = wordBreak;
3578 /**
3579 * Word break textContent of span element into <span>s
3580 * Each span will be the height of a single line of text
3581 * @param textElement - the element containing the text to wrap
3582 * @param maxWidth - the maximum width available
3583 * @param maxHeight - the maximum height available (defaults to single line)
3584 * @param linePadding - (optional) padding to add to line height
3585 */
3586 function wordBreakOverflowingText(textElement, maxWidth, maxHeight, linePadding) {
3587 if (linePadding === void 0) { linePadding = 0; }
3588 debug.assertValue(textElement, 'textElement');
3589 var properties = getSvgMeasurementProperties(textElement);
3590 var height = estimateSvgTextHeight(properties) + linePadding;
3591 var maxNumLines = Math.max(1, Math.floor(maxHeight / height));
3592 // Store and clear text content
3593 var labelText = textElement.textContent;
3594 textElement.textContent = null;
3595 // Append a span for each word broken section
3596 var words = jsCommon.WordBreaker.splitByWidth(labelText, properties, measureSvgTextWidth, maxWidth, maxNumLines);
3597 // splitByWidth() occasionally returns unnecessary empty strings, so get rid of them.
3598 // TODO: Fix splitByWidth.
3599 words = _.compact(words);
3600 var spanItem = d3.select(textElement)
3601 .selectAll(OverflowingText.selector)
3602 .data(words, function (d) { return $.inArray(d, words); });
3603 spanItem
3604 .enter()
3605 .append("span")
3606 .classed(OverflowingText.class, true)
3607 .text(function (d) { return d; })
3608 .style("width", jsCommon.PixelConverter.toString(maxWidth));
3609 }
3610 TextMeasurementService.wordBreakOverflowingText = wordBreakOverflowingText;
3611 })(TextMeasurementService = powerbi.TextMeasurementService || (powerbi.TextMeasurementService = {}));
3612})(powerbi || (powerbi = {}));
3613/*
3614 * Power BI Visualizations
3615 *
3616 * Copyright (c) Microsoft Corporation
3617 * All rights reserved.
3618 * MIT License
3619 *
3620 * Permission is hereby granted, free of charge, to any person obtaining a copy
3621 * of this software and associated documentation files (the ""Software""), to deal
3622 * in the Software without restriction, including without limitation the rights
3623 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3624 * copies of the Software, and to permit persons to whom the Software is
3625 * furnished to do so, subject to the following conditions:
3626 *
3627 * The above copyright notice and this permission notice shall be included in
3628 * all copies or substantial portions of the Software.
3629 *
3630 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3631 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3632 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3633 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3634 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3635 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3636 * THE SOFTWARE.
3637 */
3638var jsCommon;
3639(function (jsCommon) {
3640 var DOMConstants = jsCommon.DOMConstants;
3641 var KeyUtils;
3642 (function (KeyUtils) {
3643 function isArrowKey(keyCode) {
3644 return keyCode === DOMConstants.downArrowKeyCode
3645 || keyCode === DOMConstants.upArrowKeyCode
3646 || keyCode === DOMConstants.leftArrowKeyCode
3647 || keyCode === DOMConstants.rightArrowKeyCode;
3648 }
3649 KeyUtils.isArrowKey = isArrowKey;
3650 })(KeyUtils = jsCommon.KeyUtils || (jsCommon.KeyUtils = {}));
3651})(jsCommon || (jsCommon = {}));
3652/*
3653 * Power BI Visualizations
3654 *
3655 * Copyright (c) Microsoft Corporation
3656 * All rights reserved.
3657 * MIT License
3658 *
3659 * Permission is hereby granted, free of charge, to any person obtaining a copy
3660 * of this software and associated documentation files (the ""Software""), to deal
3661 * in the Software without restriction, including without limitation the rights
3662 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3663 * copies of the Software, and to permit persons to whom the Software is
3664 * furnished to do so, subject to the following conditions:
3665 *
3666 * The above copyright notice and this permission notice shall be included in
3667 * all copies or substantial portions of the Software.
3668 *
3669 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3670 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3671 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3672 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3673 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3674 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3675 * THE SOFTWARE.
3676 */
3677var jsCommon;
3678(function (jsCommon) {
3679 /**
3680 * Responsible for throttling input function.
3681 */
3682 var ThrottleUtility = (function () {
3683 function ThrottleUtility(delay) {
3684 this.timerFactory = jsCommon.TimerPromiseFactory.instance;
3685 this.delay = 0;
3686 if (delay) {
3687 this.delay = delay;
3688 }
3689 }
3690 ThrottleUtility.prototype.run = function (fn) {
3691 var _this = this;
3692 if (!this.fn) {
3693 this.fn = fn;
3694 this.timerFactory.create(this.delay).done(function () { return _this.timerComplete(_this.fn); });
3695 }
3696 else {
3697 this.fn = fn;
3698 }
3699 };
3700 /**
3701 * Note: Public for testing purpose.
3702 */
3703 ThrottleUtility.prototype.timerComplete = function (fn) {
3704 // run fn
3705 fn();
3706 // clear fn
3707 this.fn = null;
3708 };
3709 return ThrottleUtility;
3710 }());
3711 jsCommon.ThrottleUtility = ThrottleUtility;
3712})(jsCommon || (jsCommon = {}));
3713/*
3714 * Power BI Visualizations
3715 *
3716 * Copyright (c) Microsoft Corporation
3717 * All rights reserved.
3718 * MIT License
3719 *
3720 * Permission is hereby granted, free of charge, to any person obtaining a copy
3721 * of this software and associated documentation files (the ""Software""), to deal
3722 * in the Software without restriction, including without limitation the rights
3723 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3724 * copies of the Software, and to permit persons to whom the Software is
3725 * furnished to do so, subject to the following conditions:
3726 *
3727 * The above copyright notice and this permission notice shall be included in
3728 * all copies or substantial portions of the Software.
3729 *
3730 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3731 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3732 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3733 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3734 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3735 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3736 * THE SOFTWARE.
3737 */
3738var jsCommon;
3739(function (jsCommon) {
3740 /**
3741 * Responsible for creating timer promises.
3742 */
3743 var TimerPromiseFactory = (function () {
3744 function TimerPromiseFactory() {
3745 }
3746 /**
3747 * {@inheritDoc}
3748 */
3749 TimerPromiseFactory.prototype.create = function (delayInMs) {
3750 debug.assertValue(delayInMs, 'delayInMs');
3751 debug.assert(delayInMs >= 0, 'delayInMs must be a positive value.');
3752 var deferred = $.Deferred();
3753 window.setTimeout(function () { return deferred.resolve(); }, delayInMs);
3754 return deferred;
3755 };
3756 TimerPromiseFactory.instance = new TimerPromiseFactory();
3757 return TimerPromiseFactory;
3758 }());
3759 jsCommon.TimerPromiseFactory = TimerPromiseFactory;
3760})(jsCommon || (jsCommon = {}));
3761/*
3762 * Power BI Visualizations
3763 *
3764 * Copyright (c) Microsoft Corporation
3765 * All rights reserved.
3766 * MIT License
3767 *
3768 * Permission is hereby granted, free of charge, to any person obtaining a copy
3769 * of this software and associated documentation files (the ""Software""), to deal
3770 * in the Software without restriction, including without limitation the rights
3771 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3772 * copies of the Software, and to permit persons to whom the Software is
3773 * furnished to do so, subject to the following conditions:
3774 *
3775 * The above copyright notice and this permission notice shall be included in
3776 * all copies or substantial portions of the Software.
3777 *
3778 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3779 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3780 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3781 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3782 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3783 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3784 * THE SOFTWARE.
3785 */
3786var jsCommon;
3787(function (jsCommon) {
3788 /**
3789 * Http Status code we are interested.
3790 */
3791 (function (HttpStatusCode) {
3792 HttpStatusCode[HttpStatusCode["OK"] = 200] = "OK";
3793 HttpStatusCode[HttpStatusCode["BadRequest"] = 400] = "BadRequest";
3794 HttpStatusCode[HttpStatusCode["Unauthorized"] = 401] = "Unauthorized";
3795 HttpStatusCode[HttpStatusCode["Forbidden"] = 403] = "Forbidden";
3796 HttpStatusCode[HttpStatusCode["RequestEntityTooLarge"] = 413] = "RequestEntityTooLarge";
3797 })(jsCommon.HttpStatusCode || (jsCommon.HttpStatusCode = {}));
3798 var HttpStatusCode = jsCommon.HttpStatusCode;
3799 /**
3800 * Other HTTP Constants.
3801 */
3802 var HttpConstants;
3803 (function (HttpConstants) {
3804 HttpConstants.ApplicationOctetStream = 'application/octet-stream';
3805 HttpConstants.MultiPartFormData = 'multipart/form-data';
3806 })(HttpConstants = jsCommon.HttpConstants || (jsCommon.HttpConstants = {}));
3807 /**
3808 * Extensions to String class.
3809 */
3810 var StringExtensions;
3811 (function (StringExtensions) {
3812 var HtmlTagRegex = new RegExp('[<>]', 'g');
3813 function format() {
3814 var args = [];
3815 for (var _i = 0; _i < arguments.length; _i++) {
3816 args[_i - 0] = arguments[_i];
3817 }
3818 var s = args[0];
3819 if (isNullOrUndefinedOrWhiteSpaceString(s))
3820 return s;
3821 for (var i = 0; i < args.length - 1; i++) {
3822 var reg = new RegExp("\\{" + i + "\\}", "gm");
3823 s = s.replace(reg, args[i + 1]);
3824 }
3825 return s;
3826 }
3827 StringExtensions.format = format;
3828 /**
3829 * Compares two strings for equality, ignoring case.
3830 */
3831 function equalIgnoreCase(a, b) {
3832 return StringExtensions.normalizeCase(a) === StringExtensions.normalizeCase(b);
3833 }
3834 StringExtensions.equalIgnoreCase = equalIgnoreCase;
3835 function startsWithIgnoreCase(a, b) {
3836 var normalizedSearchString = StringExtensions.normalizeCase(b);
3837 return StringExtensions.normalizeCase(a).indexOf(normalizedSearchString) === 0;
3838 }
3839 StringExtensions.startsWithIgnoreCase = startsWithIgnoreCase;
3840 function startsWith(a, b) {
3841 return a.indexOf(b) === 0;
3842 }
3843 StringExtensions.startsWith = startsWith;
3844 /** Determines whether a string contains a specified substring (while ignoring case). */
3845 function containsIgnoreCase(source, substring) {
3846 if (source == null)
3847 return false;
3848 return source.toLowerCase().indexOf(substring.toLowerCase().toString()) !== -1;
3849 }
3850 StringExtensions.containsIgnoreCase = containsIgnoreCase;
3851 /**
3852 * Normalizes case for a string.
3853 * Used by equalIgnoreCase method.
3854 */
3855 function normalizeCase(value) {
3856 Utility.throwIfNullOrUndefined(value, StringExtensions, 'normalizeCase', 'value');
3857 return value.toUpperCase();
3858 }
3859 StringExtensions.normalizeCase = normalizeCase;
3860 /**
3861 * Is string null or empty or undefined?
3862 * @return True if the value is null or undefined or empty string,
3863 * otherwise false.
3864 */
3865 function isNullOrEmpty(value) {
3866 return (value == null) || (value.length === 0);
3867 }
3868 StringExtensions.isNullOrEmpty = isNullOrEmpty;
3869 /**
3870 * Returns true if the string is null, undefined, empty, or only includes white spaces.
3871 * @return True if the str is null, undefined, empty, or only includes white spaces,
3872 * otherwise false.
3873 */
3874 function isNullOrUndefinedOrWhiteSpaceString(str) {
3875 return StringExtensions.isNullOrEmpty(str) || StringExtensions.isNullOrEmpty(str.trim());
3876 }
3877 StringExtensions.isNullOrUndefinedOrWhiteSpaceString = isNullOrUndefinedOrWhiteSpaceString;
3878 /**
3879 * Returns a value indicating whether the str contains any whitespace.
3880 */
3881 function containsWhitespace(str) {
3882 Utility.throwIfNullOrUndefined(str, this, 'containsWhitespace', 'str');
3883 var expr = /\s/;
3884 return expr.test(str);
3885 }
3886 StringExtensions.containsWhitespace = containsWhitespace;
3887 /**
3888 * Returns a value indicating whether the str is a whitespace string.
3889 */
3890 function isWhitespace(str) {
3891 Utility.throwIfNullOrUndefined(str, this, 'isWhitespace', 'str');
3892 return str.trim() === '';
3893 }
3894 StringExtensions.isWhitespace = isWhitespace;
3895 /**
3896 * Returns the string with any trailing whitespace from str removed.
3897 */
3898 function trimTrailingWhitespace(str) {
3899 Utility.throwIfNullOrUndefined(str, this, 'trimTrailingWhitespace', 'str');
3900 return str.replace(/\s+$/, '');
3901 }
3902 StringExtensions.trimTrailingWhitespace = trimTrailingWhitespace;
3903 /**
3904 * Returns the string with any leading and trailing whitespace from str removed.
3905 */
3906 function trimWhitespace(str) {
3907 Utility.throwIfNullOrUndefined(str, this, 'trimWhitespace', 'str');
3908 return str.replace(/^\s+/, '').replace(/\s+$/, '');
3909 }
3910 StringExtensions.trimWhitespace = trimWhitespace;
3911 /**
3912 * Returns length difference between the two provided strings.
3913 */
3914 function getLengthDifference(left, right) {
3915 Utility.throwIfNullOrUndefined(left, this, 'getLengthDifference', 'left');
3916 Utility.throwIfNullOrUndefined(right, this, 'getLengthDifference', 'right');
3917 return Math.abs(left.length - right.length);
3918 }
3919 StringExtensions.getLengthDifference = getLengthDifference;
3920 /**
3921 * Repeat char or string several times.
3922 * @param char The string to repeat.
3923 * @param count How many times to repeat the string.
3924 */
3925 function repeat(char, count) {
3926 var result = "";
3927 for (var i = 0; i < count; i++) {
3928 result += char;
3929 }
3930 return result;
3931 }
3932 StringExtensions.repeat = repeat;
3933 /**
3934 * Replace all the occurrences of the textToFind in the text with the textToReplace.
3935 * @param text The original string.
3936 * @param textToFind Text to find in the original string.
3937 * @param textToReplace New text replacing the textToFind.
3938 */
3939 function replaceAll(text, textToFind, textToReplace) {
3940 if (!textToFind)
3941 return text;
3942 var pattern = escapeStringForRegex(textToFind);
3943 return text.replace(new RegExp(pattern, 'gi'), textToReplace);
3944 }
3945 StringExtensions.replaceAll = replaceAll;
3946 function ensureUniqueNames(names) {
3947 debug.assertValue(names, 'names');
3948 var usedNames = {};
3949 // Make sure we are giving fair chance for all columns to stay with their original name
3950 // First we fill the used names map to contain all the original unique names from the list.
3951 for (var _i = 0, names_1 = names; _i < names_1.length; _i++) {
3952 var name_1 = names_1[_i];
3953 usedNames[name_1] = false;
3954 }
3955 var uniqueNames = [];
3956 // Now we go over all names and find a unique name for each
3957 for (var _a = 0, names_2 = names; _a < names_2.length; _a++) {
3958 var name_2 = names_2[_a];
3959 var uniqueName = name_2;
3960 // If the (original) column name is already taken lets try to find another name
3961 if (usedNames[uniqueName]) {
3962 var counter = 0;
3963 // Find a name that is not already in the map
3964 while (usedNames[uniqueName] !== undefined) {
3965 uniqueName = name_2 + "." + (++counter);
3966 }
3967 }
3968 uniqueNames.push(uniqueName);
3969 usedNames[uniqueName] = true;
3970 }
3971 return uniqueNames;
3972 }
3973 StringExtensions.ensureUniqueNames = ensureUniqueNames;
3974 /**
3975 * Returns a name that is not specified in the values.
3976 */
3977 function findUniqueName(usedNames, baseName) {
3978 debug.assertValue(usedNames, 'usedNames');
3979 debug.assertValue(baseName, 'baseName');
3980 // Find a unique name
3981 var i = 0, uniqueName = baseName;
3982 while (usedNames[uniqueName]) {
3983 uniqueName = baseName + (++i);
3984 }
3985 return uniqueName;
3986 }
3987 StringExtensions.findUniqueName = findUniqueName;
3988 function constructCommaSeparatedList(list, resourceProvider, maxValue) {
3989 if (!list || list.length === 0)
3990 return '';
3991 if (maxValue === null || maxValue === undefined)
3992 maxValue = Number.MAX_VALUE;
3993 var length = Math.min(maxValue, list.length);
3994 var replacedList = [];
3995 // Only need to replace user entries of {0} and {1} since we build the list in pairs.
3996 for (var j = 0; j < 2; j++) {
3997 var targetValue = '{' + j + '}';
3998 var replaceValue = '_|_<' + j + '>_|_';
3999 for (var i = 0; i < length; i++) {
4000 if (list[i].indexOf(targetValue) > -1) {
4001 list[i] = list[i].replace(targetValue, replaceValue);
4002 replacedList.push({ targetValue: targetValue, replaceValue: replaceValue });
4003 }
4004 }
4005 }
4006 var commaSeparatedList = '';
4007 for (var i = 0; i < length; i++) {
4008 if (i === 0)
4009 commaSeparatedList = list[i];
4010 else
4011 commaSeparatedList = StringExtensions.format(resourceProvider.get('FilterRestatement_Comma'), commaSeparatedList, list[i]);
4012 }
4013 for (var i = 0; i < replacedList.length; i++) {
4014 commaSeparatedList = commaSeparatedList.replace(replacedList[i].replaceValue, replacedList[i].targetValue);
4015 }
4016 return commaSeparatedList;
4017 }
4018 StringExtensions.constructCommaSeparatedList = constructCommaSeparatedList;
4019 function escapeStringForRegex(s) {
4020 return s.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, '\\$1');
4021 }
4022 StringExtensions.escapeStringForRegex = escapeStringForRegex;
4023 /**
4024 * Remove file name reserved characters <>:"/\|?* from input string.
4025 */
4026 function normalizeFileName(fileName) {
4027 debug.assertValue(fileName, 'fileName');
4028 return fileName.replace(/[\<\>\:"\/\\\|\?*]/g, '');
4029 }
4030 StringExtensions.normalizeFileName = normalizeFileName;
4031 /**
4032 * Similar to JSON.stringify, but strips away escape sequences so that the resulting
4033 * string is human-readable (and parsable by JSON formatting/validating tools).
4034 */
4035 function stringifyAsPrettyJSON(object) {
4036 //let specialCharacterRemover = (key: string, value: string) => value.replace(/[^\w\s]/gi, '');
4037 return JSON.stringify(object /*, specialCharacterRemover*/);
4038 }
4039 StringExtensions.stringifyAsPrettyJSON = stringifyAsPrettyJSON;
4040 /**
4041 * Derive a CLS-compliant name from a specified string. If no allowed characters are present, return a fallback string instead.
4042 * TODO (6708134): this should have a fully Unicode-aware implementation
4043 */
4044 function deriveClsCompliantName(input, fallback) {
4045 debug.assertValue(input, 'input');
4046 var result = input.replace(/^[^A-Za-z]*/g, '').replace(/[ :\.\/\\\-\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]/g, '_').replace(/[\W]/g, '');
4047 return result.length > 0 ? result : fallback;
4048 }
4049 StringExtensions.deriveClsCompliantName = deriveClsCompliantName;
4050 /** Performs cheap sanitization by stripping away HTML tag (<>) characters. */
4051 function stripTagDelimiters(s) {
4052 return s.replace(HtmlTagRegex, '');
4053 }
4054 StringExtensions.stripTagDelimiters = stripTagDelimiters;
4055 })(StringExtensions = jsCommon.StringExtensions || (jsCommon.StringExtensions = {}));
4056 /**
4057 * The general utility class.
4058 */
4059 var Utility = (function () {
4060 function Utility() {
4061 }
4062 /**
4063 * Ensures the specified value is not null or undefined. Throws a relevent exception if it is.
4064 * @param value The value to check.
4065 * @param context The context from which the check originated.
4066 * @param methodName The name of the method that initiated the check.
4067 * @param parameterName The parameter name of the value to check.
4068 */
4069 Utility.throwIfNullOrUndefined = function (value, context, methodName, parameterName) {
4070 if (value === null) {
4071 Utility.throwException(jsCommon.Errors.argumentNull(Utility.getComponentName(context) + methodName + '.' + parameterName));
4072 }
4073 else if (typeof (value) === Utility.Undefined) {
4074 Utility.throwException(jsCommon.Errors.argumentUndefined(Utility.getComponentName(context) + methodName + '.' + parameterName));
4075 }
4076 };
4077 /**
4078 * Ensures the specified value is not null, undefined or empty. Throws a relevent exception if it is.
4079 * @param value The value to check.
4080 * @param context The context from which the check originated.
4081 * @param methodName The name of the method that initiated the check.
4082 * @param parameterName The parameter name of the value to check.
4083 */
4084 Utility.throwIfNullOrEmpty = function (value, context, methodName, parameterName) {
4085 Utility.throwIfNullOrUndefined(value, context, methodName, parameterName);
4086 if (!value.length) {
4087 Utility.throwException(jsCommon.Errors.argumentOutOfRange(Utility.getComponentName(context) + methodName + '.' + parameterName));
4088 }
4089 };
4090 /**
4091 * Ensures the specified string is not null, undefined or empty. Throws a relevent exception if it is.
4092 * @param value The value to check.
4093 * @param context The context from which the check originated.
4094 * @param methodName The name of the method that initiated the check.
4095 * @param parameterName The parameter name of the value to check.
4096 */
4097 Utility.throwIfNullOrEmptyString = function (value, context, methodName, parameterName) {
4098 Utility.throwIfNullOrUndefined(value, context, methodName, parameterName);
4099 if (value.length < 1) {
4100 Utility.throwException(jsCommon.Errors.argumentOutOfRange(Utility.getComponentName(context) + methodName + '.' + parameterName));
4101 }
4102 };
4103 /**
4104 * Ensures the specified value is not null, undefined, whitespace or empty. Throws a relevent exception if it is.
4105 * @param value The value to check.
4106 * @param context The context from which the check originated.
4107 * @param methodName The name of the method that initiated the check.
4108 * @param parameterName The parameter name of the value to check.
4109 */
4110 Utility.throwIfNullEmptyOrWhitespaceString = function (value, context, methodName, parameterName) {
4111 Utility.throwIfNullOrUndefined(value, context, methodName, parameterName);
4112 if (StringExtensions.isNullOrUndefinedOrWhiteSpaceString(value)) {
4113 Utility.throwException(jsCommon.Errors.argumentOutOfRange(Utility.getComponentName(context) + methodName + '.' + parameterName));
4114 }
4115 };
4116 /**
4117 * Ensures the specified condition is true. Throws relevant exception if it isn't.
4118 * @param condition The condition to check.
4119 * @param context The context from which the check originated.
4120 * @param methodName The name of the method that initiated the check.
4121 * @param parameterName The parameter name against which the condition is checked.
4122 */
4123 Utility.throwIfNotTrue = function (condition, context, methodName, parameterName) {
4124 if (!condition) {
4125 Utility.throwException(jsCommon.Errors.argument(parameterName, Utility.getComponentName(context) + methodName + '.' + parameterName));
4126 }
4127 };
4128 /**
4129 * Checks whether the provided value is a 'string'.
4130 * @param value The value to test.
4131 */
4132 Utility.isString = function (value) {
4133 return ((typeof value) === 'string');
4134 };
4135 /**
4136 * Checks whether the provided value is a 'boolean'.
4137 * @param value The value to test.
4138 */
4139 Utility.isBoolean = function (value) {
4140 return ((typeof value) === 'boolean');
4141 };
4142 /**
4143 * Checks whether the provided value is a 'number'.
4144 * @param value The value to test.
4145 */
4146 Utility.isNumber = function (value) {
4147 return ((typeof value) === 'number');
4148 };
4149 /**
4150 * Checks whether the provided value is a Date instance.
4151 * @param value The value to test.
4152 */
4153 Utility.isDate = function (value) {
4154 return Utility.isObject(value) && (value instanceof Date);
4155 };
4156 /**
4157 * Checks whether the provided value is an 'object'.
4158 * @param value The value to test.
4159 */
4160 Utility.isObject = function (value) {
4161 return (value != null) && ((typeof value) === 'object');
4162 };
4163 /**
4164 * Checks whether the provided value is null or undefined.
4165 * @param value The value to test.
4166 */
4167 Utility.isNullOrUndefined = function (value) {
4168 return (value === null) || (typeof (value) === Utility.Undefined);
4169 };
4170 /**
4171 * Combine a base url and a path.
4172 * @param baseUrl The base url.
4173 * @param path The path to add on to the base url.
4174 * @returns The combined url.
4175 */
4176 Utility.urlCombine = function (baseUrl, path) {
4177 Utility.throwIfNullOrUndefined(baseUrl, null, "urlCombine", "baseUrl");
4178 Utility.throwIfNullOrUndefined(path, null, "urlCombine", "path");
4179 // should any of the components be empty, fail gracefuly - this is important when using the test page
4180 if (StringExtensions.isNullOrUndefinedOrWhiteSpaceString(path)) {
4181 return baseUrl;
4182 }
4183 if (StringExtensions.isNullOrUndefinedOrWhiteSpaceString(baseUrl)) {
4184 return path;
4185 }
4186 var finalUrl = baseUrl;
4187 if (finalUrl.charAt(finalUrl.length - 1) === '/') {
4188 if (path.charAt(0) === '/')
4189 path = path.slice(1);
4190 }
4191 else {
4192 if (path.charAt(0) !== '/')
4193 path = '/' + path;
4194 }
4195 return finalUrl + path;
4196 };
4197 Utility.getAbsoluteUri = function (path) {
4198 Utility.throwIfNullOrUndefined(path, null, "getAbsoluteUri", "path");
4199 var url = path;
4200 // Make absolute
4201 if (url && url.indexOf('http') === -1) {
4202 url = Utility.urlCombine(clusterUri, url);
4203 }
4204 return url;
4205 };
4206 Utility.getStaticResourceUri = function (path) {
4207 Utility.throwIfNullOrUndefined(path, null, "getStaticResourceUri", "path");
4208 var url = path;
4209 // Make absolute
4210 if (url && url.indexOf('http') === -1) {
4211 url = jsCommon.Utility.urlCombine(Utility.staticContentLocation, url);
4212 }
4213 return url;
4214 };
4215 Utility.getComponentName = function (context) {
4216 return !context ? '' : (typeof context).toString() + '.';
4217 };
4218 Utility.throwException = function (e) {
4219 jsCommon.Trace.error(StringExtensions.format("Throwing exception: {0}", JSON.stringify(e)),
4220 /*includeStackTrace*/ e.stack != null ? false : true);
4221 throw e;
4222 };
4223 Utility.createClassSelector = function (className) {
4224 Utility.throwIfNullOrEmptyString(className, null, 'CreateClassSelector', 'className');
4225 return '.' + className;
4226 };
4227 Utility.createIdSelector = function (id) {
4228 Utility.throwIfNullOrEmptyString(id, null, 'CreateIdSelector', 'id');
4229 return '#' + id;
4230 };
4231 /**
4232 * Creates a client-side Guid string.
4233 * @returns A string representation of a Guid.
4234 */
4235 Utility.generateGuid = function () {
4236 var guid = "", idx = 0;
4237 for (idx = 0; idx < 32; idx += 1) {
4238 var guidDigitsItem = Math.random() * 16 | 0;
4239 switch (idx) {
4240 case 8:
4241 case 12:
4242 case 16:
4243 case 20:
4244 guid += "-";
4245 break;
4246 }
4247 guid += guidDigitsItem.toString(16);
4248 }
4249 return guid;
4250 };
4251 /**
4252 * Try extract a cookie from {@link document.cookie} identified by key.
4253 */
4254 Utility.getCookieValue = function (key) {
4255 // the cookie is of the format <key1=value1>; <key2=value2>. Split by ';', then by '='
4256 // to search for the key
4257 var keyValuePairs = document.cookie.split(';');
4258 for (var i = 0; i < keyValuePairs.length; i++) {
4259 var keyValue = keyValuePairs[i];
4260 var split = keyValue.split('=');
4261 if (split.length > 0 && split[0].trim() === key) {
4262 return keyValue.substr(keyValue.indexOf('=') + 1);
4263 }
4264 }
4265 return null;
4266 };
4267 /**
4268 * Extracts the protocol://hostname section of a url.
4269 * @param url The URL from which to extract the section.
4270 * @returns The protocol://hostname portion of the given URL.
4271 */
4272 Utility.getDomainForUrl = function (url) {
4273 var hrefObject = Utility.getHrefObjectFromUrl(url);
4274 return hrefObject.prop('protocol') + '//' + hrefObject.prop('hostname');
4275 };
4276 /**
4277 * Extracts the hostname and absolute path sections of a url.
4278 * @param url The URL from which to extract the section.
4279 * @returns The hostname and absolute path portion of the given URL.
4280 */
4281 Utility.getHostNameForUrl = function (url) {
4282 var hrefObject = Utility.getHrefObjectFromUrl(url);
4283 return Utility.urlCombine(hrefObject.prop('hostname'), hrefObject.prop('pathname'));
4284 };
4285 /**
4286 * Return the original url with query string stripped.
4287 * @param url The URL from which to extract the section.
4288 * @returns the original url with query string stripped.
4289 */
4290 Utility.getUrlWithoutQueryString = function (url) {
4291 var hrefObject = Utility.getHrefObjectFromUrl(url);
4292 return hrefObject.prop('protocol') + '//' + Utility.urlCombine(hrefObject.prop('host'), hrefObject.prop('pathname'));
4293 };
4294 /**
4295 * Extracts the protocol section of a url.
4296 * @param url The URL from which to extract the section.
4297 * @returns The protocol for the current URL.
4298 */
4299 Utility.getProtocolFromUrl = function (url) {
4300 return Utility.getHrefObjectFromUrl(url).prop('protocol').replace(':', '');
4301 };
4302 /**
4303 * Returns a formatted href object from a URL.
4304 * @param url The URL used to generate the object.
4305 * @returns A jQuery object with the url.
4306 */
4307 Utility.getHrefObjectFromUrl = function (url) {
4308 var aObject = $('<a>');
4309 aObject = aObject.prop('href', url);
4310 return aObject;
4311 };
4312 /**
4313 * Converts a WCF representation of a dictionary to a JavaScript dictionary.
4314 * @param wcfDictionary The WCF dictionary to convert.
4315 * @returns The native JavaScript representation of this dictionary.
4316 */
4317 Utility.convertWcfToJsDictionary = function (wcfDictionary) {
4318 // convert the WCF JSON representation of a dictionary
4319 // to JS dictionary.
4320 // WCF representation: [{"Key": Key, "Value": Value}..]
4321 // JS representation: [Key: Value ..]
4322 var result = {};
4323 for (var i = 0; i < wcfDictionary.length; i++) {
4324 var keyValuePair = wcfDictionary[i];
4325 result[keyValuePair['Key']] = keyValuePair['Value'];
4326 }
4327 return result;
4328 };
4329 Utility.getDateFromWcfJsonString = function (jsonDate, fromUtcMilliseconds) {
4330 if (StringExtensions.isNullOrEmpty(jsonDate)) {
4331 return null;
4332 }
4333 var begIndex = jsonDate.indexOf('(');
4334 var endIndex = jsonDate.indexOf(')');
4335 if (begIndex !== -1 && endIndex !== -1) {
4336 var milliseconds = parseInt(jsonDate.substring(begIndex + 1, endIndex), 10);
4337 if (fromUtcMilliseconds) {
4338 return new Date(milliseconds);
4339 }
4340 else {
4341 var retValue = new Date(0);
4342 retValue.setUTCMilliseconds(milliseconds);
4343 return retValue;
4344 }
4345 }
4346 return null;
4347 };
4348 /**
4349 * Get the outer html of the given jquery object.
4350 * @param content The jquery object.
4351 * @returns The entire html representation of the object.
4352 */
4353 Utility.getOuterHtml = function (content) {
4354 return $('<div>').append(content).html();
4355 };
4356 /**
4357 * Comparison Method: Compares two integer numbers.
4358 * @param a An integer value.
4359 * @param b An integer value.
4360 * @returns The comparison result.
4361 */
4362 Utility.compareInt = function (a, b) {
4363 return a - b;
4364 };
4365 /**
4366 * Return the index of the smallest value in a numerical array.
4367 * @param a A numeric array.
4368 * @returns The index of the smallest value in the array.
4369 */
4370 Utility.getIndexOfMinValue = function (a) {
4371 var retValue = 0;
4372 var currentMinValue = a[0];
4373 for (var i = 0; i < a.length; i++) {
4374 if (a[i] < currentMinValue) {
4375 currentMinValue = a[i];
4376 retValue = i;
4377 }
4378 }
4379 return retValue;
4380 };
4381 /**
4382 * Extracts a url from a background image attribute in the format of: url('www.foobar.com/image.png').
4383 * @param input The value of the background-image attribute.
4384 * @returns The extracted url.
4385 */
4386 Utility.extractUrlFromCssBackgroundImage = function (input) {
4387 return input.replace(/"/g, "").replace(/url\(|\)$/ig, "");
4388 };
4389 /**
4390 * Verifies image data url of images.
4391 */
4392 Utility.isValidImageDataUrl = function (url) {
4393 var regex = new RegExp('data:(image\/(png|jpg|jpeg|gif|svg))');
4394 return regex.test(url);
4395 };
4396 Utility.isLocalUrl = function (url) {
4397 return _.startsWith(url, "data:") || _.startsWith(url, "blob:");
4398 };
4399 /**
4400 * Downloads a content string as a file.
4401 * @param content Content stream.
4402 * @param fileName File name to use.
4403 */
4404 Utility.saveAsFile = function (content, fileName) {
4405 var contentBlob = new Blob([content], { type: HttpConstants.ApplicationOctetStream });
4406 var url = window['webkitURL'] || URL;
4407 var urlLink = url.createObjectURL(contentBlob);
4408 var fileNameLink = fileName || urlLink;
4409 // IE support, use msSaveOrOpenBlob API
4410 if (window.navigator.msSaveOrOpenBlob) {
4411 window.navigator.msSaveOrOpenBlob(contentBlob, fileNameLink);
4412 return;
4413 }
4414 // WebKit-based browser support requires generating an anchor tag with
4415 // download attribute set to blob store and triggering a click event to invoke
4416 // a download to file action
4417 var hyperlink = document.createElement('a');
4418 hyperlink.href = urlLink;
4419 hyperlink.target = '_blank';
4420 hyperlink['download'] = fileNameLink;
4421 document.body.appendChild(hyperlink);
4422 hyperlink.click();
4423 document.body.removeChild(hyperlink);
4424 };
4425 /**
4426 * Helper method to get the simple type name from a typed object.
4427 * @param obj The typed object.
4428 * @returns The simple type name for the object.
4429 */
4430 Utility.getType = function (obj) {
4431 Utility.throwIfNullEmptyOrWhitespaceString(obj.__type, this, 'getType', 'obj');
4432 var parts = obj.__type.split(":");
4433 if (parts.length !== 2) {
4434 jsCommon.Errors.argument("obj.__type", "Type String not in expected format [Type]#[Namespace]: " + obj.__type);
4435 }
4436 if (parts[1] !== Utility.TypeNamespace) {
4437 jsCommon.Errors.argument("obj.__type", "Type Namespace not expected: " + parts[1]);
4438 }
4439 return parts[0];
4440 };
4441 /**
4442 * Check if an element supports a specific event type.
4443 * @param eventName The name of the event.
4444 * @param element The element to test for event support.
4445 * @returns Whether the even is supported on the provided element.
4446 */
4447 Utility.isEventSupported = function (eventName, element) {
4448 eventName = 'on' + eventName;
4449 var isSupported = (eventName in element);
4450 if (!isSupported) {
4451 // if we can't use setAttribute try a generic element
4452 if (!element.setAttribute) {
4453 element = document.createElement('div');
4454 }
4455 if (element.setAttribute && element.removeAttribute) {
4456 element.setAttribute(eventName, '');
4457 isSupported = typeof element[eventName] === 'function';
4458 // if the property was created - remove it
4459 if (typeof element[eventName] !== 'undefined') {
4460 element[eventName] = null;
4461 }
4462 element.removeAttribute(eventName);
4463 }
4464 }
4465 element = null;
4466 return isSupported;
4467 };
4468 Utility.toPixel = function (pixelAmount) {
4469 Utility.throwIfNullOrUndefined(pixelAmount, this, "toPixel", "pixelAmount");
4470 return pixelAmount.toString() + jsCommon.CssConstants.pixelUnits;
4471 };
4472 Utility.getPropertyCount = function (object) {
4473 Utility.throwIfNullOrUndefined(object, this, "getPropertyCount", "object");
4474 return Object.getOwnPropertyNames(object).length;
4475 };
4476 /**
4477 * Check if an element supports a specific event type.
4478 * @param filePath File path.
4479 * @returns File extension.
4480 */
4481 Utility.getFileExtension = function (filePath) {
4482 if (filePath) {
4483 var index = filePath.lastIndexOf('.');
4484 if (index >= 0)
4485 return filePath.substr(index + 1);
4486 }
4487 return '';
4488 };
4489 /**
4490 * Extract the filename out of a full path delimited by '\' or '/'.
4491 * @param filePath File path.
4492 * @returns filename File name.
4493 */
4494 Utility.extractFileNameFromPath = function (filePath) {
4495 return filePath.replace(/^.*[\\\/]/, '');
4496 };
4497 /**
4498 * This method indicates whether window.clipboardData is supported.
4499 * For example, clipboard support for Windows Store apps is currently disabled
4500 * since window.clipboardData is unsupported (it raises access denied error)
4501 * since clipboard in Windows Store is being
4502 * achieved through Windows.ApplicationModel.DataTransfer.Clipboard class.
4503 */
4504 Utility.canUseClipboard = function () {
4505 return (typeof MSApp === "undefined");
4506 };
4507 Utility.is64BitOperatingSystem = function () {
4508 return navigator.userAgent.indexOf("WOW64") !== -1 ||
4509 navigator.userAgent.indexOf("Win64") !== -1;
4510 };
4511 Utility.parseNumber = function (value, defaultValue) {
4512 if (value === null)
4513 return null;
4514 if (value === undefined)
4515 return defaultValue;
4516 var result = Number(value);
4517 if (isFinite(result))
4518 return result;
4519 if (isNaN(result) && !(typeof value === "number" || value === "NaN"))
4520 return defaultValue;
4521 return result;
4522 };
4523 Utility.getURLParamValue = function (name) {
4524 var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
4525 if (results == null) {
4526 return null;
4527 }
4528 else {
4529 return results[1] || 0;
4530 }
4531 };
4532 /**
4533 * Return local timezone.
4534 * This function uses summer and winter offset to determine local time zone.
4535 * The result localTimeZoneString must be a subset of the strings used by server,
4536 * as documented here: https://msdn.microsoft.com/en-us/library/gg154758.aspx (Dynamic Daylight Savings Time (Compact 2013)).
4537 * @return Local timezone string or UTC if timezone cannot be found.
4538 */
4539 Utility.getLocalTimeZoneString = function () {
4540 var timeSummer = new Date(Date.UTC(2005, 6, 30, 0, 0, 0, 0));
4541 var summerOffset = -1 * timeSummer.getTimezoneOffset();
4542 var timeWinter = new Date(Date.UTC(2005, 12, 30, 0, 0, 0, 0));
4543 var winterOffset = -1 * timeWinter.getTimezoneOffset();
4544 var localTimeZoneString;
4545 if (-720 === summerOffset && -720 === winterOffset) {
4546 localTimeZoneString = 'Dateline Standard Time';
4547 }
4548 else if (-660 === summerOffset && -660 === winterOffset) {
4549 localTimeZoneString = 'UTC-11';
4550 }
4551 else if (-660 === summerOffset && -660 === winterOffset) {
4552 localTimeZoneString = 'Samoa Standard Time';
4553 }
4554 else if (-600 === summerOffset && -600 === winterOffset) {
4555 localTimeZoneString = 'Hawaiian Standard Time';
4556 }
4557 else if (-480 === summerOffset && -540 === winterOffset) {
4558 localTimeZoneString = 'Alaskan Standard Time';
4559 }
4560 else if (-420 === summerOffset && -480 === winterOffset) {
4561 localTimeZoneString = 'Pacific Standard Time';
4562 }
4563 else if (-420 === summerOffset && -420 === winterOffset) {
4564 localTimeZoneString = 'US Mountain Standard Time';
4565 }
4566 else if (-360 === summerOffset && -420 === winterOffset) {
4567 localTimeZoneString = 'Mountain Standard Time';
4568 }
4569 else if (-360 === summerOffset && -360 === winterOffset) {
4570 localTimeZoneString = 'Central America Standard Time';
4571 }
4572 else if (-300 === summerOffset && -360 === winterOffset) {
4573 localTimeZoneString = 'Central Standard Time';
4574 }
4575 else if (-300 === summerOffset && -300 === winterOffset) {
4576 localTimeZoneString = 'SA Pacific Standard Time';
4577 }
4578 else if (-240 === summerOffset && -300 === winterOffset) {
4579 localTimeZoneString = 'Eastern Standard Time';
4580 }
4581 else if (-270 === summerOffset && -270 === winterOffset) {
4582 localTimeZoneString = 'Venezuela Standard Time';
4583 }
4584 else if (-240 === summerOffset && -240 === winterOffset) {
4585 localTimeZoneString = 'SA Western Standard Time';
4586 }
4587 else if (-240 === summerOffset && -180 === winterOffset) {
4588 localTimeZoneString = 'Central Brazilian Standard Time';
4589 }
4590 else if (-180 === summerOffset && -240 === winterOffset) {
4591 localTimeZoneString = 'Atlantic Standard Time';
4592 }
4593 else if (-180 === summerOffset && -180 === winterOffset) {
4594 localTimeZoneString = 'Montevideo Standard Time';
4595 }
4596 else if (-180 === summerOffset && -120 === winterOffset) {
4597 localTimeZoneString = 'E. South America Standard Time';
4598 }
4599 else if (-150 === summerOffset && -210 === winterOffset) {
4600 localTimeZoneString = 'Mid-Atlantic Standard Time';
4601 }
4602 else if (-120 === summerOffset && -120 === winterOffset) {
4603 localTimeZoneString = 'SA Eastern Standard Time';
4604 }
4605 else if (0 === summerOffset && 0 === winterOffset) {
4606 localTimeZoneString = 'UTC';
4607 }
4608 else if (60 === summerOffset && 0 === winterOffset) {
4609 localTimeZoneString = 'GMT Standard Time';
4610 }
4611 else if (60 === summerOffset && 120 === winterOffset) {
4612 localTimeZoneString = 'Namibia Standard Time';
4613 }
4614 else if (120 === summerOffset && 60 === winterOffset) {
4615 localTimeZoneString = 'Romance Standard Time';
4616 }
4617 else if (120 === summerOffset && 120 === winterOffset) {
4618 localTimeZoneString = 'South Africa Standard Time';
4619 }
4620 else if (180 === summerOffset && 120 === winterOffset) {
4621 localTimeZoneString = 'GTB Standard Time';
4622 }
4623 else if (180 === summerOffset && 180 === winterOffset) {
4624 localTimeZoneString = 'E. Africa Standard Time';
4625 }
4626 else if (240 === summerOffset && 180 === winterOffset) {
4627 localTimeZoneString = 'Russian Standard Time';
4628 }
4629 else if (240 === summerOffset && 240 === winterOffset) {
4630 localTimeZoneString = 'Arabian Standard Time';
4631 }
4632 else if (270 === summerOffset && 210 === winterOffset) {
4633 localTimeZoneString = 'Iran Standard Time';
4634 }
4635 else if (270 === summerOffset && 270 === winterOffset) {
4636 localTimeZoneString = 'Afghanistan Standard Time';
4637 }
4638 else if (300 === summerOffset && 240 === winterOffset) {
4639 localTimeZoneString = 'Pakistan Standard Time';
4640 }
4641 else if (300 === summerOffset && 300 === winterOffset) {
4642 localTimeZoneString = 'West Asia Standard Time';
4643 }
4644 else if (330 === summerOffset && 330 === winterOffset) {
4645 localTimeZoneString = 'India Standard Time';
4646 }
4647 else if (345 === summerOffset && 345 === winterOffset) {
4648 localTimeZoneString = 'Nepal Standard Time';
4649 }
4650 else if (360 === summerOffset && 300 === winterOffset) {
4651 localTimeZoneString = 'N. Central Asia Standard Time';
4652 }
4653 else if (360 === summerOffset && 360 === winterOffset) {
4654 localTimeZoneString = 'Central Asia Standard Time';
4655 }
4656 else if (390 === summerOffset && 390 === winterOffset) {
4657 localTimeZoneString = 'Myanmar Standard Time';
4658 }
4659 else if (420 === summerOffset && 360 === winterOffset) {
4660 localTimeZoneString = 'North Asia Standard Time';
4661 }
4662 else if (420 === summerOffset && 420 === winterOffset) {
4663 localTimeZoneString = 'SE Asia Standard Time';
4664 }
4665 else if (480 === summerOffset && 420 === winterOffset) {
4666 localTimeZoneString = 'North Asia East Standard Time';
4667 }
4668 else if (480 === summerOffset && 480 === winterOffset) {
4669 localTimeZoneString = 'China Standard Time';
4670 }
4671 else if (540 === summerOffset && 480 === winterOffset) {
4672 localTimeZoneString = 'Yakutsk Standard Time';
4673 }
4674 else if (540 === summerOffset && 540 === winterOffset) {
4675 localTimeZoneString = 'Tokyo Standard Time';
4676 }
4677 else if (570 === summerOffset && 570 === winterOffset) {
4678 localTimeZoneString = 'Cen. Australia Standard Time';
4679 }
4680 else if (600 === summerOffset && 600 === winterOffset) {
4681 localTimeZoneString = 'E. Australia Standard Time';
4682 }
4683 else if (600 === summerOffset && 660 === winterOffset) {
4684 localTimeZoneString = 'AUS Eastern Standard Time';
4685 }
4686 else if (660 === summerOffset && 600 === winterOffset) {
4687 localTimeZoneString = 'Tasmania Standard Time';
4688 }
4689 else if (660 === summerOffset && 660 === winterOffset) {
4690 localTimeZoneString = 'West Pacific Standard Time';
4691 }
4692 else if (690 === summerOffset && 690 === winterOffset) {
4693 localTimeZoneString = 'Central Pacific Standard Time';
4694 }
4695 else if (720 === summerOffset && 660 === winterOffset) {
4696 localTimeZoneString = 'Magadan Standard Time';
4697 }
4698 else if (720 === summerOffset && 720 === winterOffset) {
4699 localTimeZoneString = 'Fiji Standard Time';
4700 }
4701 else if (720 === summerOffset && 780 === winterOffset) {
4702 localTimeZoneString = 'New Zealand Standard Time';
4703 }
4704 else if (780 === summerOffset && 780 === winterOffset) {
4705 localTimeZoneString = 'Tonga Standard Time';
4706 }
4707 else {
4708 localTimeZoneString = 'UTC';
4709 }
4710 return localTimeZoneString;
4711 };
4712 Utility.TypeNamespace = 'http://schemas.microsoft.com/sqlbi/2013/01/NLRuntimeService';
4713 Utility.JsonContentType = 'application/json';
4714 Utility.JpegContentType = 'image/jpeg';
4715 Utility.XJavascriptContentType = 'application/x-javascript';
4716 Utility.JsonDataType = 'json';
4717 Utility.BlobDataType = 'blob';
4718 Utility.HttpGetMethod = 'GET';
4719 Utility.HttpPostMethod = 'POST';
4720 Utility.HttpPutMethod = 'PUT';
4721 Utility.HttpDeleteMethod = 'DELETE';
4722 Utility.HttpContentTypeHeader = 'Content-Type';
4723 Utility.HttpAcceptHeader = 'Accept';
4724 Utility.Undefined = 'undefined';
4725 Utility.staticContentLocation = window.location.protocol + '//' + window.location.host;
4726 return Utility;
4727 }());
4728 jsCommon.Utility = Utility;
4729 var VersionUtility = (function () {
4730 function VersionUtility() {
4731 }
4732 /**
4733 * Compares 2 version strings.
4734 * @param versionA The first version string.
4735 * @param versionB The second version string.
4736 * @returns A result for the comparison.
4737 */
4738 VersionUtility.compareVersions = function (versionA, versionB) {
4739 var a = versionA.split('.').map(parseFloat);
4740 var b = versionB.split('.').map(parseFloat);
4741 var versionParts = Math.max(a.length, b.length);
4742 for (var i = 0; i < versionParts; i++) {
4743 var partA = a[i] || 0;
4744 var partB = b[i] || 0;
4745 if (partA > partB)
4746 return 1;
4747 if (partA < partB)
4748 return -1;
4749 }
4750 return 0;
4751 };
4752 return VersionUtility;
4753 }());
4754 jsCommon.VersionUtility = VersionUtility;
4755 var PerformanceUtil;
4756 (function (PerformanceUtil) {
4757 var PerfMarker = (function () {
4758 function PerfMarker(name) {
4759 this._name = name;
4760 this._start = PerfMarker.begin(name);
4761 }
4762 PerfMarker.begin = function (name) {
4763 if (window.performance === undefined || performance.mark === undefined)
4764 return;
4765 if (console.time) {
4766 console.time(name);
4767 }
4768 name = 'Begin ' + name;
4769 performance.mark(name);
4770 return name;
4771 };
4772 PerfMarker.prototype.end = function () {
4773 if (window.performance === undefined || performance.mark === undefined || performance.measure === undefined)
4774 return;
4775 var name = this._name;
4776 var end = 'End ' + name;
4777 performance.mark(end);
4778 performance.measure(name, this._start, end);
4779 if (console.timeEnd) {
4780 console.timeEnd(name);
4781 }
4782 };
4783 return PerfMarker;
4784 }());
4785 PerformanceUtil.PerfMarker = PerfMarker;
4786 function create(name) {
4787 return new PerfMarker(name);
4788 }
4789 PerformanceUtil.create = create;
4790 })(PerformanceUtil = jsCommon.PerformanceUtil || (jsCommon.PerformanceUtil = {}));
4791 var DeferUtility;
4792 (function (DeferUtility) {
4793 /**
4794 * Wraps a callback and returns a new function.
4795 * The function can be called many times but the callback
4796 * will only be executed once on the next frame.
4797 * Use this to throttle big UI updates and access to DOM.
4798 */
4799 function deferUntilNextFrame(callback) {
4800 var isWaiting, args, context;
4801 if (!window.requestAnimationFrame) {
4802 window.requestAnimationFrame = function (func) { return setTimeout(func, 1000 / 50); };
4803 }
4804 return function () {
4805 if (!isWaiting) {
4806 isWaiting = true;
4807 args = arguments;
4808 context = this;
4809 window.requestAnimationFrame(function () {
4810 isWaiting = false;
4811 callback.apply(context, args);
4812 });
4813 }
4814 };
4815 }
4816 DeferUtility.deferUntilNextFrame = deferUntilNextFrame;
4817 })(DeferUtility = jsCommon.DeferUtility || (jsCommon.DeferUtility = {}));
4818})(jsCommon || (jsCommon = {}));
4819/*
4820 * Power BI Visualizations
4821 *
4822 * Copyright (c) Microsoft Corporation
4823 * All rights reserved.
4824 * MIT License
4825 *
4826 * Permission is hereby granted, free of charge, to any person obtaining a copy
4827 * of this software and associated documentation files (the ""Software""), to deal
4828 * in the Software without restriction, including without limitation the rights
4829 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4830 * copies of the Software, and to permit persons to whom the Software is
4831 * furnished to do so, subject to the following conditions:
4832 *
4833 * The above copyright notice and this permission notice shall be included in
4834 * all copies or substantial portions of the Software.
4835 *
4836 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4837 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4838 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4839 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4840 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4841 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4842 * THE SOFTWARE.
4843 */
4844var jsCommon;
4845(function (jsCommon) {
4846 var TraceItem = (function () {
4847 function TraceItem(text, type, sessionId, requestId) {
4848 this.text = text;
4849 this.type = type;
4850 this.sessionId = sessionId;
4851 this.requestId = requestId;
4852 this.timeStamp = new Date();
4853 }
4854 TraceItem.prototype.toString = function () {
4855 var resultString = '';
4856 resultString += (jsCommon.StringExtensions.format('{0} ({1}): {2}', TraceItem.traceTypeStrings[this.type], this.timeStamp.toUTCString(), this.text));
4857 if (this.requestId)
4858 resultString += ('\n(Request id: ' + this.requestId + ')');
4859 return resultString;
4860 };
4861 TraceItem.traceTypeStrings = [
4862 'INFORMATION',
4863 'VERBOSE',
4864 'WARNING',
4865 'ERROR',
4866 'EXPECTEDERROR',
4867 'UNEXPECTEDERROR',
4868 'FATAL',
4869 ];
4870 return TraceItem;
4871 }());
4872 jsCommon.TraceItem = TraceItem;
4873})(jsCommon || (jsCommon = {}));
4874/*
4875 * Power BI Visualizations
4876 *
4877 * Copyright (c) Microsoft Corporation
4878 * All rights reserved.
4879 * MIT License
4880 *
4881 * Permission is hereby granted, free of charge, to any person obtaining a copy
4882 * of this software and associated documentation files (the ""Software""), to deal
4883 * in the Software without restriction, including without limitation the rights
4884 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4885 * copies of the Software, and to permit persons to whom the Software is
4886 * furnished to do so, subject to the following conditions:
4887 *
4888 * The above copyright notice and this permission notice shall be included in
4889 * all copies or substantial portions of the Software.
4890 *
4891 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4892 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4893 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4894 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4895 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4896 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4897 * THE SOFTWARE.
4898 */
4899var jsCommon;
4900(function (jsCommon) {
4901 var UrlUtils;
4902 (function (UrlUtils) {
4903 var urlRegex = /http[s]?:\/\/(\S)+/gi;
4904 function isValidUrl(value) {
4905 if (jsCommon.StringExtensions.isNullOrEmpty(value))
4906 return false;
4907 var match = jsCommon.RegExpExtensions.run(urlRegex, value);
4908 if (!!match && match.index === 0)
4909 return true;
4910 return false;
4911 }
4912 UrlUtils.isValidUrl = isValidUrl;
4913 /* Tests whether a URL is valid.
4914 * @param url The url to be tested.
4915 * @returns Whether the provided url is valid.
4916 **/
4917 function isValidImageUrl(url) {
4918 // VSTS: 7252099 / 7112236
4919 // For now, passes for any valid Url
4920 return isValidUrl(url);
4921 }
4922 UrlUtils.isValidImageUrl = isValidImageUrl;
4923 function findAllValidUrls(text) {
4924 if (jsCommon.StringExtensions.isNullOrEmpty(text))
4925 return [];
4926 // Find all urls in the text.
4927 // TODO: This could potentially be expensive, maybe include a cap here for text with many urls?
4928 var urlRanges = [];
4929 var matches;
4930 var start = 0;
4931 while ((matches = jsCommon.RegExpExtensions.run(urlRegex, text, start)) !== null) {
4932 var url = matches[0];
4933 var end = matches.index + url.length;
4934 urlRanges.push({
4935 start: matches.index,
4936 end: end,
4937 text: url,
4938 });
4939 start = end;
4940 }
4941 return urlRanges;
4942 }
4943 UrlUtils.findAllValidUrls = findAllValidUrls;
4944 function getBase64ContentFromDataUri(uri) {
4945 if (uri.indexOf('data:') !== 0)
4946 throw new Error("Expected data uri");
4947 // Locate the base 64 content from the URL (e.g. "data:image/png;base64,xxxxx=")
4948 var base64Token = ";base64,";
4949 var indexBase64TokenStart = uri.indexOf(base64Token);
4950 if (indexBase64TokenStart < 0)
4951 throw new Error("Expected base 64 content in data url");
4952 var indexBase64Start = indexBase64TokenStart + base64Token.length;
4953 return uri.substr(indexBase64Start, uri.length - indexBase64Start);
4954 }
4955 UrlUtils.getBase64ContentFromDataUri = getBase64ContentFromDataUri;
4956 })(UrlUtils = jsCommon.UrlUtils || (jsCommon.UrlUtils = {}));
4957})(jsCommon || (jsCommon = {}));
4958/*
4959 * Power BI Visualizations
4960 *
4961 * Copyright (c) Microsoft Corporation
4962 * All rights reserved.
4963 * MIT License
4964 *
4965 * Permission is hereby granted, free of charge, to any person obtaining a copy
4966 * of this software and associated documentation files (the ""Software""), to deal
4967 * in the Software without restriction, including without limitation the rights
4968 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4969 * copies of the Software, and to permit persons to whom the Software is
4970 * furnished to do so, subject to the following conditions:
4971 *
4972 * The above copyright notice and this permission notice shall be included in
4973 * all copies or substantial portions of the Software.
4974 *
4975 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4976 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4977 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4978 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4979 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4980 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4981 * THE SOFTWARE.
4982 */
4983var jsCommon;
4984(function (jsCommon) {
4985 var BrowserUtils;
4986 (function (BrowserUtils) {
4987 function isChrome() {
4988 var vendorName = window.navigator.vendor || "";
4989 var userAgent = window.navigator.userAgent.toLowerCase();
4990 return vendorName.toLowerCase().indexOf('google') > -1 &&
4991 userAgent.indexOf('chrome') > -1 &&
4992 userAgent.indexOf('edge') === -1 &&
4993 userAgent.indexOf('opr') === -1;
4994 }
4995 BrowserUtils.isChrome = isChrome;
4996 function isInternetExplorerOrEdge() {
4997 var userAgent = window.navigator.userAgent.toLowerCase();
4998 return userAgent.indexOf('msie') > -1
4999 || userAgent.indexOf('trident') > -1
5000 || userAgent.indexOf('edge') > -1;
5001 }
5002 BrowserUtils.isInternetExplorerOrEdge = isInternetExplorerOrEdge;
5003 /**
5004 * Get the current version of IE
5005 * @returns The version of Internet Explorer or a 0 (indicating the use of another browser).
5006 */
5007 function getInternetExplorerVersion() {
5008 var retValue = 0;
5009 if (navigator.appName === 'Microsoft Internet Explorer' || window.navigator.userAgent.indexOf('MSIE') >= 0) {
5010 var re = new RegExp('MSIE ([0-9]{1,}[\\.0-9]{0,})');
5011 var result = re.exec(window.navigator.userAgent);
5012 if (result) {
5013 retValue = parseFloat(result[1]);
5014 }
5015 }
5016 return retValue;
5017 }
5018 BrowserUtils.getInternetExplorerVersion = getInternetExplorerVersion;
5019 })(BrowserUtils = jsCommon.BrowserUtils || (jsCommon.BrowserUtils = {}));
5020})(jsCommon || (jsCommon = {}));
5021/*
5022 * Power BI Visualizations
5023 *
5024 * Copyright (c) Microsoft Corporation
5025 * All rights reserved.
5026 * MIT License
5027 *
5028 * Permission is hereby granted, free of charge, to any person obtaining a copy
5029 * of this software and associated documentation files (the ""Software""), to deal
5030 * in the Software without restriction, including without limitation the rights
5031 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5032 * copies of the Software, and to permit persons to whom the Software is
5033 * furnished to do so, subject to the following conditions:
5034 *
5035 * The above copyright notice and this permission notice shall be included in
5036 * all copies or substantial portions of the Software.
5037 *
5038 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5039 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5040 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5041 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5042 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5043 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5044 * THE SOFTWARE.
5045 */
5046var jsCommon;
5047(function (jsCommon) {
5048 /**
5049 * Extensions for Enumerations.
5050 */
5051 var EnumExtensions;
5052 (function (EnumExtensions) {
5053 /**
5054 * Gets a value indicating whether the value has the bit flags set.
5055 */
5056 function hasFlag(value, flag) {
5057 debug.assert(!!flag, 'flag must be specified and nonzero.');
5058 return (value & flag) === flag;
5059 }
5060 EnumExtensions.hasFlag = hasFlag;
5061 /**
5062 * Sets a value of a flag without modifying any other flags.
5063 */
5064 function setFlag(value, flag) {
5065 debug.assert(!!flag, "flag must be specified and nonzero.");
5066 return value |= flag;
5067 }
5068 EnumExtensions.setFlag = setFlag;
5069 /**
5070 * Resets a value of a flag without modifying any other flags.
5071 */
5072 function resetFlag(value, flag) {
5073 debug.assert(!!flag, "flag must be specified and nonzero.");
5074 return value &= ~flag;
5075 }
5076 EnumExtensions.resetFlag = resetFlag;
5077 /**
5078 * According to the TypeScript Handbook, this is safe to do.
5079 */
5080 function toString(enumType, value) {
5081 return enumType[value];
5082 }
5083 EnumExtensions.toString = toString;
5084 })(EnumExtensions = jsCommon.EnumExtensions || (jsCommon.EnumExtensions = {}));
5085 /**
5086 * Extensions to String class.
5087 */
5088 var StringExtensions;
5089 (function (StringExtensions) {
5090 /**
5091 * Checks if a string ends with a sub-string.
5092 */
5093 function endsWith(str, suffix) {
5094 debug.assertValue(str, 'str');
5095 debug.assertValue(suffix, 'suffix');
5096 return str.indexOf(suffix, str.length - suffix.length) !== -1;
5097 }
5098 StringExtensions.endsWith = endsWith;
5099 })(StringExtensions = jsCommon.StringExtensions || (jsCommon.StringExtensions = {}));
5100 var LogicExtensions;
5101 (function (LogicExtensions) {
5102 function XOR(a, b) {
5103 return (a || b) && !(a && b);
5104 }
5105 LogicExtensions.XOR = XOR;
5106 })(LogicExtensions = jsCommon.LogicExtensions || (jsCommon.LogicExtensions = {}));
5107 var JsonComparer;
5108 (function (JsonComparer) {
5109 /**
5110 * Performs JSON-style comparison of two objects.
5111 */
5112 function equals(x, y) {
5113 if (x === y)
5114 return true;
5115 return JSON.stringify(x) === JSON.stringify(y);
5116 }
5117 JsonComparer.equals = equals;
5118 })(JsonComparer = jsCommon.JsonComparer || (jsCommon.JsonComparer = {}));
5119 /**
5120 * Values are in terms of 'pt'
5121 * Convert to pixels using PixelConverter.fromPoint
5122 */
5123 var TextSizeDefaults;
5124 (function (TextSizeDefaults) {
5125 /**
5126 * Stored in terms of 'pt'
5127 * Convert to pixels using PixelConverter.fromPoint
5128 */
5129 TextSizeDefaults.TextSizeMin = 8;
5130 /**
5131 * Stored in terms of 'pt'
5132 * Convert to pixels using PixelConverter.fromPoint
5133 */
5134 TextSizeDefaults.TextSizeMax = 40;
5135 var TextSizeRange = TextSizeDefaults.TextSizeMax - TextSizeDefaults.TextSizeMin;
5136 /**
5137 * Returns the percentage of this value relative to the TextSizeMax
5138 * @param textSize - should be given in terms of 'pt'
5139 */
5140 function getScale(textSize) {
5141 return (textSize - TextSizeDefaults.TextSizeMin) / TextSizeRange;
5142 }
5143 TextSizeDefaults.getScale = getScale;
5144 })(TextSizeDefaults = jsCommon.TextSizeDefaults || (jsCommon.TextSizeDefaults = {}));
5145 var PixelConverter;
5146 (function (PixelConverter) {
5147 var PxPtRatio = 4 / 3;
5148 var PixelString = 'px';
5149 /**
5150 * Appends 'px' to the end of number value for use as pixel string in styles
5151 */
5152 function toString(px) {
5153 return px + PixelString;
5154 }
5155 PixelConverter.toString = toString;
5156 /**
5157 * Converts point value (pt) to pixels
5158 * Returns a string for font-size property
5159 * e.g. fromPoint(8) => '24px'
5160 */
5161 function fromPoint(pt) {
5162 return toString(fromPointToPixel(pt));
5163 }
5164 PixelConverter.fromPoint = fromPoint;
5165 /**
5166 * Converts point value (pt) to pixels
5167 * Returns a number for font-size property
5168 * e.g. fromPoint(8) => 24px
5169 */
5170 function fromPointToPixel(pt) {
5171 return (PxPtRatio * pt);
5172 }
5173 PixelConverter.fromPointToPixel = fromPointToPixel;
5174 /**
5175 * Converts pixel value (px) to pt
5176 * e.g. toPoint(24) => 8
5177 */
5178 function toPoint(px) {
5179 return px / PxPtRatio;
5180 }
5181 PixelConverter.toPoint = toPoint;
5182 })(PixelConverter = jsCommon.PixelConverter || (jsCommon.PixelConverter = {}));
5183 var RegExpExtensions;
5184 (function (RegExpExtensions) {
5185 /**
5186 * Runs exec on regex starting from 0 index
5187 * This is the expected behavior but RegExp actually remember
5188 * the last index they stopped at (found match at) and will
5189 * return unexpected results when run in sequence.
5190 * @param regex - regular expression object
5191 * @param value - string to search wiht regex
5192 * @param start - index within value to start regex
5193 */
5194 function run(regex, value, start) {
5195 debug.assertValue(regex, 'regex');
5196 regex.lastIndex = start || 0;
5197 return regex.exec(value);
5198 }
5199 RegExpExtensions.run = run;
5200 })(RegExpExtensions = jsCommon.RegExpExtensions || (jsCommon.RegExpExtensions = {}));
5201})(jsCommon || (jsCommon = {}));
5202/*
5203 * Power BI Visualizations
5204 *
5205 * Copyright (c) Microsoft Corporation
5206 * All rights reserved.
5207 * MIT License
5208 *
5209 * Permission is hereby granted, free of charge, to any person obtaining a copy
5210 * of this software and associated documentation files (the ""Software""), to deal
5211 * in the Software without restriction, including without limitation the rights
5212 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5213 * copies of the Software, and to permit persons to whom the Software is
5214 * furnished to do so, subject to the following conditions:
5215 *
5216 * The above copyright notice and this permission notice shall be included in
5217 * all copies or substantial portions of the Software.
5218 *
5219 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5220 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5221 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5222 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5223 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5224 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5225 * THE SOFTWARE.
5226 */
5227var powerbi;
5228(function (powerbi) {
5229 var visuals;
5230 (function (visuals) {
5231 var utility;
5232 (function (utility) {
5233 var StyleUtils;
5234 (function (StyleUtils) {
5235 function getRotateAngleFromElement(element) {
5236 var rawElemStyle = element.get(0).style;
5237 var transformString = rawElemStyle.transform || rawElemStyle.webkitTransform;
5238 if (transformString) {
5239 var transform = transformString.match(/rotate\((-?\d+(?:\.\d*)?)deg\)/);
5240 if (transform) {
5241 return parseFloat(transform[1]);
5242 }
5243 }
5244 return 0;
5245 }
5246 StyleUtils.getRotateAngleFromElement = getRotateAngleFromElement;
5247 function getTranslateTransformFromElement(element) {
5248 var rawElemStyle = element.get(0).style;
5249 // IE will recognize "webkitTransform" as "WebkitTransform" and set that as style property.
5250 // This means transform property is not read.
5251 // We put the "transform" before the "webkitTransform" to counteract the weirdness of IE.
5252 var transformString = rawElemStyle.transform || rawElemStyle.webkitTransform;
5253 var retValue = { x: 0, y: 0 };
5254 if (transformString && transformString.length > 0) {
5255 var transform = transformString.match(/translate\((-?\d+(?:\.\d*)?)px, (-?\d+(?:\.\d*)?)px\)/);
5256 if (transform) {
5257 retValue.x = parseFloat(transform[1]);
5258 retValue.y = parseFloat(transform[2]);
5259 }
5260 }
5261 return retValue;
5262 }
5263 StyleUtils.getTranslateTransformFromElement = getTranslateTransformFromElement;
5264 function getPadding(element) {
5265 if (!element)
5266 return;
5267 return {
5268 left: parseFloat(element.css('padding-left')) || 0,
5269 right: parseFloat(element.css('padding-right')) || 0,
5270 top: parseFloat(element.css('padding-top')) || 0,
5271 bottom: parseFloat(element.css('padding-bottom')) || 0,
5272 };
5273 }
5274 StyleUtils.getPadding = getPadding;
5275 })(StyleUtils = utility.StyleUtils || (utility.StyleUtils = {}));
5276 })(utility = visuals.utility || (visuals.utility = {}));
5277 })(visuals = powerbi.visuals || (powerbi.visuals = {}));
5278})(powerbi || (powerbi = {}));
5279/*
5280 * Power BI Visualizations
5281 *
5282 * Copyright (c) Microsoft Corporation
5283 * All rights reserved.
5284 * MIT License
5285 *
5286 * Permission is hereby granted, free of charge, to any person obtaining a copy
5287 * of this software and associated documentation files (the ""Software""), to deal
5288 * in the Software without restriction, including without limitation the rights
5289 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5290 * copies of the Software, and to permit persons to whom the Software is
5291 * furnished to do so, subject to the following conditions:
5292 *
5293 * The above copyright notice and this permission notice shall be included in
5294 * all copies or substantial portions of the Software.
5295 *
5296 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5297 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5298 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5299 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5300 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5301 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5302 * THE SOFTWARE.
5303 */
5304var jsCommon;
5305(function (jsCommon) {
5306 var ConsoleTracer = (function () {
5307 function ConsoleTracer() {
5308 }
5309 ConsoleTracer.prototype.logTrace = function (trace) {
5310 if (DEBUG) {
5311 switch (trace.type) {
5312 case jsCommon.TraceType.Information:
5313 console.info(trace.toString());
5314 break;
5315 case jsCommon.TraceType.UnexpectedError:
5316 case jsCommon.TraceType.Error:
5317 case jsCommon.TraceType.Fatal:
5318 console.error(trace.toString());
5319 break;
5320 case jsCommon.TraceType.ExpectedError:
5321 case jsCommon.TraceType.Warning:
5322 console.warn(trace.toString());
5323 break;
5324 case jsCommon.TraceType.Verbose:
5325 console.log(trace.toString());
5326 break;
5327 default:
5328 console.log(trace.toString());
5329 break;
5330 }
5331 }
5332 };
5333 return ConsoleTracer;
5334 }());
5335 jsCommon.ConsoleTracer = ConsoleTracer;
5336 var Trace;
5337 (function (Trace) {
5338 var traceMaxCount = 1000;
5339 var traces = new Array(traceMaxCount);
5340 var lastTraceIndex = -1;
5341 var defaultListener = new ConsoleTracer();
5342 var listeners = new Array(defaultListener);
5343 /**
5344 * Trace a warning. Please ensure that no PII is being logged.
5345 */
5346 function warning(text, requestId) {
5347 debug.assertValue(text, 'text');
5348 logTraceInternal(new jsCommon.TraceItem(text, jsCommon.TraceType.Warning, requestId));
5349 }
5350 Trace.warning = warning;
5351 /**
5352 * Trace an error. Please ensure that no PII is being logged.
5353 */
5354 function error(text, includeStackTrace, requestId) {
5355 debug.assertValue(text, 'text');
5356 if (includeStackTrace)
5357 text = jsCommon.StringExtensions.format("{0}.\nStack:\n{1}", text, jsCommon.getStackTrace());
5358 logTraceInternal(new jsCommon.TraceItem(text, jsCommon.TraceType.Error, requestId));
5359 }
5360 Trace.error = error;
5361 /**
5362 * Trace an information. Please ensure that no PII is being logged.
5363 */
5364 function verbose(text, requestId) {
5365 debug.assertValue(text, 'text');
5366 logTraceInternal(new jsCommon.TraceItem(text, jsCommon.TraceType.Verbose, requestId));
5367 }
5368 Trace.verbose = verbose;
5369 function addListener(listener) {
5370 debug.assertValue(listener, 'listener');
5371 listeners.push(listener);
5372 }
5373 Trace.addListener = addListener;
5374 function removeListener(listener) {
5375 debug.assertValue(listener, 'listener');
5376 var index = listeners.indexOf(listener);
5377 if (index >= 0)
5378 listeners.splice(index, 1);
5379 }
5380 Trace.removeListener = removeListener;
5381 function resetListeners() {
5382 listeners = new Array(defaultListener);
5383 }
5384 Trace.resetListeners = resetListeners;
5385 function reset() {
5386 lastTraceIndex = -1;
5387 }
5388 Trace.reset = reset;
5389 function getTraces() {
5390 if (lastTraceIndex < 0)
5391 return;
5392 var result = new Array(lastTraceIndex + 1);
5393 for (var i = 0; i <= lastTraceIndex; i++)
5394 result[i] = traces[i];
5395 return result;
5396 }
5397 Trace.getTraces = getTraces;
5398 /**
5399 * Note: Used for unit-test only.
5400 */
5401 function disableDefaultListener() {
5402 removeListener(defaultListener);
5403 }
5404 Trace.disableDefaultListener = disableDefaultListener;
5405 function enableDefaultListener() {
5406 addListener(defaultListener);
5407 }
5408 Trace.enableDefaultListener = enableDefaultListener;
5409 function logTraceInternal(trace) {
5410 if ((lastTraceIndex + 1) >= traceMaxCount)
5411 reset();
5412 traces[++lastTraceIndex] = trace;
5413 for (var i = 0, len = listeners.length; i < len; i++)
5414 listeners[i].logTrace(trace);
5415 }
5416 })(Trace = jsCommon.Trace || (jsCommon.Trace = {}));
5417})(jsCommon || (jsCommon = {}));
5418/*
5419 * Power BI Visualizations
5420 *
5421 * Copyright (c) Microsoft Corporation
5422 * All rights reserved.
5423 * MIT License
5424 *
5425 * Permission is hereby granted, free of charge, to any person obtaining a copy
5426 * of this software and associated documentation files (the ""Software""), to deal
5427 * in the Software without restriction, including without limitation the rights
5428 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5429 * copies of the Software, and to permit persons to whom the Software is
5430 * furnished to do so, subject to the following conditions:
5431 *
5432 * The above copyright notice and this permission notice shall be included in
5433 * all copies or substantial portions of the Software.
5434 *
5435 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5436 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5437 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5438 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5439 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5440 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5441 * THE SOFTWARE.
5442 */
5443var jsCommon;
5444(function (jsCommon) {
5445 /**
5446 * The types of possible traces within the system, this aligns to the traces available in Cloud Platform.
5447 */
5448 (function (TraceType) {
5449 TraceType[TraceType["Information"] = 0] = "Information";
5450 TraceType[TraceType["Verbose"] = 1] = "Verbose";
5451 TraceType[TraceType["Warning"] = 2] = "Warning";
5452 TraceType[TraceType["Error"] = 3] = "Error";
5453 TraceType[TraceType["ExpectedError"] = 4] = "ExpectedError";
5454 TraceType[TraceType["UnexpectedError"] = 5] = "UnexpectedError";
5455 TraceType[TraceType["Fatal"] = 6] = "Fatal";
5456 })(jsCommon.TraceType || (jsCommon.TraceType = {}));
5457 var TraceType = jsCommon.TraceType;
5458})(jsCommon || (jsCommon = {}));
5459/*
5460 * Power BI Visualizations
5461 *
5462 * Copyright (c) Microsoft Corporation
5463 * All rights reserved.
5464 * MIT License
5465 *
5466 * Permission is hereby granted, free of charge, to any person obtaining a copy
5467 * of this software and associated documentation files (the ""Software""), to deal
5468 * in the Software without restriction, including without limitation the rights
5469 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5470 * copies of the Software, and to permit persons to whom the Software is
5471 * furnished to do so, subject to the following conditions:
5472 *
5473 * The above copyright notice and this permission notice shall be included in
5474 * all copies or substantial portions of the Software.
5475 *
5476 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5477 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5478 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5479 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5480 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5481 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5482 * THE SOFTWARE.
5483 */
5484var jsCommon;
5485(function (jsCommon) {
5486 /**
5487 * JavaScript files.
5488 */
5489 var MSMapcontrol = 'https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1&onscriptload=globalMapControlLoaded';
5490 /**
5491 * Map loading logic.
5492 */
5493 var MSMapcontrolLoaded = false;
5494 var WaitForMSMapLoad = null;
5495 var PowerViewPackage = {
5496 javaScriptFiles: [
5497 powerbi.build + '/externals/pv/webclient.js'
5498 ],
5499 cssFiles: [
5500 powerbi.build + '/externals/pv/Styles/_all.css'
5501 ],
5502 javaScriptFilesWithCallback: [
5503 { javascriptFile: MSMapcontrol, onLoadCallback: waitForMapControlLoaded }
5504 ]
5505 };
5506 function ensurePowerView(action) {
5507 if (action === void 0) { action = _.noop; }
5508 jsCommon.requires(PowerViewPackage, action);
5509 }
5510 jsCommon.ensurePowerView = ensurePowerView;
5511 var MapPackage = {
5512 javaScriptFilesWithCallback: [
5513 { javascriptFile: MSMapcontrol, onLoadCallback: waitForMapControlLoaded }
5514 ]
5515 };
5516 function ensureMap(locale, action) {
5517 var mapPackageWithLocale = powerbi.Prototype.inherit(MapPackage);
5518 if (!_.isEmpty(locale)) {
5519 mapPackageWithLocale.javaScriptFilesWithCallback[0].javascriptFile = MSMapcontrol.concat('&mkt=' + locale);
5520 }
5521 jsCommon.requires(mapPackageWithLocale, action);
5522 }
5523 jsCommon.ensureMap = ensureMap;
5524 function mapControlLoaded() {
5525 MSMapcontrolLoaded = true;
5526 if (WaitForMSMapLoad) {
5527 WaitForMSMapLoad.resolve();
5528 WaitForMSMapLoad = undefined;
5529 }
5530 }
5531 jsCommon.mapControlLoaded = mapControlLoaded;
5532 function waitForMapControlLoaded() {
5533 var task;
5534 if (!MSMapcontrolLoaded) {
5535 task = WaitForMSMapLoad = $.Deferred();
5536 }
5537 else {
5538 task = $.Deferred();
5539 task.resolve();
5540 }
5541 return task.promise();
5542 }
5543 jsCommon.waitForMapControlLoaded = waitForMapControlLoaded;
5544})(jsCommon || (jsCommon = {}));
5545/* tslint:disable:no-unused-variable */
5546var globalMapControlLoaded = function () {
5547 // Map requires a function in the global namespace to callback once loaded
5548 jsCommon.mapControlLoaded();
5549};
5550/* tslint:enable:no-unused-variable */
5551/*
5552 * Power BI Visualizations
5553 *
5554 * Copyright (c) Microsoft Corporation
5555 * All rights reserved.
5556 * MIT License
5557 *
5558 * Permission is hereby granted, free of charge, to any person obtaining a copy
5559 * of this software and associated documentation files (the ""Software""), to deal
5560 * in the Software without restriction, including without limitation the rights
5561 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5562 * copies of the Software, and to permit persons to whom the Software is
5563 * furnished to do so, subject to the following conditions:
5564 *
5565 * The above copyright notice and this permission notice shall be included in
5566 * all copies or substantial portions of the Software.
5567 *
5568 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5569 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5570 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5571 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5572 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5573 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5574 * THE SOFTWARE.
5575 */
5576var InJs;
5577(function (InJs) {
5578 /**
5579 * The types of possible traces within the system, this aligns to the traces available in Cloud Platform.
5580 */
5581 (function (TraceType) {
5582 TraceType[TraceType["information"] = 0] = "information";
5583 TraceType[TraceType["verbose"] = 1] = "verbose";
5584 TraceType[TraceType["warning"] = 2] = "warning";
5585 TraceType[TraceType["error"] = 3] = "error";
5586 TraceType[TraceType["expectedError"] = 4] = "expectedError";
5587 TraceType[TraceType["unexpectedError"] = 5] = "unexpectedError";
5588 TraceType[TraceType["fatal"] = 6] = "fatal";
5589 })(InJs.TraceType || (InJs.TraceType = {}));
5590 var TraceType = InJs.TraceType;
5591})(InJs || (InJs = {}));
5592
5593//# sourceMappingURL=VisualsCommon.js.map