How to add color styles to histogram?

240
2
12-06-2023 12:36 PM
dwismer
New Contributor

I have created a simple histogram that is not connected to a feature. How do I add colours to each bin?

0 Kudos
2 Replies
KristianEkenes
Esri Regular Contributor

I wrote a blog article about how to do this a few years ago. The live samples are using older versions of the API, but the pattern for coloring the bins should be the same. https://www.esri.com/arcgis-blog/products/js-api-arcgis/mapping/make-your-histogram-legendary/ 

0 Kudos
dwismer
New Contributor

This blog is awesome! And I have be referencing it a lot. The only difference with my use case is that my histogram is not linked to a raster layer. Rather I build it "by hand". I found that I can make the entire histrogram a color, but not each bin.  

 hist.barCreatedFunction = (index = 1, element) => {  element.setAttribute("fill", "#33862B")};

Also, this is out of scope for this question, but do you know if it is possible to add a Y axis that labels the frequency of the histogram?

0 Kudos