UNPKG

83.8 kBTypeScriptView 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
27
28declare module powerbi {
29 enum VisualDataRoleKind {
30 /** Indicates that the role should be bound to something that evaluates to a grouping of values. */
31 Grouping = 0,
32 /** Indicates that the role should be bound to something that evaluates to a single value in a scope. */
33 Measure = 1,
34 /** Indicates that the role can be bound to either Grouping or Measure. */
35 GroupingOrMeasure = 2,
36 }
37 enum VisualDataChangeOperationKind {
38 Create = 0,
39 Append = 1,
40 }
41 enum VisualUpdateType {
42 Data = 2,
43 Resize = 4,
44 ViewMode = 8,
45 Style = 16,
46 ResizeEnd = 32,
47 }
48 enum VisualPermissions {
49 }
50 const enum CartesianRoleKind {
51 X = 0,
52 Y = 1,
53 }
54 const enum ViewMode {
55 View = 0,
56 Edit = 1,
57 }
58 const enum ResizeMode {
59 Resizing = 1,
60 Resized = 2,
61 }
62 module visuals.telemetry {
63 const enum TelemetryCategory {
64 Verbose = 0,
65 CustomerAction = 1,
66 CriticalError = 2,
67 Trace = 3,
68 }
69 enum ErrorSource {
70 PowerBI = 0,
71 External = 1,
72 User = 2,
73 }
74 }
75 const enum JoinPredicateBehavior {
76 /** Prevent items in this role from acting as join predicates. */
77 None = 0,
78 }
79}
80
81
82declare module powerbi {
83 export interface DragPayload {
84 }
85}
86
87
88declare module jsCommon {
89 export interface IStringResourceProvider {
90 get(id: string): string;
91 getOptional(id: string): string;
92 }
93}
94
95
96declare module powerbi.visuals {
97 export interface IPoint {
98 x: number;
99 y: number;
100 }
101}
102
103
104declare module powerbi {
105 /**
106 * An interface to promise/deferred,
107 * which abstracts away the underlying mechanism (e.g., Angular, jQuery, etc.).
108 */
109 export interface IPromiseFactory {
110 /**
111 * Creates a Deferred object which represents a task which will finish in the future.
112 */
113 defer<T>(): IDeferred<T>;
114
115 /**
116 * Creates a Deferred object which represents a task which will finish in the future.
117 */
118 defer<TSuccess, TError>(): IDeferred2<TSuccess, TError>;
119
120 /**
121 * Creates a promise that is resolved as rejected with the specified reason.
122 * This api should be used to forward rejection in a chain of promises.
123 * If you are dealing with the last promise in a promise chain, you don't need to worry about it.
124 * When comparing deferreds/promises to the familiar behavior of try/catch/throw,
125 * think of reject as the throw keyword in JavaScript.
126 * This also means that if you "catch" an error via a promise error callback and you want
127 * to forward the error to the promise derived from the current promise,
128 * you have to "rethrow" the error by returning a rejection constructed via reject.
129 *
130 * @param reason Constant, message, exception or an object representing the rejection reason.
131 */
132 reject<TError>(reason?: TError): IPromise2<any, TError>;
133
134 /**
135 * Creates a promise that is resolved with the specified value.
136 * This api should be used to forward rejection in a chain of promises.
137 * If you are dealing with the last promise in a promise chain, you don't need to worry about it.
138 *
139 * @param value Object representing the promise result.
140 */
141 resolve<TSuccess>(value?: TSuccess): IPromise2<TSuccess, any>;
142
143 /**
144 * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
145 */
146 all(promises: IPromise2<any, any>[]): IPromise<any[]>;
147
148 /**
149 * Wraps an object that might be a value or a then-able promise into a promise.
150 * This is useful when you are dealing with an object that might or might not be a promise
151 */
152 when<T>(value: T | IPromise<T>): IPromise<T>;
153 }
154
155 /**
156 * Represents an operation, to be completed (resolve/rejected) in the future.
157 */
158 export interface IPromise<T> extends IPromise2<T, T> {
159 }
160
161 /**
162 * Represents an operation, to be completed (resolve/rejected) in the future.
163 * Success and failure types can be set independently.
164 */
165 export interface IPromise2<TSuccess, TError> {
166 /**
167 * Regardless of when the promise was or will be resolved or rejected,
168 * then calls one of the success or error callbacks asynchronously as soon as the result is available.
169 * The callbacks are called with a single argument: the result or rejection reason.
170 * Additionally, the notify callback may be called zero or more times to provide a progress indication,
171 * before the promise is resolved or rejected.
172 * This method returns a new promise which is resolved or rejected via
173 * the return value of the successCallback, errorCallback.
174 */
175 then<TSuccessResult, TErrorResult>(successCallback: (promiseValue: TSuccess) => IPromise2<TSuccessResult, TErrorResult>, errorCallback?: (reason: TError) => TErrorResult): IPromise2<TSuccessResult, TErrorResult>;
176
177 /**
178 * Regardless of when the promise was or will be resolved or rejected,
179 * then calls one of the success or error callbacks asynchronously as soon as the result is available.
180 * The callbacks are called with a single argument: the result or rejection reason.
181 * Additionally, the notify callback may be called zero or more times to provide a progress indication,
182 * before the promise is resolved or rejected.
183 * This method returns a new promise which is resolved or rejected via
184 * the return value of the successCallback, errorCallback.
185 */
186 then<TSuccessResult, TErrorResult>(successCallback: (promiseValue: TSuccess) => TSuccessResult, errorCallback?: (reason: TError) => TErrorResult): IPromise2<TSuccessResult, TErrorResult>;
187
188 /**
189 * Shorthand for promise.then(null, errorCallback).
190 */
191 catch<TErrorResult>(onRejected: (reason: any) => IPromise2<TSuccess, TErrorResult>): IPromise2<TSuccess, TErrorResult>;
192
193 /**
194 * Shorthand for promise.then(null, errorCallback).
195 */
196 catch<TErrorResult>(onRejected: (reason: any) => TErrorResult): IPromise2<TSuccess, TErrorResult>;
197
198 /**
199 * Allows you to observe either the fulfillment or rejection of a promise,
200 * but to do so without modifying the final value.
201 * This is useful to release resources or do some clean-up that needs to be done
202 * whether the promise was rejected or resolved.
203 * See the full specification for more information.
204 * Because finally is a reserved word in JavaScript and reserved keywords
205 * are not supported as property names by ES3, you'll need to invoke
206 * the method like promise['finally'](callback) to make your code IE8 and Android 2.x compatible.
207 */
208 finally<T, U>(finallyCallback: () => any): IPromise2<T, U>;
209 }
210
211 export interface IDeferred<T> extends IDeferred2<T, T> {
212 }
213
214 export interface IDeferred2<TSuccess, TError> {
215 resolve(value: TSuccess): void;
216 reject(reason?: TError): void;
217 promise: IPromise2<TSuccess, TError>;
218 }
219
220 export interface RejectablePromise2<T, E> extends IPromise2<T, E> {
221 reject(reason?: E): void;
222 resolved(): boolean;
223 rejected(): boolean;
224 pending(): boolean;
225 }
226
227 export interface RejectablePromise<T> extends RejectablePromise2<T, T> {
228 }
229
230 export interface IResultCallback<T> {
231 (result: T, done: boolean): void;
232 }
233}
234
235
236declare module powerbi.visuals {
237 export interface IRect {
238 left: number;
239 top: number;
240 width: number;
241 height: number;
242 }
243}
244
245
246declare module powerbi.visuals {
247 import Selector = data.Selector;
248
249 export interface ISelectionIdBuilder {
250 withCategory(categoryColumn: DataViewCategoryColumn, index: number): this;
251 withSeries(seriesColumn: DataViewValueColumns, valueColumn: DataViewValueColumn | DataViewValueColumnGroup): this;
252 withMeasure(measureId: string): this;
253 createSelectionId(): ISelectionId;
254 }
255
256 export interface ISelectionId {
257 equals(other: ISelectionId): boolean;
258 includes(other: ISelectionId, ignoreHighlight?: boolean): boolean;
259 getKey(): string;
260 getSelector(): Selector;
261 getSelectorsByColumn(): Selector;
262 hasIdentity(): boolean;
263 }
264}
265
266
267declare module powerbi.data {
268 export interface CompiledDataViewMapping {
269 metadata: CompiledDataViewMappingMetadata;
270 categorical?: CompiledDataViewCategoricalMapping;
271 table?: CompiledDataViewTableMapping;
272 single?: CompiledDataViewSingleMapping;
273 tree?: CompiledDataViewTreeMapping;
274 matrix?: CompiledDataViewMatrixMapping;
275 scriptResult?: CompiledDataViewScriptResultMapping;
276 usage?: DataViewMappingUsage;
277 }
278
279 export interface CompiledDataViewMappingScriptDefinition {
280 source: DataViewObjectPropertyIdentifier;
281 provider: DataViewObjectPropertyIdentifier;
282 imageFormat?: string;
283 scriptInput?: ScriptInput;
284 }
285
286 export interface CompiledDataViewScriptResultMapping {
287 dataInput: CompiledDataViewMapping;
288 script: CompiledDataViewMappingScriptDefinition;
289 }
290
291 export interface CompiledDataViewMappingMetadata {
292 /** The metadata repetition objects. */
293 objects?: DataViewObjects;
294 }
295
296 export interface CompiledDataViewCategoricalMapping extends HasDataVolume, HasReductionAlgorithm {
297 categories?: CompiledDataViewRoleMappingWithReduction | CompiledDataViewListRoleMappingWithReduction;
298 values?: CompiledDataViewRoleMapping | CompiledDataViewGroupedRoleMapping | CompiledDataViewListRoleMapping;
299 includeEmptyGroups?: boolean;
300 }
301
302 export interface CompiledDataViewGroupingRoleMapping {
303 role: CompiledDataViewRole;
304 }
305
306 export interface CompiledDataViewSingleMapping {
307 role: CompiledDataViewRole;
308 }
309
310 export interface CompiledDataViewTableMapping extends HasDataVolume {
311 rows: CompiledDataViewRoleMappingWithReduction | CompiledDataViewListRoleMappingWithReduction;
312 }
313
314 export interface CompiledDataViewTreeMapping extends HasDataVolume {
315 nodes?: CompiledDataViewRoleForMappingWithReduction;
316 values?: CompiledDataViewRoleForMapping;
317 }
318
319 export interface CompiledDataViewMatrixMapping extends HasDataVolume {
320 rows?: CompiledDataViewRoleForMappingWithReduction | CompiledDataViewListRoleMappingWithReduction;
321 columns?: CompiledDataViewRoleForMappingWithReduction;
322 values?: CompiledDataViewRoleForMapping | CompiledDataViewListRoleMapping;
323 }
324
325 export type CompiledDataViewRoleMapping = CompiledDataViewRoleBindMapping | CompiledDataViewRoleForMapping;
326
327 export interface CompiledDataViewRoleBindMapping {
328 bind: {
329 to: CompiledDataViewRole;
330 };
331 }
332
333 export interface CompiledDataViewRoleForMapping {
334 for: {
335 in: CompiledDataViewRole;
336 };
337 }
338
339 export type CompiledDataViewRoleMappingWithReduction = CompiledDataViewRoleBindMappingWithReduction | CompiledDataViewRoleForMappingWithReduction;
340
341 export interface CompiledDataViewRoleBindMappingWithReduction extends CompiledDataViewRoleBindMapping, HasReductionAlgorithm {
342 }
343
344 export interface CompiledDataViewRoleForMappingWithReduction extends CompiledDataViewRoleForMapping, HasReductionAlgorithm {
345 }
346
347 export interface CompiledDataViewGroupedRoleMapping {
348 group: CompiledDataViewGroupedRoleGroupItemMapping;
349 }
350
351 export interface CompiledDataViewGroupedRoleGroupItemMapping extends HasReductionAlgorithm {
352 by: CompiledDataViewRole;
353 select: CompiledDataViewRoleMapping[];
354 }
355
356 export interface CompiledDataViewListRoleMapping {
357 select: CompiledDataViewRoleMapping[];
358 }
359
360 export interface CompiledDataViewListRoleMappingWithReduction extends CompiledDataViewListRoleMapping, HasReductionAlgorithm {
361 }
362
363 export const enum CompiledSubtotalType {
364 None = 0,
365 Before = 1,
366 After = 2
367 }
368
369 export interface CompiledDataViewRole {
370 role: string;
371 items: CompiledDataViewRoleItem[];
372 subtotalType?: CompiledSubtotalType;
373 showAll?: boolean;
374 activeItems?: string[];
375 }
376
377 export interface CompiledDataViewRoleItem {
378 queryName: string;
379 //changed to descriptor to not need to depend on ValueType class
380 type?: ValueTypeDescriptor;
381 joinPredicate?: JoinPredicateBehavior;
382 }
383}
384
385
386declare module powerbi {
387 /** Represents views of a data set. */
388 export interface DataView {
389 metadata: DataViewMetadata;
390 categorical?: DataViewCategorical;
391 single?: DataViewSingle;
392 tree?: DataViewTree;
393 table?: DataViewTable;
394 matrix?: DataViewMatrix;
395 scriptResult?: DataViewScriptResultData;
396 }
397
398 export interface DataViewMetadata {
399 columns: DataViewMetadataColumn[];
400
401 /** The metadata repetition objects. */
402 objects?: DataViewObjects;
403
404 /** When defined, describes whether the DataView contains just a segment of the complete data set. */
405 segment?: DataViewSegmentMetadata;
406 }
407
408 export interface DataViewMetadataColumn {
409 /** The user-facing display name of the column. */
410 displayName: string;
411
412 /** The query name the source column in the query. */
413 queryName?: string;
414
415 /** The format string of the column. */
416 format?: string; // TODO: Deprecate this, and populate format string through objects instead.
417
418 /** Data type information for the column. */
419 type?: ValueTypeDescriptor;
420
421 /** Indicates that this column is a measure (aggregate) value. */
422 isMeasure?: boolean;
423
424 /** The position of the column in the select statement. */
425 index?: number;
426
427 /** The properties that this column provides to the visualization. */
428 roles?: { [name: string]: boolean };
429
430 /** The metadata repetition objects. */
431 objects?: DataViewObjects;
432
433 /** The name of the containing group. */
434 groupName?: string;
435
436 /** The sort direction of this column. */
437 sort?: SortDirection;
438
439 /** The KPI metadata to use to convert a numeric status value into its visual representation. */
440 kpi?: DataViewKpiColumnMetadata;
441
442 /** Indicates that aggregates should not be computed across groups with different values of this column. */
443 discourageAggregationAcrossGroups?: boolean;
444
445 /** The aggregates computed for this column, if any. */
446 aggregates?: DataViewColumnAggregates;
447 }
448
449 export interface DataViewSegmentMetadata {
450 }
451
452 export interface DataViewColumnAggregates {
453 subtotal?: PrimitiveValue;
454 max?: PrimitiveValue;
455 min?: PrimitiveValue;
456 count?: number;
457
458 /** Client-computed maximum value for a column. */
459 maxLocal?: PrimitiveValue;
460
461 /** Client-computed maximum value for a column. */
462 minLocal?: PrimitiveValue;
463 }
464
465 export interface DataViewCategorical {
466 categories?: DataViewCategoryColumn[];
467 values?: DataViewValueColumns;
468 }
469
470 export interface DataViewCategoricalColumn {
471 source: DataViewMetadataColumn;
472 values: any[];
473
474 /** The data repetition objects. */
475 objects?: DataViewObjects[];
476 }
477
478 export interface DataViewValueColumns extends Array<DataViewValueColumn> {
479 /** Returns an array that groups the columns in this group together. */
480 grouped(): DataViewValueColumnGroup[];
481
482 /** The set of expressions that define the identity for instances of the value group. This must match items in the DataViewScopeIdentity in the grouped items result. */
483 identityFields?: data.ISQExpr[];
484
485 source?: DataViewMetadataColumn;
486 }
487
488 export interface DataViewValueColumnGroup {
489 values: DataViewValueColumn[];
490 identity?: DataViewScopeIdentity;
491
492 /** The data repetition objects. */
493 objects?: DataViewObjects;
494
495 name?: string;
496 }
497
498 export interface DataViewValueColumn extends DataViewCategoricalColumn {
499 highlights?: any[];
500 identity?: DataViewScopeIdentity;
501 }
502
503 // NOTE: The following is needed for backwards compatibility and should be deprecated. Callers should use
504 // DataViewMetadataColumn.aggregates instead.
505 export interface DataViewValueColumn extends DataViewColumnAggregates {
506 }
507
508 export interface DataViewCategoryColumn extends DataViewCategoricalColumn {
509 identity?: DataViewScopeIdentity[];
510
511 /** The set of expressions that define the identity for instances of the category. This must match items in the DataViewScopeIdentity in the identity. */
512 identityFields?: data.ISQExpr[];
513 }
514
515 export interface DataViewSingle {
516 value: any;
517 }
518
519 export interface DataViewTree {
520 root: DataViewTreeNode;
521 }
522
523 export interface DataViewTreeNode {
524 name?: string;
525
526 /**
527 * When used under the context of DataView.tree, this value is one of the elements in the values property.
528 *
529 * When used under the context of DataView.matrix, this property is the value of the particular
530 * group instance represented by this node (e.g. In a grouping on Year, a node can have value == 2016).
531 *
532 * DEPRECATED for usage under the context of DataView.matrix: This property is deprecated for objects
533 * that conform to the DataViewMatrixNode interface (which extends DataViewTreeNode).
534 * New visuals code should consume the new property levelValues on DataViewMatrixNode instead.
535 * If this node represents a composite group node in matrix, this property will be undefined.
536 */
537 value?: any;
538
539 /**
540 * When used under the context of DataView.tree, this property contains all the values in this node.
541 * The key of each of the key-value-pair in this dictionary is the position of the column in the
542 * select statement to which the value belongs.
543 *
544 * When used under the context of DataView.matrix.rows (as DataViewMatrixNode), if this node represents the
545 * inner-most dimension of row groups (i.e. a leaf node), then this property will contain the values at the
546 * matrix intersection under the group. The value type will be DataViewMatrixNodeValue, and their
547 * valueSourceIndex property will contain the position of the column in the select statement to which the
548 * value belongs.
549 *
550 * When used under the context of DataView.matrix.columns (as DataViewMatrixNode), this property is not used.
551 */
552 values?: { [id: number]: DataViewTreeNodeValue };
553
554 children?: DataViewTreeNode[];
555 identity?: DataViewScopeIdentity;
556
557 /** The data repetition objects. */
558 objects?: DataViewObjects;
559
560 /** The set of expressions that define the identity for the child nodes. This must match items in the DataViewScopeIdentity of those nodes. */
561 childIdentityFields?: data.ISQExpr[];
562 }
563
564 export interface DataViewTreeNodeValue {
565 value?: any;
566 }
567
568 export interface DataViewTreeNodeMeasureValue extends DataViewTreeNodeValue, DataViewColumnAggregates {
569 highlight?: any;
570 }
571
572 export interface DataViewTreeNodeGroupValue extends DataViewTreeNodeValue {
573 count?: any;
574 }
575
576 export interface DataViewTable {
577 columns: DataViewMetadataColumn[];
578
579 identity?: DataViewScopeIdentity[];
580
581 /** The set of expressions that define the identity for rows of the table. This must match items in the DataViewScopeIdentity in the identity. */
582 identityFields?: data.ISQExpr[];
583
584 rows?: DataViewTableRow[];
585
586 totals?: any[];
587 }
588
589 export interface DataViewTableRow extends Array<any> {
590 /** The metadata repetition objects. */
591 objects?: DataViewObjects[];
592 }
593
594 export interface DataViewMatrix {
595 rows: DataViewHierarchy;
596 columns: DataViewHierarchy;
597 valueSources: DataViewMetadataColumn[];
598 }
599
600 export interface DataViewMatrixNode extends DataViewTreeNode {
601 /** Indicates the level this node is on. Zero indicates the outermost children (root node level is undefined). */
602 level?: number;
603
604 /**
605 * Indicates the source metadata index on the node's level. Its value is 0 if omitted.
606 *
607 * DEPRECATED: This property is deprecated and exists for backward-compatibility only.
608 * New visuals code should consume the new property levelSourceIndex on DataViewMatrixGroupValue instead.
609 */
610 levelSourceIndex?: number;
611
612 /**
613 * The values of the particular group instance represented by this node.
614 * This array property would contain more than one element in a composite group
615 * (e.g. Year == 2016 and Month == 'January').
616 */
617 levelValues?: DataViewMatrixGroupValue[];
618
619 /** Indicates whether or not the node is a subtotal node. Its value is false if omitted. */
620 isSubtotal?: boolean;
621 }
622
623 /**
624 * Represents a value at a particular level of a matrix's rows or columns hierarchy.
625 * In the hierarchy level node is an instance of a composite group, this object will
626 * be one of multiple values
627 */
628 export interface DataViewMatrixGroupValue extends DataViewTreeNodeValue {
629 /**
630 * Indicates the index of the corresponding column for this group level value
631 * (held by DataViewHierarchyLevel.sources).
632 *
633 * @example
634 * // For example, to get the source column metadata of each level value at a particular row hierarchy node:
635 * let matrixRowsHierarchy: DataViewHierarchy = dataView.matrix.rows;
636 * let targetRowsHierarchyNode = <DataViewMatrixNode>matrixRowsHierarchy.root.children[0];
637 * // Use the DataViewMatrixNode.level property to get the corresponding DataViewHierarchyLevel...
638 * let targetRowsHierarchyLevel: DataViewHierarchyLevel = matrixRows.levels[targetRowsHierarchyNode.level];
639 * for (let levelValue in rowsRootNode.levelValues) {
640 * // columnMetadata is the source column for the particular levelValue.value in this loop iteration
641 * let columnMetadata: DataViewMetadataColumn =
642 * targetRowsHierarchyLevel.sources[levelValue.levelSourceIndex];
643 * }
644 */
645 levelSourceIndex: number;
646 }
647
648 /** Represents a value at the matrix intersection, used in the values property on DataViewMatrixNode (inherited from DataViewTreeNode). */
649 export interface DataViewMatrixNodeValue extends DataViewTreeNodeValue {
650 highlight?: any;
651
652 /** Indicates the index of the corresponding measure (held by DataViewMatrix.valueSources). Its value is 0 if omitted. */
653 valueSourceIndex?: number;
654 }
655
656 export interface DataViewHierarchy {
657 root: DataViewMatrixNode;
658 levels: DataViewHierarchyLevel[];
659 }
660
661 export interface DataViewHierarchyLevel {
662 sources: DataViewMetadataColumn[];
663 }
664
665 export interface DataViewKpiColumnMetadata {
666 graphic: string;
667
668 // When false, five state KPIs are in: { -2, -1, 0, 1, 2 }.
669 // When true, five state KPIs are in: { -1, -0.5, 0, 0.5, 1 }.
670 normalizedFiveStateKpiRange?: boolean;
671 }
672
673 export interface DataViewScriptResultData {
674 imageBase64: string;
675 }
676}
677
678
679declare module powerbi {
680 export interface DataViewMapping {
681 /**
682 * Defines set of conditions, at least one of which must be satisfied for this mapping to be used.
683 * Any roles not specified in the condition accept any number of items.
684 */
685 conditions?: DataViewMappingCondition[];
686 requiredProperties?: DataViewObjectPropertyIdentifier[];
687
688 categorical?: DataViewCategoricalMapping;
689 table?: DataViewTableMapping;
690 single?: DataViewSingleMapping;
691 tree?: DataViewTreeMapping;
692 matrix?: DataViewMatrixMapping;
693 scriptResult?: DataViewScriptResultMapping;
694 usage?: DataViewMappingUsage;
695 }
696
697 /** Describes whether a particular mapping is fits the set of projections. */
698 export interface DataViewMappingCondition {
699 [dataRole: string]: RoleCondition;
700 }
701
702 /** Describes a mapping which supports a data volume level. */
703 export interface HasDataVolume {
704 dataVolume?: number;
705 }
706
707 export interface DataViewCategoricalMapping extends HasDataVolume, HasReductionAlgorithm {
708 categories?: DataViewRoleMappingWithReduction | DataViewListRoleMappingWithReduction;
709 values?: DataViewRoleMapping | DataViewGroupedRoleMapping | DataViewListRoleMapping;
710
711 /** Specifies a constraint on the number of data rows supported by the visual. */
712 rowCount?: AcceptabilityNumberRange;
713
714 /** Indicates whether the data rows include empty groups */
715 includeEmptyGroups?: boolean;
716 }
717
718 export interface DataViewSingleMapping {
719 /** Indicates the role which is bound to this structure. */
720 role: string;
721 }
722
723 export interface DataViewTableMapping extends HasDataVolume {
724 rows: DataViewRoleMappingWithReduction | DataViewListRoleMappingWithReduction;
725
726 /** Specifies a constraint on the number of data rows supported by the visual. */
727 rowCount?: AcceptabilityNumberRange;
728 }
729
730 export interface DataViewTreeMapping extends HasDataVolume {
731 nodes?: DataViewRoleForMappingWithReduction;
732 values?: DataViewRoleForMapping;
733
734 /** Specifies a constraint on the depth of the tree supported by the visual. */
735 depth?: AcceptabilityNumberRange;
736 }
737
738 export interface DataViewMatrixMapping extends HasDataVolume {
739 rows?: DataViewRoleForMappingWithReduction | DataViewListRoleMappingWithReduction;
740 columns?: DataViewRoleForMappingWithReduction;
741 values?: DataViewRoleForMapping | DataViewListRoleMapping;
742 }
743
744 /* tslint:disable:no-unused-expression */
745 export type DataViewRoleMapping = DataViewRoleBindMapping | DataViewRoleForMapping;
746
747 /* tslint: enable */
748
749 export interface DataViewRoleBindMapping {
750 /**
751 * Indicates evaluation of a single-valued data role.
752 * Equivalent to for, without support for multiple items.
753 */
754 bind: {
755 to: string;
756 };
757 }
758
759 export interface DataViewRoleForMapping {
760 /** Indicates iteration of the in data role, as an array. */
761 for: {
762 in: string;
763 };
764 }
765
766 export type DataViewRoleMappingWithReduction = DataViewRoleBindMappingWithReduction | DataViewRoleForMappingWithReduction;
767
768 export interface DataViewRoleBindMappingWithReduction extends DataViewRoleBindMapping, HasReductionAlgorithm {
769 }
770
771 export interface DataViewRoleForMappingWithReduction extends DataViewRoleForMapping, HasReductionAlgorithm {
772 }
773
774 export interface DataViewGroupedRoleMapping {
775 group: {
776 by: string;
777 select: DataViewRoleMapping[];
778 dataReductionAlgorithm?: ReductionAlgorithm;
779 };
780 }
781
782 export interface DataViewListRoleMapping {
783 select: DataViewRoleMapping[];
784 }
785
786 export interface DataViewListRoleMappingWithReduction extends DataViewListRoleMapping, HasReductionAlgorithm {
787 }
788
789 export interface HasReductionAlgorithm {
790 dataReductionAlgorithm?: ReductionAlgorithm;
791 }
792
793 /** Describes how to reduce the amount of data exposed to the visual. */
794 export interface ReductionAlgorithm {
795 top?: DataReductionTop;
796 bottom?: DataReductionBottom;
797 sample?: DataReductionSample;
798 window?: DataReductionWindow;
799 }
800
801 /** Reduce the data to the Top(count) items. */
802 export interface DataReductionTop {
803 count?: number;
804 }
805
806 /** Reduce the data to the Bottom count items. */
807 export interface DataReductionBottom {
808 count?: number;
809 }
810
811 /** Reduce the data using a simple Sample of count items. */
812 export interface DataReductionSample {
813 count?: number;
814 }
815
816 /** Allow the data to be loaded one window, containing count items, at a time. */
817 export interface DataReductionWindow {
818 count?: number;
819 }
820
821 export interface AcceptabilityNumberRange {
822 /** Specifies a preferred range of values for the constraint. */
823 preferred?: NumberRange;
824
825 /** Specifies a supported range of values for the constraint. Defaults to preferred if not specified. */
826 supported?: NumberRange;
827 }
828
829 /** Defines the acceptable values of a number. */
830 export interface NumberRange {
831 min?: number;
832 max?: number;
833 }
834
835 export interface DataViewMappingScriptDefinition {
836 source: DataViewObjectPropertyIdentifier;
837 provider: DataViewObjectPropertyIdentifier;
838 imageFormat?: string;
839 }
840
841 export interface DataViewScriptResultMapping {
842 dataInput: DataViewMapping;
843 script: DataViewMappingScriptDefinition;
844 }
845
846 /** Defines how the mapping will be used. The set of objects in this interface can modify the usage. */
847 export interface DataViewMappingUsage {
848 regression: {
849 [propertyName: string]: DataViewObjectPropertyIdentifier;
850 };
851 }
852}
853
854
855declare module powerbi {
856 /** Represents evaluated, named, custom objects in a DataView. */
857 export interface DataViewObjects {
858 [name: string]: DataViewObject | DataViewObjectMap;
859 }
860
861 /** Represents an object (name-value pairs) in a DataView. */
862 export interface DataViewObject {
863 [propertyName: string]: DataViewPropertyValue;
864 }
865
866 export interface DataViewObjectWithId {
867 id: string;
868 object: DataViewObject;
869 }
870
871 export interface DataViewObjectPropertyIdentifier {
872 objectName: string;
873 propertyName: string;
874 }
875
876 export type DataViewObjectMap = DataViewObjectWithId[];
877
878 export type DataViewPropertyValue = PrimitiveValue | StructuralObjectValue;
879}
880
881
882declare module powerbi.data {
883 export interface DataViewObjectDescriptors {
884 /** Defines general properties for a visualization. */
885 general?: DataViewObjectDescriptor;
886
887 [objectName: string]: DataViewObjectDescriptor;
888 }
889
890 /** Defines a logical object in a visualization. */
891 export interface DataViewObjectDescriptor {
892 displayName?: DisplayNameGetter;
893 description?: DisplayNameGetter;
894 properties: DataViewObjectPropertyDescriptors;
895 }
896
897 export interface DataViewObjectPropertyDescriptors {
898 [propertyName: string]: DataViewObjectPropertyDescriptor;
899 }
900
901 /** Defines a property of a DataViewObjectDefinition. */
902 export interface DataViewObjectPropertyDescriptor {
903 displayName?: DisplayNameGetter;
904 description?: DisplayNameGetter;
905 placeHolderText?: DisplayNameGetter;
906 type: DataViewObjectPropertyTypeDescriptor;
907 rule?: DataViewObjectPropertyRuleDescriptor;
908
909 /** Indicates whether the Format Painter should ignore this property. */
910 suppressFormatPainterCopy?: boolean;
911 }
912
913 export type DataViewObjectPropertyTypeDescriptor = ValueTypeDescriptor | StructuralTypeDescriptor;
914
915 export interface DataViewObjectPropertyRuleDescriptor {
916 /** For rule typed properties, defines the input visual role name. */
917 inputRole?: string;
918
919 /** Defines the output for rule-typed properties. */
920 output?: DataViewObjectPropertyRuleOutputDescriptor;
921 }
922
923 export interface DataViewObjectPropertyRuleOutputDescriptor {
924 /** Name of the target property for rule output. */
925 property: string;
926
927 /** Names roles that define the selector for the output properties. */
928 selector: string[];
929 }
930
931}
932
933
934declare module powerbi.data {
935 /** Defines a match against all instances of given roles. */
936 export interface DataViewRoleWildcard {
937 roles: string[];
938 key: string;
939 }
940}
941
942
943declare module powerbi {
944 /** Encapsulates the identity of a data scope in a DataView. */
945 export interface DataViewScopeIdentity {
946 /** Predicate expression that identifies the scope. */
947 expr: data.ISQExpr;
948
949 /** Key string that identifies the DataViewScopeIdentity to a string, which can be used for equality comparison. */
950 key: string;
951 }
952}
953
954
955declare module powerbi.data {
956 /** Defines a match against all instances of a given DataView scope. */
957 export interface DataViewScopeWildcard {
958 exprs: ISQExpr[];
959 key: string;
960 }
961}
962
963
964declare module powerbi.data {
965 import IStringResourceProvider = jsCommon.IStringResourceProvider;
966
967 export type DisplayNameGetter = ((resourceProvider: IStringResourceProvider) => string) | string;
968}
969
970
971declare module powerbi.data {
972 export interface ScriptInputColumn {
973 /** The queryName of the corresponding Select from the associated SemanticQuery providing the data for this column. */
974 QueryName: string;
975
976 /** The name of this column expected by the script. */
977 Name: string;
978 }
979
980 export interface ScriptInput {
981 VariableName?: string;
982 Columns?: ScriptInputColumn[];
983 }
984}
985
986
987declare module powerbi.data {
988 /** Defines a selector for content, including data-, metadata, and user-defined repetition. */
989 export interface Selector {
990 /** Data-bound repetition selection. */
991 data?: DataRepetitionSelector[];
992
993 /** Metadata-bound repetition selection. Refers to a DataViewMetadataColumn queryName. */
994 metadata?: string;
995
996 /** User-defined repetition selection. */
997 id?: string;
998 }
999
1000 export type DataRepetitionSelector = DataViewScopeIdentity | DataViewScopeWildcard | DataViewRoleWildcard;
1001}
1002
1003
1004declare module powerbi.data {
1005 //intentionally blank interfaces since this is not part of the public API
1006
1007 export interface ISemanticFilter { }
1008
1009 export interface ISQExpr { }
1010
1011 export interface ISQConstantExpr extends ISQExpr { }
1012
1013}
1014
1015
1016declare module powerbi {
1017 export const enum SortDirection {
1018 Ascending = 1,
1019 Descending = 2,
1020 }
1021}
1022
1023
1024declare module powerbi {
1025 export interface IViewport {
1026 height: number;
1027 width: number;
1028 }
1029}
1030
1031
1032declare module powerbi {
1033 import DisplayNameGetter = powerbi.data.DisplayNameGetter;
1034
1035 /** Defines the data roles understood by the IVisual. */
1036 export interface VisualDataRole {
1037 /** Unique name for the VisualDataRole. */
1038 name: string;
1039
1040 /** Indicates the kind of role. This value is used to build user interfaces, such as a field well. */
1041 kind: VisualDataRoleKind;
1042
1043 displayName?: DisplayNameGetter;
1044
1045 /** The tooltip text */
1046 description?: DisplayNameGetter;
1047
1048 /** Indicates the preferred ValueTypes to be used in this data role. This is used by authoring tools when adding fields into the visual. */
1049 preferredTypes?: ValueTypeDescriptor[];
1050
1051 /** Indicates the required ValueTypes for this data role. Any values which do not match one of the ValueTypes specified will be null'd out */
1052 requiredTypes?: ValueTypeDescriptor[];
1053
1054 /** Indicates the cartesian role for the visual role */
1055 cartesianKind?: CartesianRoleKind;
1056
1057 /** Indicates the join predicate behavior of items in this role. */
1058 joinPredicate?: JoinPredicateBehavior;
1059 }
1060
1061 export interface RoleCondition extends NumberRange {
1062 kind?: VisualDataRoleKind;
1063 }
1064}
1065
1066
1067declare module powerbi.extensibility {
1068 export interface ISelectionId { }
1069
1070 export interface ISelectionIdBuilder {
1071 withCategory(categoryColumn: DataViewCategoryColumn, index: number): this;
1072 withSeries(seriesColumn: DataViewValueColumns, valueColumn: DataViewValueColumn | DataViewValueColumnGroup): this;
1073 withMeasure(measureId: string): this;
1074 createSelectionId(): ISelectionId;
1075 }
1076}
1077
1078
1079declare module powerbi.extensibility {
1080 interface ISelectionManager {
1081 select(selectionId: ISelectionId, multiSelect?: boolean): IPromise<ISelectionId[]>;
1082 hasSelection(): boolean;
1083 clear(): IPromise<{}>;
1084 getSelectionIds(): ISelectionId[];
1085 }
1086}
1087
1088
1089declare module powerbi.extensibility {
1090
1091 export interface IVisualPluginOptions {
1092 capabilities: VisualCapabilities;
1093 }
1094
1095 export interface IVisualConstructor {
1096 __capabilities__: VisualCapabilities;
1097 }
1098
1099 // These are the base interfaces. These should remain empty
1100 // All visual versions should extend these for type compatability
1101
1102 export interface IVisual { }
1103
1104 export interface IVisualHost { }
1105
1106 export interface VisualUpdateOptions { }
1107
1108 export interface VisualConstructorOptions { }
1109
1110}
1111
1112
1113
1114declare module powerbi.extensibility {
1115
1116 export interface VisualVersionOverloads {
1117 [name: string]: Function;
1118 }
1119
1120 export interface VisualVersionOverloadFactory {
1121 (visual: powerbi.extensibility.IVisual): VisualVersionOverloads;
1122 }
1123
1124 export interface VisualHostAdapter {
1125 (host: powerbi.IVisualHostServices): IVisualHost;
1126 }
1127
1128 export interface VisualVersion {
1129 version: string;
1130 overloads?: VisualVersionOverloadFactory;
1131 hostAdapter: VisualHostAdapter;
1132 }
1133
1134 /**
1135 * Extends the interface of a visual wrapper (IVisual) to include
1136 * the unwrap method which returns a direct reference to the wrapped visual.
1137 * Used in SafeExecutionWrapper and VisualAdapter
1138 */
1139 export interface WrappedVisual {
1140 /** Returns this visual inside of this wrapper */
1141 unwrap: () => powerbi.IVisual;
1142 }
1143}
1144
1145
1146/**
1147 * Change Log Version 1.0.0
1148 * - Add type to update options (data, resize, viewmode)
1149 * - Remove deprecated methods (onDataChange, onResizing, onViewModeChange)
1150 * - Add hostAdapter for host services versioning
1151 */
1152declare module powerbi.extensibility.v100 {
1153 /**
1154 * Represents a visualization displayed within an application (PowerBI dashboards, ad-hoc reporting, etc.).
1155 * This interface does not make assumptions about the underlying JS/HTML constructs the visual uses to render itself.
1156 */
1157 export interface IVisual extends extensibility.IVisual {
1158 /** Notifies the IVisual of an update (data, viewmode, size change). */
1159 update(options: VisualUpdateOptions): void;
1160
1161 /** Notifies the visual that it is being destroyed, and to do any cleanup necessary (such as unsubscribing event handlers). */
1162 destroy?(): void;
1163
1164 /** Gets the set of objects that the visual is currently displaying. */
1165 enumerateObjectInstances?(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstanceEnumeration;
1166 }
1167
1168 export interface IVisualHost extends extensibility.IVisualHost { }
1169
1170 export interface VisualUpdateOptions extends extensibility.VisualUpdateOptions {
1171 viewport: IViewport;
1172 dataViews: DataView[];
1173 type: VisualUpdateType;
1174 viewMode?: ViewMode;
1175 }
1176
1177 export interface VisualConstructorOptions extends extensibility.VisualConstructorOptions {
1178 element: HTMLElement;
1179 host: IVisualHost;
1180 }
1181
1182}
1183
1184
1185
1186/**
1187 * Change Log Version 1.1.0
1188 */
1189declare module powerbi.extensibility.v110 {
1190 /**
1191 * Represents a visualization displayed within an application (PowerBI dashboards, ad-hoc reporting, etc.).
1192 * This interface does not make assumptions about the underlying JS/HTML constructs the visual uses to render itself.
1193 */
1194 export interface IVisual extends extensibility.IVisual {
1195 /** Notifies the IVisual of an update (data, viewmode, size change). */
1196 update(options: VisualUpdateOptions): void;
1197
1198 /** Notifies the visual that it is being destroyed, and to do any cleanup necessary (such as unsubscribing event handlers). */
1199 destroy?(): void;
1200
1201 /** Gets the set of objects that the visual is currently displaying. */
1202 enumerateObjectInstances?(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstanceEnumeration;
1203 }
1204
1205 export interface IVisualHost extends extensibility.IVisualHost {
1206 createSelectionIdBuilder: () => visuals.ISelectionIdBuilder;
1207 createSelectionManager: () => ISelectionManager;
1208 }
1209
1210 export interface VisualUpdateOptions extends extensibility.VisualUpdateOptions {
1211 viewport: IViewport;
1212 dataViews: DataView[];
1213 type: VisualUpdateType;
1214 viewMode?: ViewMode;
1215 }
1216
1217 export interface VisualConstructorOptions extends extensibility.VisualConstructorOptions {
1218 element: HTMLElement;
1219 host: IVisualHost;
1220 }
1221
1222}
1223
1224
1225
1226declare module powerbi.extensibility {
1227 import DataViewObjectDescriptors = powerbi.data.DataViewObjectDescriptors;
1228
1229 /** Defines the capabilities of an IVisual. */
1230 export interface VisualCapabilities {
1231 /** Defines what roles the visual expects, and how those roles should be populated. This is useful for visual generation/editing. */
1232 dataRoles?: VisualDataRole[];
1233
1234 /** Defines the set of objects supported by this IVisual. */
1235 objects?: DataViewObjectDescriptors;
1236
1237 /** Defines how roles that the visual understands map to the DataView. This is useful for query generation. */
1238 dataViewMappings?: DataViewMapping[];
1239
1240 /** Indicates whether cross-highlight is supported by the visual. This is useful for query generation. */
1241 supportsHighlight?: boolean;
1242
1243 /** Indicates whether sorting is supported by the visual. This is useful for query generation */
1244 sorting?: VisualSortingCapabilities;
1245 }
1246}
1247
1248
1249declare module powerbi {
1250
1251 /**
1252 * Interface that provides scripted access to geographical location information associated with the hosting device
1253 * The Interface is similar to W3 Geolocation API Specification {@link https://dev.w3.org/geo/api/spec-source.html}
1254 */
1255 export interface IGeolocation {
1256 /**
1257 * Request repeated updates
1258 *
1259 * @param successCallback invoked when current location successfully obtained
1260 * @param errorCallback invoked when attempt to obtain the current location fails
1261 *
1262 * @return a number value that uniquely identifies a watch operation
1263 */
1264 watchPosition(successCallback: IPositionCallback, errorCallback?: IPositionErrorCallback): number;
1265 /**
1266 * Cancel the updates
1267 *
1268 * @param watchId a number returned from {@link IGeolocation#watchPosition}
1269 */
1270 clearWatch(watchId: number): void;
1271 /**
1272 * One-shot position request.
1273 *
1274 * @param successCallback invoked when current location successfully obtained
1275 * @param errorCallback invoked when attempt to obtain the current location fails
1276 */
1277 getCurrentPosition(successCallback: IPositionCallback, errorCallback?: IPositionErrorCallback): void;
1278 }
1279
1280 export interface IPositionCallback {
1281 (position: Position): void;
1282 }
1283
1284 export interface IPositionErrorCallback {
1285 (error: PositionError): void;
1286 }
1287}
1288
1289
1290declare module powerbi.visuals.telemetry {
1291
1292 export interface ITelemetryEventI<T> extends ITelemetryEvent {
1293 info: T;
1294 }
1295
1296 interface IErrorWithStackTraceAndSourceDetails extends IErrorWithStackTrace {
1297 source: string;
1298 lineNumber: number;
1299 columnNumber: number;
1300 }
1301
1302 export interface IErrorWithStackTrace extends IError {
1303 stack: string;
1304 }
1305
1306 export interface IError {
1307 message: string;
1308 }
1309
1310 export interface IPBIVisualException extends IErrorWithStackTraceAndSourceDetails {
1311 visualType: string;
1312 isCustom: boolean;
1313 apiVersion: string;
1314 }
1315
1316 export interface IPBIExtensibilityVisualApiUsage extends ICustomerAction {
1317 name: string;
1318 apiVersion: string;
1319 custom: boolean;
1320 }
1321
1322 export interface VisualTelemetryInfo {
1323 name: string;
1324 apiVersion: string;
1325 custom: boolean;
1326 }
1327
1328}
1329
1330
1331declare module powerbi.visuals.telemetry {
1332
1333 interface ITelemetryService {
1334 /** Log Telemetry event */
1335 logEvent(eventFactory: ITelemetryEventFactory): ITelemetryEvent;
1336 logEvent<T>(eventFactory: ITelemetryEventFactory1<T>, arg: T): ITelemetryEvent;
1337 logEvent<T1, T2>(eventFactory: ITelemetryEventFactory2<T1, T2>, arg1: T1, arg2: T2): ITelemetryEvent;
1338 logEvent<T1, T2, T3>(eventFactory: ITelemetryEventFactory3<T1, T2, T3>, arg1: T1, arg2: T2, arg3: T3): ITelemetryEvent;
1339 logEvent<T1, T2, T3, T4>(eventFactory: ITelemetryEventFactory4<T1, T2, T3, T4>, arg1: T1, arg2: T2, arg3: T3, arg4: T4): ITelemetryEvent;
1340 logEvent<T1, T2, T3, T4, T5>(eventFactory: ITelemetryEventFactory5<T1, T2, T3, T4, T5>, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5): ITelemetryEvent;
1341 logEvent<T1, T2, T3, T4, T5, T6>(eventFactory: ITelemetryEventFactory6<T1, T2, T3, T4, T5, T6>, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6): ITelemetryEvent;
1342 logEvent<T1, T2, T3, T4, T5, T6, T7>(eventFactory: ITelemetryEventFactory7<T1, T2, T3, T4, T5, T6, T7>, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7): ITelemetryEvent;
1343 logEvent<T1, T2, T3, T4, T5, T6, T7, T8>(eventFactory: ITelemetryEventFactory8<T1, T2, T3, T4, T5, T6, T7, T8>, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8): ITelemetryEvent;
1344 logEvent<T1, T2, T3, T4, T5, T6, T7, T8, T9>(eventFactory: ITelemetryEventFactory9<T1, T2, T3, T4, T5, T6, T7, T8, T9>, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, arg9: T9): ITelemetryEvent;
1345 logEvent<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(eventFactory: ITelemetryEventFactory10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, arg9: T9, arg10: T10): ITelemetryEvent;
1346 logEvent<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(eventFactory: ITelemetryEventFactory11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, arg9: T9, arg10: T10, arg11: T11): ITelemetryEvent;
1347 }
1348
1349 interface ITelemetryEvent {
1350 name: string;
1351 category?: TelemetryCategory;
1352 id: string;
1353 loggers?: number;
1354 time: number;
1355 getFormattedInfoObject(): any;
1356 info: any;
1357 privateFields: string[];
1358 orgInfoFields: string[];
1359 }
1360
1361 interface ITelemetryEventFactory {
1362 (parentId: string): ITelemetryEvent;
1363 }
1364 interface ITelemetryEventFactory1<T> {
1365 (arg: T, parentId: string): ITelemetryEvent;
1366 }
1367 interface ITelemetryEventFactory2<T1, T2> {
1368 (arg1: T1, arg2: T2, parentId: string): ITelemetryEvent;
1369 }
1370 interface ITelemetryEventFactory3<T1, T2, T3> {
1371 (arg1: T1, arg2: T2, arg3: T3, parentId: string): ITelemetryEvent;
1372 }
1373 interface ITelemetryEventFactory4<T1, T2, T3, T4> {
1374 (arg1: T1, arg2: T2, arg3: T3, arg4: T4, parentId: string): ITelemetryEvent;
1375 }
1376 interface ITelemetryEventFactory5<T1, T2, T3, T4, T5> {
1377 (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, parentId: string): ITelemetryEvent;
1378 }
1379 interface ITelemetryEventFactory6<T1, T2, T3, T4, T5, T6> {
1380 (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, parentId: string): ITelemetryEvent;
1381 }
1382 interface ITelemetryEventFactory7<T1, T2, T3, T4, T5, T6, T7> {
1383 (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, parentId: string): ITelemetryEvent;
1384 }
1385 interface ITelemetryEventFactory8<T1, T2, T3, T4, T5, T6, T7, T8> {
1386 (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, parentId: string): ITelemetryEvent;
1387 }
1388 interface ITelemetryEventFactory9<T1, T2, T3, T4, T5, T6, T7, T8, T9> {
1389 (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, arg9: T9, parentId: string): ITelemetryEvent;
1390 }
1391 interface ITelemetryEventFactory10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> {
1392 (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, arg9: T9, arg10: T10, parentId: string): ITelemetryEvent;
1393 }
1394 interface ITelemetryEventFactory11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> {
1395 (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: T7, arg8: T8, arg9: T9, arg10: T10, arg11: T11, parentId: string): ITelemetryEvent;
1396 }
1397
1398 interface IBaseEvent {
1399 parentId: string;
1400 isError: boolean;
1401 errorSource: ErrorSource;
1402 errorCode: string;
1403 }
1404
1405 interface ICustomerAction extends IBaseEvent {
1406 }
1407}
1408
1409declare module powerbi {
1410 interface ITelemetryService { }
1411}
1412
1413
1414
1415
1416declare module powerbi {
1417 export interface DefaultValueDefinition {
1418 value: data.ISQConstantExpr;
1419 identityFieldsValues?: data.ISQConstantExpr[];
1420 }
1421
1422 export interface DefaultValueTypeDescriptor {
1423 defaultValue: boolean;
1424 }
1425}
1426
1427
1428declare module powerbi {
1429 import DisplayNameGetter = powerbi.data.DisplayNameGetter;
1430
1431 export type EnumMemberValue = string | number;
1432
1433 export interface IEnumMember {
1434 value: EnumMemberValue;
1435 displayName: DisplayNameGetter;
1436 }
1437
1438 /** Defines a custom enumeration data type, and its values. */
1439 export interface IEnumType {
1440 /** Gets the members of the enumeration, limited to the validMembers, if appropriate. */
1441 members(validMembers?: EnumMemberValue[]): IEnumMember[];
1442 }
1443
1444}
1445
1446
1447declare module powerbi {
1448 export interface Fill {
1449 solid?: {
1450 color?: string;
1451 };
1452 gradient?: {
1453 startColor?: string;
1454 endColor?: string;
1455 };
1456 pattern?: {
1457 patternKind?: string;
1458 color?: string;
1459 };
1460 }
1461
1462 export interface FillTypeDescriptor {
1463 solid?: {
1464 color?: FillSolidColorTypeDescriptor;
1465 };
1466 gradient?: {
1467 startColor?: boolean;
1468 endColor?: boolean;
1469 };
1470 pattern?: {
1471 patternKind?: boolean;
1472 color?: boolean;
1473 };
1474 }
1475
1476 export type FillSolidColorTypeDescriptor = boolean | FillSolidColorAdvancedTypeDescriptor;
1477
1478 export interface FillSolidColorAdvancedTypeDescriptor {
1479 /** Indicates whether the color value may be nullable, and a 'no fill' option is appropriate. */
1480 nullable: boolean;
1481 }
1482}
1483
1484
1485declare module powerbi {
1486 export interface FillRule extends FillRuleGeneric<string, number> {
1487 }
1488
1489 export interface FillRuleTypeDescriptor {
1490 }
1491
1492 export interface FillRuleGeneric<TColor, TValue> {
1493 linearGradient2?: LinearGradient2Generic<TColor, TValue>;
1494 linearGradient3?: LinearGradient3Generic<TColor, TValue>;
1495
1496 // stepped2?
1497 // ...
1498 }
1499
1500 export interface LinearGradient2Generic<TColor, TValue> {
1501 max: RuleColorStopGeneric<TColor, TValue>;
1502 min: RuleColorStopGeneric<TColor, TValue>;
1503 }
1504
1505 export interface LinearGradient3Generic<TColor, TValue> {
1506 max: RuleColorStopGeneric<TColor, TValue>;
1507 mid: RuleColorStopGeneric<TColor, TValue>;
1508 min: RuleColorStopGeneric<TColor, TValue>;
1509 }
1510
1511 export interface RuleColorStopGeneric<TColor, TValue> {
1512 color: TColor;
1513 value?: TValue;
1514 }
1515}
1516
1517
1518declare module powerbi {
1519 export interface FilterTypeDescriptor {
1520 }
1521}
1522
1523
1524declare module powerbi {
1525 export type ImageValue = ImageDefinitionGeneric<string>;
1526
1527 export interface ImageDefinitionGeneric<T> {
1528 name: T;
1529 url: T;
1530 scaling?: T;
1531 }
1532
1533 export interface ImageTypeDescriptor { }
1534
1535}
1536
1537
1538declare module powerbi {
1539 export type Paragraphs = Paragraph[];
1540 export interface Paragraph {
1541 horizontalTextAlignment?: string;
1542 textRuns: TextRun[];
1543 }
1544
1545 export interface ParagraphsTypeDescriptor {
1546 }
1547
1548 export interface TextRunStyle {
1549 fontFamily?: string;
1550 fontSize?: string;
1551 fontStyle?: string;
1552 fontWeight?: string;
1553 textDecoration?: string;
1554 }
1555
1556 export interface TextRun {
1557 textStyle?: TextRunStyle;
1558 url?: string;
1559 value: string;
1560 }
1561}
1562
1563
1564declare module powerbi {
1565 import SemanticFilter = data.ISemanticFilter;
1566
1567 /** Defines instances of structural types. */
1568 export type StructuralObjectValue =
1569 Fill |
1570 FillRule |
1571 SemanticFilter |
1572 DefaultValueDefinition |
1573 ImageValue |
1574 Paragraphs;
1575
1576 /** Describes a structural type in the client type system. Leaf properties should use ValueType. */
1577 export interface StructuralTypeDescriptor {
1578 fill?: FillTypeDescriptor;
1579 fillRule?: FillRuleTypeDescriptor;
1580 filter?: FilterTypeDescriptor;
1581 expression?: DefaultValueTypeDescriptor;
1582 image?: ImageTypeDescriptor;
1583 paragraphs?: ParagraphsTypeDescriptor;
1584
1585 //border?: BorderTypeDescriptor;
1586 //etc.
1587 }
1588}
1589
1590
1591declare module powerbi {
1592 /** Describes a data value type in the client type system. Can be used to get a concrete ValueType instance. */
1593 export interface ValueTypeDescriptor {
1594 // Simplified primitive types
1595 text?: boolean;
1596 numeric?: boolean;
1597 integer?: boolean;
1598 bool?: boolean;
1599 dateTime?: boolean;
1600 duration?: boolean;
1601 binary?: boolean;
1602 none?: boolean; //TODO: 5005022 remove none type when we introduce property categories.
1603
1604 // Extended types
1605 temporal?: TemporalTypeDescriptor;
1606 geography?: GeographyTypeDescriptor;
1607 misc?: MiscellaneousTypeDescriptor;
1608 formatting?: FormattingTypeDescriptor;
1609 enumeration?: IEnumType;
1610 scripting?: ScriptTypeDescriptor;
1611 }
1612
1613 export interface ScriptTypeDescriptor {
1614 source?: boolean;
1615 }
1616
1617 export interface TemporalTypeDescriptor {
1618 year?: boolean;
1619 month?: boolean;
1620 }
1621
1622 export interface GeographyTypeDescriptor {
1623 address?: boolean;
1624 city?: boolean;
1625 continent?: boolean;
1626 country?: boolean;
1627 county?: boolean;
1628 region?: boolean;
1629 postalCode?: boolean;
1630 stateOrProvince?: boolean;
1631 place?: boolean;
1632 latitude?: boolean;
1633 longitude?: boolean;
1634 }
1635
1636 export interface MiscellaneousTypeDescriptor {
1637 image?: boolean;
1638 imageUrl?: boolean;
1639 webUrl?: boolean;
1640 barcode?: boolean;
1641 }
1642
1643 export interface FormattingTypeDescriptor {
1644 color?: boolean;
1645 formatString?: boolean;
1646 alignment?: boolean;
1647 labelDisplayUnits?: boolean;
1648 fontSize?: boolean;
1649 labelDensity?: boolean;
1650 }
1651
1652 /** Describes instances of value type objects. */
1653 export type PrimitiveValue = string | number | boolean | Date;
1654}
1655
1656
1657declare module powerbi {
1658 import DataViewObjectDescriptor = powerbi.data.DataViewObjectDescriptor;
1659 import DataViewObjectDescriptors = powerbi.data.DataViewObjectDescriptors;
1660 import Selector = powerbi.data.Selector;
1661 import IPoint = powerbi.visuals.IPoint;
1662 import ISemanticFilter = powerbi.data.ISemanticFilter;
1663 import ISQExpr = powerbi.data.ISQExpr;
1664 import IStringResourceProvider = jsCommon.IStringResourceProvider;
1665 import IRect = powerbi.visuals.IRect;
1666
1667 /**
1668 * Represents a visualization displayed within an application (PowerBI dashboards, ad-hoc reporting, etc.).
1669 * This interface does not make assumptions about the underlying JS/HTML constructs the visual uses to render itself.
1670 */
1671 export interface IVisual {
1672 /**
1673 * Initializes an instance of the IVisual.
1674 *
1675 * @param options Initialization options for the visual.
1676 */
1677 init(options: VisualInitOptions): void;
1678
1679 /** Notifies the visual that it is being destroyed, and to do any cleanup necessary (such as unsubscribing event handlers). */
1680 destroy?(): void;
1681
1682 /**
1683 * Notifies the IVisual of an update (data, viewmode, size change).
1684 */
1685 update?(options: VisualUpdateOptions): void;
1686
1687 /**
1688 * Notifies the IVisual to resize.
1689 *
1690 * @param finalViewport This is the viewport that the visual will eventually be resized to.
1691 * @param resized true on on final call when resizing is complete.
1692 */
1693 onResizing?(finalViewport: IViewport, resizeMode?: ResizeMode): void;
1694
1695 /**
1696 * Notifies the IVisual of new data being provided.
1697 * This is an optional method that can be omitted if the visual is in charge of providing its own data.
1698 */
1699 onDataChanged?(options: VisualDataChangedOptions): void;
1700
1701 /** Notifies the IVisual to change view mode if applicable. */
1702 onViewModeChanged?(viewMode: ViewMode): void;
1703
1704 /** Notifies the IVisual to clear any selection. */
1705 onClearSelection?(): void;
1706
1707 /** Gets a value indicating whether the IVisual can be resized to the given viewport. */
1708 canResizeTo?(viewport: IViewport): boolean;
1709
1710 /** Gets the set of objects that the visual is currently displaying. */
1711 enumerateObjectInstances?(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstanceEnumeration;
1712
1713 /** Gets the set of object repetitions that the visual can display. */
1714 enumerateObjectRepetition?(): VisualObjectRepetition[];
1715 }
1716
1717 /** Parameters available to a CustomizeQueryMethod */
1718 export interface CustomizeQueryOptions {
1719 /**
1720 * The data view mapping for this visual with some additional information. CustomizeQueryMethod implementations
1721 * are expected to edit this in-place.
1722 */
1723 dataViewMappings: data.CompiledDataViewMapping[];
1724
1725 /**
1726 * Visual should prefer to request a higher volume of data.
1727 */
1728 preferHigherDataVolume?: boolean;
1729 }
1730
1731 /** Parameters available to a sortable visual candidate */
1732 export interface VisualSortableOptions {
1733 /* The data view mapping for this visual with some additional information.*/
1734 dataViewMappings: data.CompiledDataViewMapping[];
1735 }
1736
1737 /** An imperative way for a visual to influence query generation beyond just its declared capabilities. */
1738 export interface CustomizeQueryMethod {
1739 (options: CustomizeQueryOptions): void;
1740 }
1741
1742 /** Defines the visual filtering capability for a particular filter kind. */
1743 export interface VisualFilterMapping {
1744 /** Specifies what data roles are used to control the filter semantics for this filter kind. */
1745 targetRoles: string[];
1746 }
1747
1748 /**
1749 * Defines the visual filtering capabilities for various filter kinds.
1750 * By default all visuals support attribute filters and measure filters in their innermost scope.
1751 */
1752 export interface VisualFilterMappings {
1753 measureFilter?: VisualFilterMapping;
1754 }
1755
1756 /** Defines the capabilities of an IVisual. */
1757 export interface VisualCapabilities {
1758 /** Defines what roles the visual expects, and how those roles should be populated. This is useful for visual generation/editing. */
1759 dataRoles?: VisualDataRole[];
1760
1761 /** Defines the set of objects supported by this IVisual. */
1762 objects?: DataViewObjectDescriptors;
1763
1764 /** Defines how roles that the visual understands map to the DataView. This is useful for query generation. */
1765 dataViewMappings?: DataViewMapping[];
1766
1767 /** Defines how filters are understood by the visual. This is used by query generation */
1768 filterMappings?: VisualFilterMappings;
1769
1770 /** Indicates whether cross-highlight is supported by the visual. This is useful for query generation. */
1771 supportsHighlight?: boolean;
1772
1773 /** Indicates whether the visual uses onSelected function for data selections. Default is true. */
1774 supportsSelection?: boolean;
1775
1776 /** Indicates whether sorting is supported by the visual. This is useful for query generation */
1777 sorting?: VisualSortingCapabilities;
1778
1779 /** Indicates whether a default title should be displayed. Visuals with self-describing layout can omit this. */
1780 suppressDefaultTitle?: boolean;
1781
1782 /** Indicates whether a default padding should be applied. */
1783 suppressDefaultPadding?: boolean;
1784
1785 /** Indicates whether drilling is supported by the visual. */
1786 drilldown?: VisualDrillCapabilities;
1787
1788 /** Indicates whether rotating is supported by the visual. */
1789 canRotate?: boolean;
1790
1791 /** Indicates whether showing the data underlying this visual would be helpful. Visuals that already show raw data can specify this. */
1792 disableVisualDetails?: boolean;
1793
1794 /** Indicates whether focus mode is supported for the visual. Visuals that would not benefit from focus mode (such as non-data-bound ones) can set it to true. */
1795 disableFocusMode?: boolean;
1796 }
1797
1798 /** Defines the visual sorting capability. */
1799 export interface VisualSortingCapabilities {
1800 /** When specified, indicates that the IVisual wants default sorting behavior. */
1801 default?: {};
1802
1803 /** When specified, indicates that the IVisual wants to control sort interactivity. */
1804 custom?: {};
1805
1806 /** When specified, indicates sorting that is inherently implied by the IVisual. This is useful to automatically sort. */
1807 implicit?: VisualImplicitSorting;
1808 }
1809
1810 /** Defines the visual's drill capability. */
1811 export interface VisualDrillCapabilities {
1812 /** Returns the drillable role names for this visual **/
1813 roles?: string[];
1814 }
1815
1816 /** Defines implied sorting behaviour for an IVisual. */
1817 export interface VisualImplicitSorting {
1818 clauses: VisualImplicitSortingClause[];
1819 }
1820
1821 export interface VisualImplicitSortingClause {
1822 role: string;
1823 direction: SortDirection;
1824 }
1825
1826 /** Defines the capabilities of an IVisual. */
1827 export interface VisualInitOptions {
1828 /** The DOM element the visual owns. */
1829 element: JQuery;
1830
1831 /** The set of services provided by the visual hosting layer. */
1832 host: IVisualHostServices;
1833
1834 /** Style information. */
1835 style: IVisualStyle;
1836
1837 /** The initial viewport size. */
1838 viewport: IViewport;
1839
1840 /** Animation options. */
1841 animation?: AnimationOptions;
1842
1843 /** Interactivity options. */
1844 interactivity?: InteractivityOptions;
1845 }
1846
1847 export interface VisualUpdateOptions {
1848 viewport: IViewport;
1849 dataViews: DataView[];
1850 suppressAnimations?: boolean;
1851 viewMode?: ViewMode;
1852 resizeMode?: ResizeMode;
1853 type?: VisualUpdateType;
1854 /** Indicates what type of update has been performed on the data.
1855 The default operation kind is Create.*/
1856 operationKind?: VisualDataChangeOperationKind;
1857 }
1858
1859 export interface VisualDataChangedOptions {
1860 dataViews: DataView[];
1861
1862 /** Optionally prevent animation transitions */
1863 suppressAnimations?: boolean;
1864
1865 /** Indicates what type of update has been performed on the data.
1866 The default operation kind is Create.*/
1867 operationKind?: VisualDataChangeOperationKind;
1868 }
1869
1870 export interface CustomSortEventArgs {
1871 sortDescriptors: SortableFieldDescriptor[];
1872 }
1873
1874 export interface SortableFieldDescriptor {
1875 queryName: string;
1876 sortDirection?: SortDirection;
1877 }
1878
1879 export interface IVisualErrorMessage {
1880 message: string;
1881 title: string;
1882 detail: string;
1883 }
1884
1885 export interface IVisualWarning {
1886 code: string;
1887 getMessages(resourceProvider: IStringResourceProvider): IVisualErrorMessage;
1888 }
1889
1890 /** Animation options for visuals. */
1891 export interface AnimationOptions {
1892 /** Indicates whether all transition frames should be flushed immediately, effectively "disabling" any visual transitions. */
1893 transitionImmediate: boolean;
1894 }
1895
1896 /** Interactivity options for visuals. */
1897 export interface InteractivityOptions {
1898 /** Indicates that dragging of data points should be permitted. */
1899 dragDataPoint?: boolean;
1900
1901 /** Indicates that data points should be selectable. */
1902 selection?: boolean;
1903
1904 /** Indicates that the chart and the legend are interactive */
1905 isInteractiveLegend?: boolean;
1906
1907 /** Indicates overflow behavior. Values are CSS oveflow strings */
1908 overflow?: string;
1909 }
1910
1911 export interface VisualDragPayload extends DragPayload {
1912 data?: Selector;
1913 field?: {};
1914 }
1915
1916 export interface DragEventArgs {
1917 event: DragEvent;
1918 data: VisualDragPayload;
1919 }
1920
1921 /** Defines geocoding services. */
1922 export interface IGeocoder {
1923 geocode(query: string, category?: string): IPromise<IGeocodeCoordinate>;
1924 geocodeBoundary(latitude: number, longitude: number, category: string, levelOfDetail?: number, maxGeoData?: number): IPromise<IGeocodeBoundaryCoordinate>;
1925 geocodePoint(latitude: number, longitude: number): IPromise<IGeocodeResource>;
1926
1927 /** returns data immediately if it is locally available (e.g. in cache), null if not in cache */
1928 tryGeocodeImmediate(query: string, category?: string): IGeocodeCoordinate;
1929 tryGeocodeBoundaryImmediate(latitude: number, longitude: number, category: string, levelOfDetail?: number, maxGeoData?: number): IGeocodeBoundaryCoordinate;
1930 }
1931
1932 export interface IGeocodeCoordinate {
1933 latitude: number;
1934 longitude: number;
1935 }
1936
1937 export interface IGeocodeBoundaryCoordinate {
1938 latitude?: number;
1939 longitude?: number;
1940 locations?: IGeocodeBoundaryPolygon[]; // one location can have multiple boundary polygons
1941 }
1942
1943 export interface IGeocodeResource extends IGeocodeCoordinate {
1944 addressLine: string;
1945 locality: string;
1946 neighborhood: string;
1947 adminDistrict: string;
1948 adminDistrict2: string;
1949 formattedAddress: string;
1950 postalCode: string;
1951 countryRegionIso2: string;
1952 countryRegion: string;
1953 landmark: string;
1954 }
1955
1956 export interface IGeocodeBoundaryPolygon {
1957 nativeBing: string;
1958
1959 /** array of lat/long pairs as [lat1, long1, lat2, long2,...] */
1960 geographic?: Float64Array;
1961
1962 /** array of absolute pixel position pairs [x1,y1,x2,y2,...]. It can be used by the client for cache the data. */
1963 absolute?: Float64Array;
1964 absoluteBounds?: IRect;
1965
1966 /** string of absolute pixel position pairs "x1 y1 x2 y2...". It can be used by the client for cache the data. */
1967 absoluteString?: string;
1968 }
1969
1970 export interface SelectorForColumn {
1971 [queryName: string]: data.DataRepetitionSelector;
1972 }
1973
1974 export interface SelectorsByColumn {
1975 /** Data-bound repetition selection. */
1976 dataMap?: SelectorForColumn;
1977
1978 /** Metadata-bound repetition selection. Refers to a DataViewMetadataColumn queryName. */
1979 metadata?: string;
1980
1981 /** User-defined repetition selection. */
1982 id?: string;
1983 }
1984
1985 // TODO: Consolidate these two into one object and add a method to transform SelectorsByColumn[] into Selector[] for components that need that structure
1986 export interface SelectEventArgs {
1987 data: Selector[];
1988 data2?: SelectorsByColumn[];
1989 }
1990
1991 export interface ContextMenuArgs {
1992 data: SelectorsByColumn[];
1993
1994 /** Absolute coordinates for the top-left anchor of the context menu. */
1995 position: IPoint;
1996 }
1997
1998 export interface SelectObjectEventArgs {
1999 object: DataViewObjectDescriptor;
2000 }
2001
2002 export interface FilterAnalyzerOptions {
2003 dataView: DataView;
2004
2005 /** The DataViewObjectPropertyIdentifier for default value */
2006 defaultValuePropertyId: DataViewObjectPropertyIdentifier;
2007
2008 /** The filter that will be analyzed */
2009 filter: ISemanticFilter;
2010
2011 /** The field SQExprs used in the filter */
2012 fieldSQExprs: ISQExpr[];
2013 }
2014
2015 export interface AnalyzedFilter {
2016 /** The default value of the slicer selected item and it can be undefined if there is no default value */
2017 defaultValue?: DefaultValueDefinition;
2018
2019 /** Indicates the filter has Not condition. */
2020 isNotFilter: boolean;
2021
2022 /** The selected filter values. */
2023 selectedIdentities: DataViewScopeIdentity[];
2024
2025 /** The filter after analyzed. It will be the default filter if it has defaultValue and the pre-analyzed filter is undefined. */
2026 filter: ISemanticFilter;
2027 }
2028
2029 /** Defines behavior for IVisual interaction with the host environment. */
2030 export interface IVisualHostServices {
2031 /** Returns the localized form of a string. */
2032 getLocalizedString(stringId: string): string;
2033
2034 /** Notifies of a DragStart event. */
2035 onDragStart(args: DragEventArgs): void;
2036
2037 ///** Indicates whether the drag payload is compatible with the IVisual's data role. This is useful when dropping to a particular drop area within the visual (e.g., dropping on a legend). */
2038 //canDropAs(payload: DragPayload, dataRole?: string): boolean;
2039
2040 ///** Notifies of a Drop event. */
2041 //onDrop(args: DragEventArgs, dataRole?: string);
2042
2043 /** Gets a value indicating whether the given selection is valid. */
2044 canSelect(args: SelectEventArgs): boolean;
2045
2046 /** Notifies of a data point being selected. */
2047 onSelect(args: SelectEventArgs): void; // TODO: Revisit onSelect vs. onSelectObject.
2048
2049 /** Notifies of a request for a context menu. */
2050 onContextMenu(args: ContextMenuArgs): void;
2051
2052 /** Check if selection is sticky or otherwise. */
2053 shouldRetainSelection(): boolean;
2054
2055 /** Notifies of a visual object being selected. */
2056 onSelectObject?(args: SelectObjectEventArgs): void; // TODO: make this mandatory, not optional.
2057
2058 /** Notifies that properties of the IVisual have changed. */
2059 persistProperties(changes: VisualObjectInstance[]): void;
2060 persistProperties(changes: VisualObjectInstancesToPersist): void;
2061
2062 ///** This information will be part of the query. */
2063 //onDataRangeChanged(range: {
2064 // categorical: { // TODO: this structure is affected by the reduction algorithm as well as the data view type
2065 // categories?: {
2066 // /** Index of the category. */
2067 // index: number;
2068 // lower?: DataViewScopeIdentity;
2069 // upper?: DataViewScopeIdentity;
2070 // }[]
2071 // }
2072 // });
2073
2074 ///** Notifies of a drill down on the specified data point. */
2075 //onDrillDown(data: DataViewScopeIdentity): void;
2076
2077 /** Requests more data to be loaded. */
2078 loadMoreData(): void;
2079
2080 /** Notification to sort on the specified column */
2081 onCustomSort(args: CustomSortEventArgs): void;
2082
2083 /** Indicates which view mode the host is in. */
2084 getViewMode(): ViewMode;
2085
2086 /** Notify any warning that happened during update of the visual. */
2087 setWarnings(clientWarnings: IVisualWarning[]): void;
2088
2089 /** Sets a toolbar on the host. */
2090 setToolbar($selector: JQuery): void;
2091
2092 /** Gets Geocoding Service. */
2093 geocoder(): IGeocoder;
2094
2095 /** Gets IGeolocation Service */
2096 geolocation(): IGeolocation;
2097
2098 /** Gets the locale string */
2099 locale?(): string;
2100
2101 /** Gets the promise factory. */
2102 promiseFactory(): IPromiseFactory;
2103
2104 /** Gets filter analyzer */
2105 analyzeFilter(options: FilterAnalyzerOptions): AnalyzedFilter;
2106
2107 /** Gets display name for the identities */
2108 getIdentityDisplayNames(identities: DataViewScopeIdentity[]): DisplayNameIdentityPair[];
2109
2110 /** Set the display names for their corresponding DataViewScopeIdentity */
2111 setIdentityDisplayNames(displayNamesIdentityPairs: DisplayNameIdentityPair[]): void;
2112
2113 }
2114
2115 export interface DisplayNameIdentityPair {
2116 displayName: string;
2117 identity: DataViewScopeIdentity;
2118 }
2119}
2120
2121
2122
2123declare module powerbi {
2124
2125 export interface IVisualPlugin {
2126 /** The name of the plugin. Must match the property name in powerbi.visuals. */
2127 name: string;
2128
2129 /** The key for the watermark style of this visual. Must match the id name in ExploreUI/views/svg/visualsWatermarks.svg */
2130 watermarkKey?: string;
2131
2132 /** Declares the capabilities for this IVisualPlugin type. */
2133 capabilities?: VisualCapabilities;
2134
2135 /** Function to call to create the visual. */
2136 create: (options?: extensibility.VisualConstructorOptions) => IVisual;
2137
2138 /**
2139 * Function to allow the visual to influence query generation. Called each time a query is generated
2140 * so the visual can translate its state into options understood by the query generator.
2141 */
2142 customizeQuery?: CustomizeQueryMethod;
2143
2144 /** Funation to allow the visual to provide additional information for telemetry. */
2145 getAdditionalTelemetry?: GetAdditionalTelemetryMethod;
2146
2147 /** The class of the plugin. At the moment it is only used to have a way to indicate the class name that a custom visual has. */
2148 class?: string;
2149
2150 /** The url to the icon to display within the visualization pane. */
2151 iconUrl?: string;
2152
2153 /** Check if a visual is custom */
2154 custom?: boolean;
2155
2156 /** Function to get the list of sortable roles */
2157 getSortableRoles?: (visualSortableOptions?: VisualSortableOptions) => string[];
2158
2159 /** The version of the api that this plugin should be run against */
2160 apiVersion?: string;
2161 }
2162
2163 /** Method for gathering addition information from the visual for telemetry. */
2164 export interface GetAdditionalTelemetryMethod {
2165 (dataView: DataView): any;
2166 }
2167
2168 /** Factory method for an IVisual. This factory method should be registered on the powerbi.visuals object. */
2169 export interface IVisualFactoryMethod {
2170 (): powerbi.IVisual;
2171 }
2172}
2173
2174
2175declare module powerbi {
2176 export interface IVisualStyle{
2177 colorPalette: IColorPalette;
2178 isHighContrast: boolean;
2179 titleText: ITextStyle;
2180 subTitleText: ITextStyle;
2181 labelText: ITextStyle;
2182 // TODO 4486317: This is a host-specific property that should be exposed through DataViewObjects.
2183 maxMarginFactor?: number;
2184 }
2185
2186 export interface ITextStyle extends IStyleInfo {
2187 fontFace?: string;
2188 fontSize?: string;
2189 fontWeight?: string;
2190 color: IColorInfo;
2191 }
2192
2193 export interface IColorPalette {
2194 background?: IColorInfo;
2195 foreground?: IColorInfo;
2196
2197 positive?: IColorInfo;
2198 neutral?: IColorInfo;
2199 negative?: IColorInfo;
2200 separator?: IColorInfo;
2201 selection?: IColorInfo;
2202
2203 dataColors: IDataColorPalette;
2204 }
2205
2206 export interface IDataColorPalette {
2207 /** Gets the color scale associated with the given key. */
2208 getColorScaleByKey(scaleKey: string): IColorScale;
2209
2210 /** Gets a fresh color scale with no colors allocated. */
2211 getNewColorScale(): IColorScale;
2212
2213 /** Gets the nth color in the palette. */
2214 getColorByIndex(index: number): IColorInfo;
2215
2216 /**
2217 * Gets the set of sentiment colors used for visuals such as KPIs
2218 * Note: This is only a temporary API so that we can have reasonable color schemes for KPIs
2219 * and gauges until the conditional formatting feature is implemented.
2220 */
2221 getSentimentColors(): IColorInfo[];
2222
2223 getBasePickerColors(): IColorInfo[];
2224
2225 /** Gets all the colors for the color palette **/
2226 getAllColors?(): IColorInfo[];
2227 }
2228
2229 export interface IColorScale {
2230 /** Gets the color associated with the given key. */
2231 getColor(key: any): IColorInfo;
2232
2233 /**
2234 * Clears the current scale, but rotates the colors such that the first color allocated will
2235 * the be first color that would have been allocated before clearing the scale.
2236 */
2237 clearAndRotateScale(): void;
2238
2239 /** Returns a copy of the current scale. */
2240 clone(): IColorScale;
2241
2242 getDomain(): any[];
2243 }
2244
2245 export interface IColorInfo extends IStyleInfo {
2246 value: string;
2247 }
2248
2249 export interface IStyleInfo {
2250 className?: string;
2251 }
2252}
2253
2254
2255declare module powerbi {
2256 import Selector = powerbi.data.Selector;
2257
2258 export interface VisualObjectInstance {
2259 /** The name of the object (as defined in VisualCapabilities). */
2260 objectName: string;
2261
2262 /** A display name for the object instance. */
2263 displayName?: string;
2264
2265 /** The set of property values for this object. Some of these properties may be defaults provided by the IVisual. */
2266 properties: {
2267 [propertyName: string]: DataViewPropertyValue;
2268 };
2269
2270 /** The selector that identifies this object. */
2271 selector: Selector;
2272
2273 /** Defines the constrained set of valid values for a property. */
2274 validValues?: {
2275 [propertyName: string]: string[];
2276 };
2277
2278 /** (Optional) VisualObjectInstanceEnumeration category index. */
2279 containerIdx?: number;
2280 }
2281
2282 export type VisualObjectInstanceEnumeration = VisualObjectInstance[] | VisualObjectInstanceEnumerationObject;
2283
2284 export interface VisualObjectInstanceEnumerationObject {
2285 /** The visual object instances. */
2286 instances: VisualObjectInstance[];
2287
2288 /** Defines a set of containers for related object instances. */
2289 containers?: VisualObjectInstanceContainer[];
2290 }
2291
2292 export interface VisualObjectInstanceContainer {
2293 displayName: data.DisplayNameGetter;
2294 }
2295
2296 export interface VisualObjectInstancesToPersist {
2297 /** Instances which should be merged with existing instances. */
2298 merge?: VisualObjectInstance[];
2299
2300 /** Instances which should replace existing instances. */
2301 replace?: VisualObjectInstance[];
2302
2303 /** Instances which should be deleted from the existing instances. */
2304 remove?: VisualObjectInstance[];
2305 }
2306
2307 export interface EnumerateVisualObjectInstancesOptions {
2308 objectName: string;
2309 }
2310}
2311
2312
2313
2314declare module powerbi {
2315 import Selector = powerbi.data.Selector;
2316
2317 export interface VisualObjectRepetition {
2318 /** The selector that identifies the objects. */
2319 selector: Selector;
2320
2321 /** The set of repetition descriptors for this object. */
2322 objects: {
2323 [objectName: string]: DataViewRepetitionObjectDescriptor;
2324 };
2325 }
2326
2327 export interface DataViewRepetitionObjectDescriptor {
2328 /** Properties used for formatting (e.g., Conditional Formatting). */
2329 formattingProperties?: string[];
2330 }
2331}