Select to view content in your preferred language

Print Widget and Renderers with Functions

8024
17
05-10-2013 09:54 AM
DanielTrone
Deactivated User
I am using the print widget and have noticed an unusual issue.

When I use a function-formula in the renderer instead of a simple variable, the legend does not display normally, but instead displays only the symbols used for that area and the label 'Override' (see attachment).  Is this a bug? (Also see code snippet below).

Secondly, also when I am using a function formula in the renderer, and when I use a defaultSymbol instead of setting the first parameter of ClassBreaksRenderer to false, the print process will fail.

Thirdly, when I use a renderer with a simple variable, and no default symbol, it works, but my transparency is always opaque. (At least in the first situation, with the Override labels, the transparency is correct).

<CODE>
  if (themevar === 'PCT_OTH_R') {
   renderer = new esri.renderer.ClassBreaksRenderer(false, function (graphic) {
    return ((graphic.attributes.OTHER_NH / graphic.attributes.POP0711) * 100);
   });
   renderer.addBreak({
    minValue: 0,
    maxValue: 2,
    symbol: new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([239, 237, 245, 0.5])),
    label: "< 2%"
   });
   renderer.addBreak({
    minValue: 2,
    maxValue: 5,
    symbol: new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([188, 189, 220, 0.5])),
    label: "2% to 5%"
   });
   renderer.addBreak({
    minValue: 5,
    maxValue: Infinity,
    symbol: new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([117, 107, 177, 0.5])),
    label: "> 5%"
   });
   $('#titleleg').html('PCT Other');
  }
</CODE>

Here is a link to the working application to see the print behavior in action.

http://dola.colorado.gov/gis-cms/sites/default/files/html/acs0711_11.html

And here is the fiddle (sorry its so long, but still 1/5 size of original project).
http://jsfiddle.net/DanielTrone/e2yse/
0 Kudos
17 Replies
DanielTrone
Deactivated User
Thanks for the update.  It's good to know that it's not necessarily anything I'm doing wrong.  I've never had any formal javascript education, so sometimes I just assume my problems are a result of subtleties that I don't yet understand.

FWIW, I found an easy workaround to this problem via CSS:

    #legendDiv path{
    fill-opacity:0.6 !important;
    }


I hope this helps someone else out there!
0 Kudos
ChrisVradis
Deactivated User
Hello,
I am having the exact same problem - a feature layer with a function renderer. The legend appears fine with the Javascript API. When I try to print with the Print Task, the colours look fine (although not in correct order) but the name next to the symbol patch is replaced with the word "Override". In my case, the feature layer service on the server cannot access the data from which the renderer is created, since a) they are organized as numerous files not in a database and b) the algorithm that the break values are calculated runs in the browser (in javascript).

I was thinking about creating a class break and assign it temporarily to the feature layer, but I understand that access to data on the server is critical.

Are there any alternate solutions to this problem?  W

Thanks.
0 Kudos
BillLotz
Frequent Contributor
Hello, any idea if a fix is in the works for this?                                                                                                                                                           
sorry for the delayed reply.  i did some more testing and confirmed that this is a REST problem (as opposed to a problem in the JS API).  it seems that currently ArcGIS Server does not honor transparency defined as an alpha value within a RGB color symbol for feature service layers.

you can see this problem by removing the .TXT extension from the attached .webmap file (which has identical contents to the webmap JSON we pass to ArcGIS Server when printing) and dragging and dropping itdirectly into ArcMap.

"symbol" : {
    "color" : [0, 255, 0, 128], //128 (or 50% transparency) is replaced by 255
    "outline" : {
        "color" : [0, 0, 0, 128],  //128 (or 50% transparency) is replaced by 255
        "width" : 2,
        "type" : "esriSLS",
        "style" : "esriSLSSolid"
    },
    "type" : "esriSFS",
    "style" : "esriSFSSolid"
},

even though an alpha transparency of 128 is specified for the symbol fill color, the layer is completely opaque in ArcMap

[ATTACH=CONFIG]25482[/ATTACH]

since your sample app passes a collection of graphics instead of a feature service layer, you get around this limitation (but encounter another). 

ive asked the developers to update the Export Web Map Spec to acknowledge the limitation i found.  sorry for the inconvenience.
0 Kudos
JohnGravois
Deactivated User
Bill,

this is unfortunately still considered a known limit.  i went ahead and logged an issue requesting that it be revisited in the future on your behalf.

[NIM099543: Add support for transparency in color's alpha value when printing feature layers.]

sorry for the inconvenience.
0 Kudos
BillLotz
Frequent Contributor
Bill,

this is unfortunately still considered a known limit.  i went ahead and logged an issue requesting that it be revisited in the future on your behalf.

[NIM099543: Add support for transparency in color's alpha value when printing feature layers.]

sorry for the inconvenience.


Thanks. For some reason I thought this was fixed in 10.2.2, but I guess it isn't.
0 Kudos
ChrisSmith7
Honored Contributor

I'm having a similar problem - we have an application that is joining dynamic JSON data to a map service by a unique ID shared between the JSON dataset and the map service... everything works brilliantly in our application, although we ended-up creating a custom breaks function; however, when we "print" the map using the default template, the LegendLayer passed to the server ends-up overriding the break labels rendering in the application with "override 1", "override 2", etc., like what is seen in Daniel's attachment (exOverride.pdf).

The resolution, it seems from John Gravois' previous response, is to ensure the map service contains the field/data... unfortunately, this isn't an option for us. Has anyone had success with a workaround? My initial thought was to create a custom template where we could send an HTML object from the client-side (the object being the legend) - I haven't come across supporting documentation yet to pursue this... we are currently using the default print template.

Thanks!

0 Kudos
by Anonymous User
Not applicable

Same issue here...UniqueValueRenderer with a function. Plopping a client-side legend into the print layout would be very handy.

Long-shot but, in the Print Template task the API can accept 'customTextElements' in the layout options. Is there some way to draw SVG and labels that could get put into a snapshot and inserted as png into the print output?

davetinkle
Occasional Contributor

...coming up on 5 years and API version 4.6 still shows "Override 1" in the PDF print task output.

any fix, or even a work around?

any acknowledgement this is a bug, or a correction if not?

thanks.