[Geojs-users] Question about LegendWidget
Olsen.Erik
Olsen.Erik at ensco.com
Thu Dec 15 13:44:48 EST 2016
Jon,
Thanks for the quick response on this, that fixed my problem. Also, just wondering is there a way to add a title to the default legendWidget? Or would I need to extend it and write custom code in order to do that?
Thanks,
Erik
From: Jonathan Beezley [mailto:jonathan.beezley at kitware.com]
Sent: Thursday, December 15, 2016 12:09 PM
To: Olsen.Erik <Olsen.Erik at ensco.com>
Cc: geojs-users at public.kitware.com
Subject: Re: [Geojs-users] Question about LegendWidget
Hi Erik,
The legend predates when we were attempting to normalize how colors are represented. It looks like it expects a valid CSS representation of color. You can use the method geo.util.convertColorToHex<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_OpenGeoscience_geojs_blob_master_src_util_init.js-23L305&d=CwMFaQ&c=DsZY2bea7iNIzyp-7sZ0t0F2UfNQZUfZhEPCv_2wBI0&r=sdAMZxqAoPTtVpp0WTsUGE05dS9lBt3NjsK7CxSH_Bc&m=Hy-tQTuLetyz8nCqNejq9Io68RW4huSJDI2WADFlvbM&s=H_DU9f2z_BZkqjS47SJk7eRIDrX7lx_5EBLjX3LckI8&e=> to convert anything accepted elsewhere in geojs to a hex string.
Jon
On Thu, Dec 15, 2016 at 11:29 AM, Olsen.Erik <Olsen.Erik at ensco.com<mailto:Olsen.Erik at ensco.com>> wrote:
All,
I have been trying to set a custom color for my rectangles in a LegendWidget I am using. I was looking into the provided example code that said that the fillColor could be a string or object. Is there an example of how the fillColor object should be constructed?
Here is some example code of what I’m trying to do:
Note that the uilayer is a reference to a layer that I already made before instantiating the legendWidget.
var legend = uilayer.createWidget('legend', {
position : {
bottom : 0,
right: 0
}
});
legend.categories([{
name : "Test",
style: {
fill : true,
fillColor: {'r' : 1, 'b' : 1, 'g': 0}
},
type : 'rect'
}]);
I was under the assumption that the color object would be an rgb object with values 0 to 1 as I have seen in other places in the geo.js code (specifically the geoJson reader)
Any help would be appreciated.
Thanks,
Erik
________________________________
The information contained in this email message is intended only for the use of the individual(s) to whom it is addressed and may contain information that is privileged and sensitive. If you are not the intended recipient, or otherwise have received this communication in error, please notify the sender immediately by email at the above referenced address and note that any further dissemination, distribution or copying of this communication is strictly prohibited.
The U.S. Export Control Laws regulate the export and re-export of technology originating in the United States. This includes the electronic transmission of information and software to foreign countries and to certain foreign nationals. Recipient agrees to abide by these laws and their regulations -- including the U.S. Department of Commerce Export Administration Regulations and the U.S. Department of State International Traffic in Arms Regulations -- and not to transfer, by electronic transmission or otherwise, any content derived from this email to either a foreign national or a foreign destination in violation of such laws.
_______________________________________________
Geojs-users mailing list
Geojs-users at public.kitware.com<mailto:Geojs-users at public.kitware.com>
http://public.kitware.com/mailman/listinfo/geojs-users<https://urldefense.proofpoint.com/v2/url?u=http-3A__public.kitware.com_mailman_listinfo_geojs-2Dusers&d=CwMFaQ&c=DsZY2bea7iNIzyp-7sZ0t0F2UfNQZUfZhEPCv_2wBI0&r=sdAMZxqAoPTtVpp0WTsUGE05dS9lBt3NjsK7CxSH_Bc&m=Hy-tQTuLetyz8nCqNejq9Io68RW4huSJDI2WADFlvbM&s=AzwwU4RVNu996YFGolsLS-j2MMiuGb7L3RZW3jkr9lo&e=>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/geojs-users/attachments/20161215/9aacc58e/attachment-0001.html>
More information about the Geojs-users
mailing list