Search code examples
openlayers

Openlayers ol-ext Add fill color to donut chart


I face the problem to add fill background to donut chart in ol-ext extention of Openlayers enter image description here

Any ideas how that can be achieved? I've tried adding fill to image of new Chart, also tried adding text with backgroundFill, but as soon as there is no border radius for Text background it looks very ugly inside cirle of donut. enter image description here


Solution

  • Try a style array with a smaller circle on top of the donut:

                style = [
                  new ol.style.Style({
                    image: new ol.style.Chart({
                      type: 'donut',
                      ...
                      ...
                    })
                  }),
                  new ol.style.Style({
                    image: new ol.style.Circle({
                      radius: ???,
                      fill: new ol.style.Fill({
                        color: ???
                      })
                    })
                  })
                ];