Skip to content

Commit

Permalink
Remove interactivity utils (#127)
Browse files Browse the repository at this point in the history
* Remove behavior classes

* Remove interactivity utils from legend

* Remove interactivity utils from packages

* Remove interactivity utils from labels

* Fix legend tests

* Increment version

* Increase version to 7.0.0

* Add interface for selectable dataPoint

* Fix eslint

* Update docs

* Remove interactive legend class

* Update docs

* Update changelog

* Update changelog

* Update docs

* Use beta version

---------

Co-authored-by: Iuliia Kulagina <[email protected]>
  • Loading branch information
kullJul and kullJul authored Jul 19, 2024
1 parent 2f4b09e commit a658e5a
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 1,067 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 7.0.0
* Removed interactivityutils and related code
* Removed interactiveLegend class
* Changed createLegend function signature -> createLegend(HTMLElement, boolean, LegendPosition)

## 6.0.4
* Updated powerbi-visuals-api to 5.9.0 and other utils

Expand Down
7 changes: 0 additions & 7 deletions docs/api/legend.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ This helper function simplifies PowerBI Custom Visual legends creation.

```typescript
function createLegend(legendParentElement: HTMLElement, // top visual element, container in which legend will be created
interactive: boolean, // indicates that legend should be interactive
interactivityService: IInteractivityService, // reference to IInteractivityService interface which need to create legend click events
isScrollable: boolean = false, // indicates that legend could be scrollable or not
legendPosition: LegendPosition = LegendPosition.Top // Position of the legend inside of legendParentElement container
): ILegend;
Expand All @@ -31,13 +29,8 @@ function createLegend(legendParentElement: HTMLElement, // top visual e

//... some other init calls

if (this.behavior) {
this.interactivityService = createInteractivityService(hostServices);
}
this.legend = createLegend(
element,
options.interactivity && options.interactivity.isInteractiveLegend,
this.interactivityService,
true);
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/dev/development-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ npm run build
This command compiles less code to CSS and TypeScript code to JavaScript. The result of the compilation is available in the ```lib``` directory.

## How to lint the source code
We use [TSLint](https://github.com/palantir/tslint) as a linter for TypeScript code. To check source code you should run the following command:
We use [eslint](https://github.com/eslint/eslint) as a linter for TypeScript code. To check source code you should run the following command:

```bash
npm run lint
```

This command checks style of TypeScript code and provides a list of problems. Please address all of problems reported by TSLint before sending a pull request to the [repository](https://github.com/Microsoft/powerbi-visuals-utils-chartutils).
This command checks style of TypeScript code and provides a list of problems. Please address all of problems reported by eslint before sending a pull request to the [repository](https://github.com/Microsoft/powerbi-visuals-utils-chartutils).

## How to run unit tests locally
We use [Jasmine](https://github.com/jasmine/jasmine) and [Karma](https://github.com/karma-runner/karma) to run unit tests. Please note, Karma requires Google Chrome to run unit tests.
Expand Down
6 changes: 0 additions & 6 deletions docs/usage/installation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ This command installs the package and adds a package as a dependency to your ```
The package contains ```d.ts``` declarations file, it's necessary for TypeScript compiler and it helps to develop your visuals fast and confident. You should add the following files to the ```files``` property of ```tsconfig.json```:
* ```typings/index.d.ts```
* ```node_modules/powerbi-visuals-utils-formattingutils/lib/index.d.ts```
* ```node_modules/powerbi-visuals-utils-interactivityutils/lib/index.d.ts```
* ```node_modules/powerbi-visuals-utils-svgutils/lib/index.d.ts```
* ```node_modules/powerbi-visuals-utils-typeutils/lib/index.d.ts```
* ```node_modules/powerbi-visuals-utils-chartutils/lib/index.d.ts```
Expand All @@ -37,7 +36,6 @@ As a result you will have the following file structure:
"files": [
"typings/index.d.ts",
"node_modules/powerbi-visuals-utils-formattingutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-interactivityutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-svgutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-typeutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-chartutils/lib/index.d.ts"
Expand All @@ -53,7 +51,6 @@ To use the package with your custom visuals you should add the following files t
* ```node_modules/powerbi-visuals-utils-typeutils/lib/index.js```
* ```node_modules/powerbi-visuals-utils-svgutils/lib/index.js```
* ```node_modules/powerbi-visuals-utils-formattingutils/lib/index.js```
* ```node_modules/powerbi-visuals-utils-interactivityutils/lib/index.js```
* ```node_modules/powerbi-visuals-utils-chartutils/lib/index.js```

As a result you will have the following file structure:
Expand All @@ -70,7 +67,6 @@ As a result you will have the following file structure:
"node_modules/powerbi-visuals-utils-typeutils/lib/index.js",
"node_modules/powerbi-visuals-utils-svgutils/lib/index.js",
"node_modules/powerbi-visuals-utils-formattingutils/lib/index.js",
"node_modules/powerbi-visuals-utils-interactivityutils/lib/index.js",
"node_modules/powerbi-visuals-utils-chartutils/lib/index.js"
],
"style": ...,
Expand All @@ -81,12 +77,10 @@ As a result you will have the following file structure:
## Including CSS artifacts to the custom visual
To use the package with your custom visuals you should import the following CSS files to your ```.less``` file:

* ```node_modules/powerbi-visuals-utils-interactivityutils/lib/index.css```
* ```node_modules/powerbi-visuals-utils-chartutils/lib/index.css```

As a result you will have the following file structure:
```less
@import (less) "node_modules/powerbi-visuals-utils-interactivityutils/lib/index.css";
@import (less) "node_modules/powerbi-visuals-utils-chartutils/lib/index.css";
```

Expand Down
1 change: 1 addition & 0 deletions docs/usage/usage-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ This package contains the following classes, interfaces and methods:
* [Axis Helper](../api/axis-helper.md) - provide all necessary methods to maintain chart axes
* [DataLabelManager](../api/data-label-manager.md) - helps to create and maintain labels
* [DataLabelUtils](../api/data-label-utils.md) - label manager utils
* [Legend](../api/legend.md) - helps to create and mantain legend
37 changes: 2 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powerbi-visuals-utils-chartutils",
"version": "6.0.4",
"version": "7.0.0-beta.1",
"description": "ChartUtils",
"main": "lib/index.js",
"module": "lib/index.js",
Expand Down Expand Up @@ -72,7 +72,6 @@
"d3-selection": "^3.0.0",
"d3-transition": "^3.0.1",
"powerbi-visuals-utils-formattingutils": "^6.1.1",
"powerbi-visuals-utils-interactivityutils": "^6.0.4",
"powerbi-visuals-utils-svgutils": "^6.0.4",
"powerbi-visuals-utils-typeutils": "^6.0.3"
},
Expand Down
8 changes: 2 additions & 6 deletions src/dataLabel/dataLabelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ import * as svg from "powerbi-visuals-utils-svgutils";
import ClassAndSelector = svg.CssConstants.ClassAndSelector;
import createClassAndSelector = svg.CssConstants.createClassAndSelector;

// powerbi.extensibility.utils.interactivity
import { interactivitySelectionService } from "powerbi-visuals-utils-interactivityutils";
import SelectionDataPoint = interactivitySelectionService.SelectableDataPoint;

import * as dataLabelInterfaces from "./dataLabelInterfaces";
import LabelFormattedTextOptions = dataLabelInterfaces.LabelFormattedTextOptions;
import LabelEnabledDataPoint = dataLabelInterfaces.LabelEnabledDataPoint;
Expand Down Expand Up @@ -216,7 +212,7 @@ export function drawDefaultLabelsForDataPointChart(data: any[], context: Selecti
.transition("")
.duration(animationDuration)
// .style(layout.style as any)
.style("opacity", (hasSelection ? (d: SelectionDataPoint) => getFillOpacity(d.selected, false, hasSelection, false) : 1) as any)
.style("opacity", (hasSelection ? d => getFillOpacity(d.selected, false, hasSelection, false) : 1) as any)
.attr(
"x", (d: LabelEnabledDataPoint) => d.labelX
)
Expand Down Expand Up @@ -260,7 +256,7 @@ function selectLabels(filteredData: LabelEnabledDataPoint[], context: Selection<
const getIdentifier = hasKey ?
(d: any) => d.key
: hasDataPointIdentity ?
(d: SelectionDataPoint) => (d.identity as ISelectionId).getKey()
d => (d.identity as ISelectionId).getKey()
: undefined;

const labels: Selection<any, any, any, any> = isDonut ?
Expand Down
6 changes: 0 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import DataLabelManager from "./dataLabel/dataLabelManager";
import * as dataLabelUtils from "./dataLabel/dataLabelUtils";
import * as locationConverter from "./dataLabel/locationConverter";

import * as interactiveLegend from "./legend/interactiveLegend";
import * as legend from "./legend/legend";
import * as legendBehavior from "./legend/behavior/legendBehavior";
import OpacityLegendBehavior from "./legend/behavior/opacityLegendBehavior";
import * as legendData from "./legend/legendData";
import * as legendInterfaces from "./legend/legendInterfaces";
import * as legendPosition from "./legend/legendPosition";
Expand All @@ -30,11 +27,8 @@ export {
DataLabelManager,
dataLabelUtils,
locationConverter,
interactiveLegend,
label,
legend,
legendBehavior,
OpacityLegendBehavior,
legendData,
legendInterfaces,
legendPosition,
Expand Down
10 changes: 4 additions & 6 deletions src/label/labelLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ import {
IRect,
} from "powerbi-visuals-utils-svgutils";

import {
interactivitySelectionService
} from "powerbi-visuals-utils-interactivityutils";

import { FontProperties, inherit } from "./fontProperties";
import * as LabelUtils from "./labelUtils";
import * as Units from "./units";

import * as DataLabelRectPositioner from "./dataLabelRectPositioner";
import * as DataLabelPointPositioner from "./dataLabelPointPositioner";

import { ISelectableDataPoint } from "../legend/legendInterfaces";

export enum LabelOrientation {
Vertical = 0,
Horizontal = 1,
Expand Down Expand Up @@ -324,7 +322,7 @@ export interface LabelDataPointGroup<TLabelDataPoint> {
labelOrientation?: LabelOrientation;
}

export interface Label extends interactivitySelectionService.SelectableDataPoint {
export interface Label extends ISelectableDataPoint {
/** Text to be displayed in the label */
text: string;

Expand Down Expand Up @@ -363,7 +361,7 @@ export interface Label extends interactivitySelectionService.SelectableDataPoint
backgroundTransparency?: number;
}

export interface LabelOld extends interactivitySelectionService.SelectableDataPoint {
export interface LabelOld extends ISelectableDataPoint{
/** Text to be displayed in the label */
text: string;

Expand Down
79 changes: 0 additions & 79 deletions src/legend/behavior/legendBehavior.ts

This file was deleted.

Loading

0 comments on commit a658e5a

Please sign in to comment.