cms/app-client/app/components/visu-carto.js
author nowmad@nowmads-macbook-pro.local
Fri, 15 Jan 2016 15:49:42 +0100
changeset 84 36f84e8f1ad5
parent 62 6fc7d50c6b5d
child 91 acfeddc7821d
permissions -rw-r--r--
add d3js for langue visu add modal update css
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;
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
     7
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     8
    var continentsDataProvider;
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     9
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    10
    var franceDataProvider = {
84
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    11
        mapVar: AmCharts.maps.france2016Low,
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    12
        getAreasFromMap:true,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    13
84
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    14
        areas: this.initArea(AmCharts.maps.france2016Low)
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    15
    };
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 worldDataProvider = {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    18
        map: "worldLow",
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
        images: [{
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    21
            id: "backButton",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    22
            label: "Back to continents map",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    23
            rollOverColor: "#CC0000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    24
            labelRollOverColor: "#CC0000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    25
            useTargetsZoomValues: true,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    26
            left: 30,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    27
            bottom: 30,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    28
            labelFontSize: 15,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    29
            selectable: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    30
        }],
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
    31
        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
    32
    };
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    33
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    34
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
    35
    var continentsDataProvider = {
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    36
        map: "continentsLow",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    37
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    38
        areas: [{
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    39
            id: "africa",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    40
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    41
            color: "#7CACAE",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    42
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    43
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    44
            id: "asia",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    45
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    46
            color: "#E0EEEF",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    47
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    48
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    49
            id: "australia",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    50
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    51
            color: "#E0EEEF",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    52
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    53
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    54
            id: "europe",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    55
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    56
            color: "#2D7073",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    57
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    58
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    59
            id: "north_america",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    60
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    61
            color: "#B0D1D3",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    62
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    63
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    64
            id: "south_america",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    65
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    66
            color: "#E0EEEF",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    67
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    68
        }]
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    69
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
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    72
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    73
    var map = AmCharts.makeChart("mapdiv", {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    74
        type: "map",
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
        areasSettings: {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    78
            autoZoom: true,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    79
            rollOverOutlineColor: "#000000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    80
            selectedOutlineColor: "#CC0000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    81
            selectedColor: "green",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    82
            color: "#E0EEEF"
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
84
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    85
        dataProvider: continentsDataProvider,
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    86
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    87
        listeners: [{event:"clickMapObject", method:handleMapObjectClick}]
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    88
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    89
    });
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
    function handleGoHome() {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    92
        map.dataProvider = continentsDataProvider;
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    93
        map.validateNow();
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    94
    }
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
    95
    function handleMapObjectClick (event) {
84
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    96
      console.log("bbox: ", event.mapObject.displayObject.node.getBBox());
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    97
      // console.log("event", event);
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    98
      // console.log("originalTarget", event.event.originalTarget);
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    99
      // console.log("getTotalLength", event.event.originalTarget.getTotalLength());
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
   100
      // console.log("getBBox", event.event.originalTarget.getBBox());
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
   101
      // console.log("event", event.event.originalTarget.attributes[1].d);
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
   102
        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
   103
            handleGoHome();
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   104
        }
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
   105
        _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
   106
    }
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   107
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   108
    // 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
   109
    map.addListener("homeButtonClicked", handleGoHome);
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
});