Skip to content

Instantly share code, notes, and snippets.

@amahdy
Created March 24, 2016 21:05
Show Gist options
  • Save amahdy/0a70ad3f201453183e42 to your computer and use it in GitHub Desktop.
Save amahdy/0a70ad3f201453183e42 to your computer and use it in GitHub Desktop.
import {Directive, ViewContainerRef} from 'angular2/core';
/*
* This directive aims to overcome the current issues in integrating vaadin-bar-chart to an Angular 2 app.
*/
@Directive({
selector: 'vaadin-bar-chart'
})
export class VaadinBarChart {
constructor(public viewContainer: ViewContainerRef) {
const chart = viewContainer.element.nativeElement;
var selector = "vaadin-bar-chart";
var localDoms = ["chart-title", "subtitle", "x-axis", "y-axis", "tooltip", "plot-options", "legend", "data-series"];
for(var ld of localDoms) {
var localDom = chart.querySelector(ld + ":not(." + selector + ")");
if (localDom) {
Polymer.dom(chart).appendChild(localDom);
}
}
chart.reloadConfiguration();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment