AnsweredAssumed Answered

How to set up text in PopupTempalte (A divided by B)

Question asked by zhouleizhou on Aug 8, 2016
Latest reply on Aug 8, 2016 by thejus.kambi

I need to set up some percentage values in PopupTemplate (esri/dijit/PopupTemplate) using two fields (fieldA is divided by fieldB). See “description” part below (percentage 1, 2, 3, 4, 5): All the fields are defined, the chart works well. But the text in “description” just did not display any the calculation by me. I also tried {“Age_Under_5”/ “Pop_Total “},  not working either. Thanks!

 

var popupTemplateUpdated2 = new PopupTemplate({
             title: "Population by Age",
        description: "Total Population is <b>{Pop_Total}</b>, "
          + "Percentage 1 <b>{Age_Under_5/Pop_Total }</b>; "
          + " Percentage 2 <b>{Age_5to17/Pop_Total }</b>; "
          + " Percentage 3 <b>{Age_18to34/Pop_Total }</b>; "
          + " Percentage 4 <b>{Age_35to64/Pop_Total }</b>; "
          + " Percentage 5 <b>{Age_65plus/Pop_Total }</b>; ",
        mediaInfos: [{
          type: "piechart",
          value: {
            fields: ["Age_Under_5", "Age_5to17", "Age_18to34", "Age_35to64", "Age_65plus"]
          }
        }],
        fieldInfos: [{
          fieldName: "Age_Under_5",
          label: "< 5 Yrs",
          format: { places: 0, digitSeparator: true }  
        }, {
          fieldName: "Age_5to17",
          label: " 5 - 17",
          format: { places: 0, digitSeparator: true }  
        }, {
          fieldName: "Age_18to34",
          label: "18 - 34",
          format: { places: 0, digitSeparator: true }  
        }, {
          fieldName: "Age_35to64",
          label: "35 - 64",
          format: { places: 0, digitSeparator: true }  
        }, {
          fieldName: "Age_65plus",
          label: "> 65",
          format: { places: 0, digitSeparator: true }  
        }]
          });

Outcomes