cms/app-client/app/components/visu-carto.js
author nowmad@23.1.168.192.in-addr.arpa
Thu, 17 Dec 2015 12:12:39 +0100
changeset 62 6fc7d50c6b5d
parent 51 70dff07a76ff
child 84 36f84e8f1ad5
permissions -rw-r--r--
remove unecessary svg icon and update the way we define the area to make it more automatic
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     1
import Ember from 'ember';
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     2
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     3
export default Ember.Component.extend({
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
     4
  // storage: Ember.inject.service(),
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     5
  didInsertElement: function(){
51
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents: 45
diff changeset
     6
    var _this = this;
62
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
     7
    // console.log("maps : ", AmCharts.maps);
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
     8
    //
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
     9
    // console.log('test: ', this.get("query"));
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
    10
    //
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
    11
    // this.get("sounds").map(item => {
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
    12
  	// 	console.log(item.get('title'));
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
    13
  	// });
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
    14
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    15
    var continentsDataProvider;
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    16
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    17
    var franceDataProvider = {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    18
        mapVar: AmCharts.maps.franceDepartmentsLow,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    19
        getAreasFromMap:true,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    20
62
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
    21
        areas: this.initArea(AmCharts.maps.franceDepartmentsLow)
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    22
    };
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    23
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    24
    var worldDataProvider = {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    25
        map: "worldLow",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    26
        getAreasFromMap: true,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    27
        images: [{
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    28
            id: "backButton",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    29
            label: "Back to continents map",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    30
            rollOverColor: "#CC0000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    31
            labelRollOverColor: "#CC0000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    32
            useTargetsZoomValues: true,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    33
            left: 30,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    34
            bottom: 30,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    35
            labelFontSize: 15,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    36
            selectable: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    37
        }],
62
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
    38
        areas: this.initArea(AmCharts.maps.worldLow, franceDataProvider)
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    39
    };
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    40
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    41
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
    42
    var continentsDataProvider = {
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    43
        map: "continentsLow",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    44
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    45
        areas: [{
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    46
            id: "africa",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    47
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    48
            color: "#7CACAE",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    49
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    50
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    51
            id: "asia",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    52
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    53
            color: "#E0EEEF",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    54
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    55
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    56
            id: "australia",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    57
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    58
            color: "#E0EEEF",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    59
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    60
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    61
            id: "europe",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    62
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    63
            color: "#2D7073",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    64
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    65
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    66
            id: "north_america",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    67
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    68
            color: "#B0D1D3",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    69
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    70
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    71
            id: "south_america",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    72
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    73
            color: "#E0EEEF",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    74
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    75
        }]
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    76
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    77
    };
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    78
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    79
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    80
    var map = AmCharts.makeChart("mapdiv", {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    81
        type: "map",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    82
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    83
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    84
        areasSettings: {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    85
            autoZoom: true,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    86
            rollOverOutlineColor: "#000000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    87
            selectedOutlineColor: "#CC0000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    88
            selectedColor: "green",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    89
            color: "#E0EEEF"
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    90
        },
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    91
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    92
        dataProvider: continentsDataProvider
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    93
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    94
    });
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    95
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    96
    function handleGoHome() {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    97
        map.dataProvider = continentsDataProvider;
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    98
        map.validateNow();
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    99
    }
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
   100
    function handleMapObjectClick (event) {
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
   101
        if (event.mapObject.id == "backButton") {
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   102
            handleGoHome();
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   103
        }
51
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents: 45
diff changeset
   104
        _this.sendAction('action', event.mapObject.title);
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   105
    }
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   106
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   107
    // monitor when home icon was clicked and also go to continents map
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   108
    map.addListener("homeButtonClicked", handleGoHome);
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   109
    map.addListener("clickMapObject", handleMapObjectClick);
62
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   110
  },
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   111
  initArea: function(area, dataProvider){
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   112
    var _this = this;
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   113
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   114
    var areaList = [];
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   115
    var count = {};
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   116
    area.svg.g.path.map(function(elt, index){
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   117
      var length = _this.get("sounds").filterBy("spatial", elt.title).toArray().length;
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   118
      if (length > 0)
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   119
        count[elt.id]= length;
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   120
    });
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   121
    area.svg.g.path.map(function(elt, index){
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   122
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   123
      areaList.push({
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   124
        id: elt.id,
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   125
        linkToObject: (elt.id === "FR" ? dataProvider : ""),
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   126
        color: ((typeof(count[elt.id]) === "undefined") ? "#E0EEEF" : "#2D7073"),
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   127
        autoZoom: (elt.id === "FR" ? true : false),
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   128
        selectable: true,
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   129
        passZoomValuesToTarget: false
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   130
      });
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   131
    });
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   132
    return areaList;
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   133
  }
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   134
});