bubble maps component refactoring

This commit is contained in:
nixa 2016-05-16 13:05:17 +03:00
parent 49b545ec32
commit 17846aa08a
4 changed files with 42 additions and 237 deletions

View file

@ -1,51 +1,27 @@
import {Component, ViewEncapsulation} from '@angular/core';
import {BaCard} from '../../../../theme/components';
import {BaAmChart} from '../../../../theme/components';
import {layoutPaths} from "../../../../theme/theme.constants";
import {BubbleMapsService} from "./bubbleMaps.service";
require('ammap3');
require('ammap3/ammap/maps/js/worldLow');
// TODO: use baAmChart instead of this
@Component({
selector: 'bubble-maps',
pipes: [],
providers: [BubbleMapsService],
// otherwise maps won't work
encapsulation: ViewEncapsulation.None,
styles: [require('ammap3/ammap/ammap.css'), require('./bubbleMaps.scss')],
directives: [BaCard],
directives: [BaCard, BaAmChart],
styles: [require('./bubbleMaps.scss')],
template: require('./bubbleMaps.html'),
})
export class BubbleMaps {
chartData:Object;
constructor(private _bubbleMapsService:BubbleMapsService) {
}
ngAfterViewInit() {
AmCharts.theme = this._bubbleMapsService.getTheme();
ngOnInit() {
let map = new AmCharts.AmMap();
map.addTitle('Population of the World in 2011', 14);
map.addTitle('source: Gapminder', 11);
map.areasSettings = {
unlistedAreasColor: '#000000',
unlistedAreasAlpha: 0.1
};
map.imagesSettings.balloonText = '<span style="font-size:14px;"><b>[[title]]</b>: [[value]]</span>';
map.pathToImages = layoutPaths.images.amMap;
let dataProvider = {
mapVar: AmCharts.maps.worldLow,
images: []
};
map.dataProvider = this._bubbleMapsService.getDataProvider(dataProvider);
map.export = {
enabled: true
};
map.write('map-bubbles');
this.chartData = this._bubbleMapsService.getData();
}
}