Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy render code, re-enable variation icons #146

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/D3 Plotting Functions/drawPlot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as d3 from "d3";
import viewModelClass from "../Classes/viewModelClass";
import drawXAxis from "./drawXAxis";
import drawYAxis from "./drawYAxis";
import drawTooltipLine from "./drawTooltipLine";
import drawLines from "./drawLines";
import drawDots from "./drawDots";
import drawIcons from "./drawIcons";

type SelectionBase = d3.Selection<SVGGElement, unknown, null, undefined>;

export default function drawPlot(selection: SelectionBase, viewModel: viewModelClass) {
selection.attr("width", viewModel.plotProperties.width)
.attr("height", viewModel.plotProperties.height)
.call(drawXAxis, viewModel)
.call(drawYAxis, viewModel)
.call(drawTooltipLine, viewModel)
.call(drawLines, viewModel)
.call(drawDots, viewModel)
.call(drawIcons, viewModel)
}
6 changes: 0 additions & 6 deletions src/D3 Plotting Functions/index.ts

This file was deleted.

13 changes: 4 additions & 9 deletions src/visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ import IVisualEventService = powerbi.extensibility.IVisualEventService;
import viewModelClass from "./Classes/viewModelClass"
import { plotData } from "./Classes/viewModelClass";
import * as d3 from "d3";
import * as plottingFunctions from "./D3 Plotting Functions"
import highlight from "./D3 Plotting Functions/highlight";
import plotPropertiesClass from "./Classes/plotPropertiesClass";
import drawPlot from "./D3 Plotting Functions/drawPlot";

export class Visual implements IVisual {
private host: IVisualHost;
private svg: d3.Selection<SVGSVGElement, unknown, null, undefined>;
private objectsToPlot: string[] = ["xAxis", "yAxis", "tooltipLine", "lines", "dots", "icons"];
private viewModel: viewModelClass;
private selectionManager: ISelectionManager;
// Service for notifying external clients (export to powerpoint/pdf) of rendering status
Expand All @@ -31,15 +30,16 @@ export class Visual implements IVisual {
constructor(options: VisualConstructorOptions) {
console.log("Constructor start")
console.log(options)

this.svg = d3.select(options.element).append("svg");
this.events = options.host.eventService;
this.host = options.host;
this.viewModel = new viewModelClass();
this.viewModel.firstRun = true;

this.selectionManager = this.host.createSelectionManager();

this.selectionManager.registerOnSelectCallback(() => this.updateHighlighting());

console.log("Constructor finish")
}

Expand All @@ -53,12 +53,7 @@ export class Visual implements IVisual {
this.viewModel.update({ options: options, host: this.host });

console.log("Draw plot")
this.svg.attr("width", this.viewModel.plotProperties.width)
.attr("height", this.viewModel.plotProperties.height);
this.objectsToPlot.forEach(plotObject => {
this.svg.call(plottingFunctions[plotObject as keyof typeof plottingFunctions],
this.viewModel)
})
this.svg.call(drawPlot, this.viewModel)

if (this.viewModel.plotProperties.displayPlot) {
this.addDotsInteractivity();
Expand Down
Loading