Skip to content

Commit

Permalink
Revert "Linked Time: Removed old customVisTemplate that is no longer …
Browse files Browse the repository at this point in the history
…used" (#6060)

This reverts commit b08e2f8.

* Motivation for features / changes
I was wrong. This template is still used to shade out the area outside
of a range selection.
  • Loading branch information
JamesHollyer authored Nov 21, 2022
1 parent 47c1b57 commit cd3fa72
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
[useDarkMode]="useDarkMode"
(onViewBoxOverridden)="isViewBoxOverridden = $event"
(viewBoxChanged)="onLineChartZoom.emit($event)"
[customVisTemplate]="lineChartCustomVis"
[customChartOverlayTemplate]="lineChartCustomXAxisVis"
></line-chart>
<ng-template
Expand Down Expand Up @@ -181,6 +182,45 @@
</scalar-card-data-table>
</div>
</ng-container>
<ng-template
#lineChartCustomVis
let-viewExtent="viewExtent"
let-domDim="domDimension"
let-xScale="xScale"
>
<ng-container *ngIf="stepOrLinkedTimeSelection">
<div
[ngClass]="{
'out-of-selected-time': true,
start: true,
range: !!stepOrLinkedTimeSelection.end?.step
}"
[style.right]="
xScale.forward(
viewExtent.x,
[domDim.width, 0],
stepOrLinkedTimeSelection.start.step
) + 'px'
"
></div>
<div
*ngIf="stepOrLinkedTimeSelection.end?.step"
[ngClass]="{
'out-of-selected-time': true,
end: true,
range: true
}"
[style.left]="
xScale.forward(
viewExtent.x,
[0, domDim.width],
stepOrLinkedTimeSelection.end?.step
) + 'px'
"
></div>
</ng-container>
</ng-template>

<ng-template
#lineChartCustomXAxisVis
let-viewExtent="viewExtent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@
(onViewExtentReset)="viewBoxReset()"
(onInteractionStateChange)="onInteractionStateChange($event)"
></line-chart-interactive-view>
<div *ngIf="customVisTemplate" class="custom-vis">
<ng-container
[ngTemplateOutlet]="customVisTemplate"
[ngTemplateOutletContext]="{
xScale: xScale,
yScale: yScale,
domDimension: domDimensions.main,
viewExtent: viewBox
}"
></ng-container>
</div>
</div>
<div class="y-axis" #yAxis>
<line-chart-axis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ export class LineChartComponent
@ViewChild('chartEl', {static: false, read: ElementRef})
private chartEl?: ElementRef<HTMLCanvasElement | SVGElement>;

/**
* Optional ngTemplate that renders on top of line chart (not axis). This
* template is rendered on top of interactive layer and can mask other
* contents. Do note that this component may not intercept pointer-events.
*/
@Input()
customVisTemplate?: TemplateRef<TemplateContext>;

@Input()
customChartOverlayTemplate?: TemplateRef<
TemplateContext & {formatter: Formatter}
Expand Down

0 comments on commit cd3fa72

Please sign in to comment.