Implementation of ArcGIS Server Thematic Map

Source: Internet
Author: User
Recently, I have studied the implementation of the ArcGIS Server Web ADF (9.2) Thematic Map as follows (taking the bar chart as an example, the pie chart is similar to the histogram). I hope it will help you! // Obtain the layer ID of the topic.
..........
Int layerid = 3;

// Obtain the attribute name list of the topic graph analysis element.
String [] fieldname = new string [2];
Fieldname [0] = "pop1990 ";
Fieldname [1] = "pop1999 ";


// Obtain the layer object (featurelayer) of the topic graph analysis)
Agslocalmapresource res = (agslocalmapresource) This. webcontext
. Getresources (). Get ("ags0 ");
Mapserver = res. getlocalmapserver ();
Ilayer filayer = mapserver. getlayer (mapserver. getmapname (0), layerid );
Featurelayer flayer = (featurelayer) filayer;


// Create a chartrenderer object. Note: Use the createarcobject (string) method of the agslocalmapresource object to create an AO object in the Web ADF.
Chartrenderer chartrender = (chartrenderer) res
. Createarcobject (chartrenderer. getclsid ());

// Specify the Field Values in each column of the bar chart in irendererfileds.
Irendererfields rendererfields = chartrender;
Rendererfields. addfield (fieldname [0], null );
Rendererfields. setfieldalias (0, rendererfields. getfield (0 ));
Rendererfields. addfieldfieldname [1], null );
Rendererfields. setfieldalias (1, rendererfields. getfield (1 ));

// Find the maximum value required for each element's specified attribute
Queryfilter = (queryfilter) res
. Createarcobject (queryfilter. getclsid ());
Queryfilter. addfield (fieldname [0]);
Queryfilter. addfield (fieldname [1]);
Icursor cursor = flayer. itable_search (queryfilter, true );
Int numfields = 2; // Number of bar chart Columns
Int [] fieldindecies = new int [numfields];
Fieldindecies [0] = flayer. findfield (fieldname [0]);
Fieldindecies [1] = flayer. findfield (fieldname [1]);
Double maxvalue = 0;
Boolean firstvalue = true;
Irowbuffer ROW = cursor. nextrow ();
While (row! = NULL ){
String fieldvalue = "";
For (INT fieldindex = 0; fieldindex <numfields; fieldindex ++ ){
Double fieldvalue = double. parsedouble (row. getvalue (
Fieldindecies [fieldindex]). tostring ());
If (firstvalue ){
Maxvalue = fieldvalue;
Firstvalue = false;
}
If (fieldvalue> maxvalue)
Maxvalue = fieldvalue;
}
Row = cursor. nextrow ();
}


// Instantiate a chart object
Barchartsymbol = (barchartsymbol) res. createarcobject (barchartsymbol. getclsid ());

Ichartsymbol chartsymbol = barchartsymbol;
Barchartsymbol. setwidth (10 );
Imarkersymbol markersymbol = barchartsymbol;
Chartsymbol. setmaxvalue (maxvalue );
Markersymbol. setsize (60 );


// Set the fill color and line color of each column in the bar chart

Isymbolarray symbolarray = barchartsymbol;
Simplefillsymbol fillsymbol1 = (simplefillsymbol) res. createarcobject (simplefillsymbol. getclsid ());
Irgbcolor rgbcolor1 = (rgbcolor) res. createarcobject (rgbcolor. getclsid ());

Rgbcolor1.setred (255 );
Rgbcolor1.setgreen (0 );
Rgbcolor1.setblue (0 );
Rgbcolor1.setusewindowsdithering (true );

Ilinesymbol ilinesym1 = (ilinesymbol) res. createarcobject (simplelinesymbol. getclsid ());
Ilinesym1.setcolor (rgbcolor1 );
Ilinesym1.setwidth (1 );
Fillsymbol1.setoutline (ilinesym1 );

Fillsymbol1.setcolor (rgbcolor1 );
Barchartsymbol. addsymbol (fillsymbol1 );

Simplefillsymbol fillsymbol2 = (simplefillsymbol) res. createarcobject (simplefillsymbol. getclsid ());

Irgbcolor rgbcolor2 = (rgbcolor) res. createarcobject (rgbcolor. getclsid ());

Rgbcolor2.setred (238 );
Rgbcolor2.setgreen (1, 195 );
Rgbcolor2.setblue (235 );
Rgbcolor2.setusewindowsdithering (true );

Ilinesymbol ilinesym2 = (ilinesymbol) res. createarcobject (simplelinesymbol. getclsid ());
Ilinesym2.setcolor (rgbcolor2 );
Ilinesym2.setwidth (1 );
Fillsymbol2.setoutline (ilinesym2 );
Fillsymbol2.setcolor (rgbcolor2 );
Barchartsymbol. addsymbol (fillsymbol2 );

Chartrender. setchartsymbolbyref (chartsymbol );
Chartrender. setuseoverposter (false );
// Set the featurerenderer chartrenderer object
Flayer. setrendererbyref (chartrender );

// Refresh the Map Display chart
Map1.refresh ();
This. webcontext. Refresh ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.