Skip to content

Commit

Permalink
Remove animation
Browse files Browse the repository at this point in the history
  • Loading branch information
kullJul committed May 31, 2024
1 parent b3a571b commit 7d958ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 47 deletions.
26 changes: 5 additions & 21 deletions src/WordCloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -80,7 +78,6 @@ import { VisualLayout } from "./VisualLayout";
import { WordCloudColumns } from "./WordCloudColumns";
import {IWordCloudBehaviorOptions, WordCloudBehavior} from "./behavior";

type Transition<T1, T2 = T1> = d3Transition<any, T1, any, T2>;
type Selection<T1, T2 = T1> = d3Selection<any, T1, any, T2>;

type WordMap = { [word: string]: boolean };
Expand Down Expand Up @@ -368,7 +365,6 @@ export class WordCloud implements IVisual {

private data: WordCloudData;
private colorPalette: IColorPalette;
private durationAnimations: number = 50;

private specialViewport: IViewport;

Expand Down Expand Up @@ -1400,17 +1396,17 @@ export class WordCloud implements IVisual {
.selectAll("g")
.data(wordCloudDataView.data);

const wordGroupSelectionMerged: Selection<WordCloudDataPoint> = this.wordsGroupSelection
const wordGroupSelectionMerged: Selection<WordCloudDataPoint> = 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()
Expand All @@ -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));

Expand Down Expand Up @@ -1516,18 +1512,6 @@ export class WordCloud implements IVisual {
return formattingModel;
}

private animateSelection<T extends Selection<any>>(
element: T,
duration: number = 0,
delay: number = 0,
callback?: (data: any, index: number) => void): Transition<any> {

return element.transition()
.delay(delay)
.duration(duration)
.on("end", callback);
}

private renderTooltip(selection: Selection<WordCloudDataPoint>): void {
const categorical: WordCloudColumns<DataViewCategoryColumn> = WordCloudColumns.getCategoricalColumns(this.visualUpdateOptions.dataViews[0]);
let wordValueFormatter: IValueFormatter = null;
Expand Down
26 changes: 0 additions & 26 deletions src/behavior.ts
Original file line number Diff line number Diff line change
@@ -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<T1, T2 = T1> = d3Selection<any, T1, any, T2>;
type Transition<T1, T2 = T1> = d3Transition<any, T1, any, T2>;


export interface IWordCloudBehaviorOptions{
wordsSelection: Selection<WordCloudDataPoint>;
Expand All @@ -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;

Expand Down Expand Up @@ -154,23 +146,5 @@ export class WordCloudBehavior {

private setOpacity(element: Selection<any>, 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<T extends Selection<any>>(
element: T,
duration: number = 0,
delay: number = 0,
callback?: (data: any, index: number) => void): Transition<any> {

return element.transition()
.delay(delay)
.duration(duration)
.on("end", callback);
}
}

0 comments on commit 7d958ae

Please sign in to comment.