When I add a label to a chart with the following:
fieldInfos: [{
fieldName: "hosp_beds",
label: "Total Beds"
},{
fieldName: "icu_beds",
label: "ICU Beds"
}],
The data element passed has the following values.
hosp_beds: "<span class='esriNumericValue'>32</span>"
icu_beds: "<span class='esriNumericValue'>3</span>"
This is fine for just labels but I process the data elements and I expect a number only and not html tags. This didn't happen prior to 3.10. Any idea if this is a bug or a change?
Working with this sample: ArcGIS API for JavaScript Sandbox , I do not encounter the problem you are describing. I added the following lines of code to the application:
map.on("click" ,function(evt) {
console.log(map.infoWindow.features[0].attributes);
});
The attributes are displayed with name value pairs without any HTML formatting. Is there anything I am doing wrong?
Nicholas,
Thanks for the reply. Yes. I get the same results in my example. In the original layer data there is no formatting markup. However, for some reason when you pass the value to a javascript function within the popup the formatting is there for anything you have a label for. I have this for the description:
"Address: {hosp_street} <br/> ICU/Total Beds: {ICUCOMP:icucomp}"
The markup is passed to my icucomp function on anything I have a label specified for in my chart. Here is my icucomp function:
function icucomp(value, key, data) {
console.log("icucomp ", data)
return (data.icu_beds / data.hosp_beds).toFixed(3);
}
If I go back to ArcGIS javascript version 3.8 it doesn't include the formatting. However when I paste my code using my service into the sandbox it works fine. I am at a loss now since I just copy and pasted and it is working as expected in the sandbox. Any ideas on what could cause the difference?
Not sure if this is the difference but the Sandbox is using version 3.12.
I saw that and updated my to 3.12 and hoped that would resolve but still no luck.
Would it be possible to post your code to JSFiddle or zip it up and post it here?
This is strange. When I run the attached test on my machine it does the same thing as mine, it puts the formatting inline. If I run it in the sandbox it works fine. I ran it on three different web servers locally, apache, iisexpress, and IIS all give the the same result of putting the formatting inline. When I change back to 3.8 it works fine. I put a calculation in the sample. The calculation produces NaN on my webservers and the correct result in the sandbox. What happens if you run this file locally?
I spent some time testing this yesterday. Your code produces NaN on my local server and in the sandbox. I don't know if this is expected behavior or not. I did produce a workaround for this issue though. The following is the calcit function I use in my application (note that it uses jQuery):
function calcit(value, key, data) {
var number_Fin = $.parseHTML( data.Number_Fin );
var number_Sta = $.parseHTML( data.Number_Sta );
return (number_Fin[0].innerHTML / number_Sta[0].innerHTML).toFixed(3);
}
Yes. NaN is what is expected when the html tags are returned for the formatted values. So is this a bug since 3.8? Do you know what changed then to make the labels return tags? I am using a regex to get rid of the html tags so I can work around the new behavior.