in src/visual.ts [551:629]
public update(options: VisualUpdateOptions): void {
if (!options
|| !options.dataViews
|| !options.dataViews[0]
|| !options.dataViews[0].categorical
) {
this.clearData();
return;
}
this.viewport = StreamGraph.getViewport(options.viewport);
this.dataView = options.dataViews[0];
if (options.type !== VisualUpdateType.Resize && options.type !== VisualUpdateType.ResizeEnd) {
this.data = StreamGraph.converter(
this.dataView,
this.colorPalette,
this.interactivityService,
this.visualHost
);
}
if (!this.data
|| !this.data.series
|| !this.data.series.length
) {
this.clearData();
return;
}
this.renderLegend(this.data);
this.updateViewport();
this.svg.attr("width", PixelConverter.toString(this.viewport.width));
this.svg.attr("height", PixelConverter.toString(this.viewport.height));
const values: DataViewValueColumns = this.dataView.categorical.values;
const hasHighlights: boolean = !!(values.length > 0 && values[0].highlights);
const selection: Selection<d3.BaseType, StreamGraphSeries, any, any> = this.renderChart(
this.data.series,
this.data.stackedSeries,
StreamGraph.AnimationDuration,
hasHighlights
);
this.calculateAxes();
this.tooltipServiceWrapper.addTooltip(
selection,
(tooltipEvent: TooltipEventArgs<d3.Series<any, any>>) => {
const index: number = tooltipEvent.data.index;
const tooltipInfo: VisualTooltipDataItem[] = this.data.series[index].tooltipInfo;
return tooltipInfo.length > 0
? tooltipInfo
: null;
});
const interactivityService: IInteractivityService = this.interactivityService;
if (interactivityService) {
const behaviorOptions: BehaviorOptions = {
selection,
interactivityService,
clearCatcher: this.clearCatcher,
series: this.data.series
};
interactivityService.bind(
this.data.series,
this.behavior,
behaviorOptions
);
this.behavior.renderSelection(false);
}
}