3

I googled this for a long time now . I am looking for a way to draw or add charts on map in any way. I am using DynamicLayer and can query on any field and any layer but the is no way to draw charts. There is InfoWindow/MapTip but it needs clicking on the map and that is not what we are looking for because of the clicking and mouse over need.

enter image description here

Something like this.

2

Well...since there is no feature in JSAPI satisfying the need, I created a server-side solution for making the charts and the drawing it using "esri/symbols/SimpleMarkerSymbol" . enter image description here I explain the solution step by step.

First of all I make the charts using System.Web.UI.DataVisualization.Charting on server-side code. This will save the png files on a specific folder in the solution . (The code for creating charts using this class is out there , so I did not provide any undue code )

string FileStr = LpInfo[i].ObjId + "_" + LayerName + ".png";
chart1.SaveImage(AppRoot + FileStr,ChartImageFormat.Png);

I save the png files using objectId and the LayerName separated with underline character to address the files. After creating the charts, I just need to query through the Layer and draw the pngs using "esri/symbols/SimpleMarkerSymbol". To draw each chart for each feature I just need to make an address for the files.for example :

var markerUrl = "images/PngCharts/" + PreFolderN +   
features[i].attributes[ObjIdFieldName] + "_" + LayerName + ".PNG";

This solution has 2 parts. So if you want to make it happen an one click, I suggest you to create a webmethod to create the charts and then in the callBack, query through the requested LayerName and draw the charts.

I should mention that this solution is not the only way of doing that but it's the easiest method I could think of. It does have the flexibility and it is fast enough. So if anyone can provide a better solution I would be happy to read that!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.