Maybe someone can spot what I'm missing. I have a popupTemplate based on data that is from a linked table. I am creating a pie chart. All the values for the chart are in the join table, and from the layer, I just need county name. Both the layer and the table are in a file geodatabase.
If I create a plain infoTemplate, defined as
var genericInfoTemplate = new InfoTemplate("generic", "${*}");
I can see all the values I want, both from the layer and the joined table. The county name is available as county.COUNTYNAME
Here is my rest endpoint:
Layer: Veteran Population by Race - current (ID: 2)
Here is how I'm trying to defined my popupTemplate:
var raceTemplate = new PopupTemplate({ title: "{county.COUNTYNAME}: Current Veteran Population by Race", fieldInfos: [{ fieldName: "VetPop_current_Race.EstAsianVetPop", visible: true, format: { places: 0 }, label:"Asian" },{ fieldName: "VetPop_current_Race.EstBlackVetPop", visible: true, format: { places: 0 }, label:"Black" },{ fieldName: "VetPop_current_Race.EstHispanicVetPop", visible: true, format: { places: 0 }, label:"Hispanic" },{ fieldName: "VetPop_current_Race.EstWhiteVetPop", visible: true, format: { places: 0 }, label:"White" },{ fieldName: "VetPop_current_Race.EstMultiRaceVetPop", visible: true, format: { places: 0 }, label:"Multi-Race" },{ fieldName: "VetPop_current_Race.EstOtherVetPop", visible: true, format: { places: 0 }, label:"Other" }], mediaInfos: [{ type: "piechart", caption: "Hover to see value for each race", value: { fields: [ "VetPop_current_Race.EstMultiRaceVetPop", "VetPop_current_Race.EstOtherVetPop", "VetPop_current_Race.EstWhiteVetPop" , "VetPop_current_Race.EstBlackVetPop", "VetPop_current_Race.EstHispanicVetPop", "VetPop_current_Race.EstAsianVetPop" ] , theme: "PrimaryColors" } }] });
Besides not using PopupTemplates very often, this is also the first time I've defined infoTemplates in an ArcGISDynamicMapServiceLayer using myLayername.setInfoTemplates. I don't know if that makes any difference or not.
Solved! Go to Solution.
Tracy,
You just needed to include the county.COUNTYNAME field in your fieldInfos array
var raceTemplate = new PopupTemplate({ title: "{county.COUNTYNAME}: Current Veteran Population by Race", fieldInfos: [{ fieldName: "VetPop_current_Race.EstAsianVetPop", visible: true, format: { places: 0 }, label: "Asian" }, { fieldName: "VetPop_current_Race.EstBlackVetPop", visible: true, format: { places: 0 }, label: "Black" }, { fieldName: "VetPop_current_Race.EstHispanicVetPop", visible: true, format: { places: 0 }, label: "Hispanic" }, { fieldName: "VetPop_current_Race.EstWhiteVetPop", visible: true, format: { places: 0 }, label: "White" }, { fieldName: "VetPop_current_Race.EstMultiRaceVetPop", visible: true, format: { places: 0 }, label: "Multi-Race" }, { fieldName: "VetPop_current_Race.EstOtherVetPop", visible: true, format: { places: 0 }, label: "Other" }, { fieldName: "county.COUNTYNAME", visible: false }], mediaInfos: [{ type: "piechart", caption: "Hover to see value for each race", value: { fields: [ "VetPop_current_Race.EstMultiRaceVetPop", "VetPop_current_Race.EstOtherVetPop", "VetPop_current_Race.EstWhiteVetPop", "VetPop_current_Race.EstBlackVetPop", "VetPop_current_Race.EstHispanicVetPop", "VetPop_current_Race.EstAsianVetPop" ], theme: "PrimaryColors" } }] });
Tracy,
You just needed to include the county.COUNTYNAME field in your fieldInfos array
var raceTemplate = new PopupTemplate({ title: "{county.COUNTYNAME}: Current Veteran Population by Race", fieldInfos: [{ fieldName: "VetPop_current_Race.EstAsianVetPop", visible: true, format: { places: 0 }, label: "Asian" }, { fieldName: "VetPop_current_Race.EstBlackVetPop", visible: true, format: { places: 0 }, label: "Black" }, { fieldName: "VetPop_current_Race.EstHispanicVetPop", visible: true, format: { places: 0 }, label: "Hispanic" }, { fieldName: "VetPop_current_Race.EstWhiteVetPop", visible: true, format: { places: 0 }, label: "White" }, { fieldName: "VetPop_current_Race.EstMultiRaceVetPop", visible: true, format: { places: 0 }, label: "Multi-Race" }, { fieldName: "VetPop_current_Race.EstOtherVetPop", visible: true, format: { places: 0 }, label: "Other" }, { fieldName: "county.COUNTYNAME", visible: false }], mediaInfos: [{ type: "piechart", caption: "Hover to see value for each race", value: { fields: [ "VetPop_current_Race.EstMultiRaceVetPop", "VetPop_current_Race.EstOtherVetPop", "VetPop_current_Race.EstWhiteVetPop", "VetPop_current_Race.EstBlackVetPop", "VetPop_current_Race.EstHispanicVetPop", "VetPop_current_Race.EstAsianVetPop" ], theme: "PrimaryColors" } }] });
Thanks - now I'm trying to include a description under the title. This is just a string, not pulling from a value. When I add this, it only loads my title and my chart, but none of the values.
This seems to match the examples. I'm adding it right below the title:
var raceTemplate = new PopupTemplate({
title: "{county.COUNTYNAME}: Current Veteran Population by Race",
description: "Population values for 2015",
fieldInfos: [{
....
Tracy,
It is either or. You can use description or if you do not use description then the popup will use the fieldinfos that are set to visible and display those in a table layout format. If you want to add some static text as a description then you have to add all your field values text to the description as well.
Here is a example (just using Asian):
var popupDescTemplate = 'Population values for 2015<br><table class="attrTable" cellpadding=0px" cellspacing="0px"><tbody>' + '<tr valign="top"><td class="attrName">Asian</td><td class="attrValue">{VetPop_current_Race.EstAsianVetPop}</td></tr>' + '</tbody></table>'; var raceTemplate = new PopupTemplate({ title: "{county.COUNTYNAME}: Current Veteran Population by Race", description: popupDescTemplate, fieldInfos: [{ fieldName: "VetPop_current_Race.EstAsianVetPop", visible: true, format: { places: 0 }, label: "Asian" }, { fieldName: "VetPop_current_Race.EstBlackVetPop", visible: true, format: { places: 0 }, label: "Black" }, { fieldName: "VetPop_current_Race.EstHispanicVetPop", visible: true, format: { places: 0 }, label: "Hispanic" }, { fieldName: "VetPop_current_Race.EstWhiteVetPop", visible: true, format: { places: 0 }, label: "White" }, { fieldName: "VetPop_current_Race.EstMultiRaceVetPop", visible: true, format: { places: 0 }, label: "Multi-Race" }, { fieldName: "VetPop_current_Race.EstOtherVetPop", visible: true, format: { places: 0 }, label: "Other" }, { fieldName: "county.COUNTYNAME", visible: false }], mediaInfos: [{ type: "piechart", caption: "Hover to see value for each race", value: { fields: [ "VetPop_current_Race.EstMultiRaceVetPop", "VetPop_current_Race.EstOtherVetPop", "VetPop_current_Race.EstWhiteVetPop", "VetPop_current_Race.EstBlackVetPop", "VetPop_current_Race.EstHispanicVetPop", "VetPop_current_Race.EstAsianVetPop" ], theme: "PrimaryColors" } }] });
I was hoping for something obvious I wasn't seeing, but at least there's a way to have both.