Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
MapPointSeries not calling heatRules in amcharts5?

I have successfully created MapPolygonSeries on amcharts5 with heatRules. But I am trying to add MapPointSeries to set the colour of the bullets. It appears to me that the heatRules are not called at all. Does anyone have a working example, or is the issue with my code obvious?

            var rootElements = am5.registry.rootElements;
            var root = (rootElements.length > 0? rootElements[0]: am5.Root.new("chartdiv"));
            root.container.children.clear();
            
            var chart = root.container.children.push (
                am5map.MapChart.new(root, {
                    projection: am5map.geoMercator(),
                    panX: "none",
                    panY: "none",
                    wheelX: "none",
                    wheelY: "none"
                })
            );
            
            var pointSeries = chart.series.push(
                am5map.MapPointSeries.new(root, {
                    latitudeField: "lat",
                    longitudeField: "lon",
                    fill: am5.color(0xff0000)
                })
            );

            var circleTemplate = am5.Template.new({});
            pointSeries.bullets.push(function() {
                var bulletCircle = am5.Circle.new(root, {
                    radius: 5,  
                    fill: pointSeries.get("fill"),
                    fillOpacity: 0.8
                }, circleTemplate);
                return am5.Bullet.new(root, {
                    sprite: bulletCircle
                });
            });
            
            pointSeries.set("heatRules", [{
                target: circleTemplate,
                dataField: "value",
                key: "fill"
                min: am5.color(0xff3300),
                max: am5.color(0xffff00),
            }]);

            pointSeries.data.setAll(myPointData);

myPointData looks like this:

[
{lat: -15.4183, lon: 28.287, value: 1.00448108131708},
{lat: -9.7915, lon: 29.0791, value: 1.0057251847281312},
...
]

Notes:

  • If I do not set fill in MapPointSeries.new, then nothing is drawn (or so it appears)
  • No errors in the browser console (Chrome)

Thank you in advance for any insight on this!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here is how I did a workaround, but it is ugly, since I basically wrote my own heatmap function. I am still open to suggestions how to get the heatRules to work properly for points!

    function manualHeatMap(series) {
        if (series.length < 1) {
            return series;
        }
        var min, max;
        min = max = series[0].value;
        for (var i = 1; i < series.length; ++i) {
            if (series[i].value > max) {
                max = series[i].value;
            }
            if (series[i].value < min) {
                min = series[i].value;
            }
        }
        if (min == max) {
            min = 0;
        }
        for (var i = 0; i < series.length; ++i) {
            series[i].settings = {fill: am5.color(heatRuleCalc(min, max, series[i].value))};
        }
        return series;
    }

/* ... */

            var circleTemplate = am5.Template.new({});
            pointSeries.bullets.push(function() {
                var bulletCircle = am5.Circle.new(root, {
                    radius: 7,  
                    templateField: "settings",
                    fillOpacity: 0.8
                }, circleTemplate);
                return am5.Bullet.new(root, {
                    sprite: bulletCircle
                });
            });

            pointSeries.data.setAll(manualHeatMap(myPointData));

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda