From 7d958aef96c8db115caaaa29e0be5ee55dc8362a Mon Sep 17 00:00:00 2001 From: Iuliia Kulagina Date: Fri, 31 May 2024 11:29:05 +0200 Subject: [PATCH] Remove animation --- src/WordCloud.ts | 26 +++++--------------------- src/behavior.ts | 26 -------------------------- 2 files changed, 5 insertions(+), 47 deletions(-) diff --git a/src/WordCloud.ts b/src/WordCloud.ts index 5cca07a..5068597 100644 --- a/src/WordCloud.ts +++ b/src/WordCloud.ts @@ -27,8 +27,6 @@ import "./../style/visual.less"; import { select as d3Select, Selection as d3Selection } from 'd3-selection'; -import { Transition as d3Transition } from 'd3-transition'; -import 'd3-transition'; import isEmpty from 'lodash.isempty'; import isString from 'lodash.isstring'; @@ -80,7 +78,6 @@ import { VisualLayout } from "./VisualLayout"; import { WordCloudColumns } from "./WordCloudColumns"; import {IWordCloudBehaviorOptions, WordCloudBehavior} from "./behavior"; -type Transition = d3Transition; type Selection = d3Selection; type WordMap = { [word: string]: boolean }; @@ -368,7 +365,6 @@ export class WordCloud implements IVisual { private data: WordCloudData; private colorPalette: IColorPalette; - private durationAnimations: number = 50; private specialViewport: IViewport; @@ -1400,17 +1396,17 @@ export class WordCloud implements IVisual { .selectAll("g") .data(wordCloudDataView.data); - const wordGroupSelectionMerged: Selection = this.wordsGroupSelection + const wordGroupSelectionMerged: Selection = this.wordsGroupSelection .enter() - .append("svg:g") + .append("g") .merge(this.wordsGroupSelection) .classed(WordCloud.WordGroup.className, true); wordGroupSelectionMerged - .append("svg:text") + .append("text") .style("font-size", WordCloud.DefaultTextFontSize); wordGroupSelectionMerged - .append("svg:rect"); + .append("rect"); this.wordsGroupSelection .exit() @@ -1433,7 +1429,7 @@ export class WordCloud implements IVisual { .exit() .remove(); - this.animateSelection(this.wordsTextUpdateSelection, this.durationAnimations) + this.wordsTextUpdateSelection .style("font-size", ((item: WordCloudDataPoint): string => PixelConverter.toString(item.size))) .style("fill", ((item: WordCloudDataPoint): string => item.color)); @@ -1516,18 +1512,6 @@ export class WordCloud implements IVisual { return formattingModel; } - private animateSelection>( - element: T, - duration: number = 0, - delay: number = 0, - callback?: (data: any, index: number) => void): Transition { - - return element.transition() - .delay(delay) - .duration(duration) - .on("end", callback); - } - private renderTooltip(selection: Selection): void { const categorical: WordCloudColumns = WordCloudColumns.getCategoricalColumns(this.visualUpdateOptions.dataViews[0]); let wordValueFormatter: IValueFormatter = null; diff --git a/src/behavior.ts b/src/behavior.ts index 0b366de..b6a195a 100644 --- a/src/behavior.ts +++ b/src/behavior.ts @@ -1,19 +1,14 @@ import powerbi from "powerbi-visuals-api"; import { Selection as d3Selection } from "d3-selection"; -import { Transition as d3Transition } from 'd3-transition'; import isArray from "lodash.isarray"; import flatten from "lodash.flatten"; import { WordCloudDataPoint } from "./dataInterfaces"; -import { pixelConverter as PixelConverter } from "powerbi-visuals-utils-typeutils"; - import ISelectionManager = powerbi.extensibility.ISelectionManager; import ISelectionId = powerbi.visuals.ISelectionId; type Selection = d3Selection; -type Transition = d3Transition; - export interface IWordCloudBehaviorOptions{ wordsSelection: Selection; @@ -24,9 +19,6 @@ export interface IWordCloudBehaviorOptions{ export class WordCloudBehavior { private behaviorOptions: IWordCloudBehaviorOptions; private selectionManager: ISelectionManager; - private durationAnimations: number = 50; - private static TheThirdLineHeight: string = PixelConverter.toString(14); // Note: This construction fixes bug #6343. - private static TheFourthLineHeight: string = PixelConverter.toString(15); // Note: This construction fixes bug #6343. private static MaxOpacity: number = 1; private static MinOpacity: number = 0.2; @@ -154,23 +146,5 @@ export class WordCloudBehavior { private setOpacity(element: Selection, opacityValue: number): void { element.style("fill-opacity", opacityValue); - - if (this.behaviorOptions.main) { // Note: This construction fixes bug #6343. - this.behaviorOptions.main.style("line-height", WordCloudBehavior.TheThirdLineHeight); - this.animateSelection(this.behaviorOptions.main, 0, this.durationAnimations) - .style("line-height", WordCloudBehavior.TheFourthLineHeight); - } - } - - private animateSelection>( - element: T, - duration: number = 0, - delay: number = 0, - callback?: (data: any, index: number) => void): Transition { - - return element.transition() - .delay(delay) - .duration(duration) - .on("end", callback); } } \ No newline at end of file