[Geojs-users] Question about LegendWidget

Jonathan Beezley jonathan.beezley at kitware.com
Thu Dec 15 12:09:21 EST 2016


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://github.com/OpenGeoscience/geojs/blob/master/src/util/init.js#L305> 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> 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
> http://public.kitware.com/mailman/listinfo/geojs-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/geojs-users/attachments/20161215/111c8326/attachment.html>


More information about the Geojs-users mailing list