Extending Highmaps Side Effect

410 views Asked by At

I am trying to create a dot density map of the state of Florida. While I know that Highmaps doesn't support color axis with mappoints. I extended it and it works but it comes with a side affect. When I click on one of the categories in the legend no hiding occurs. For example if I click on '>10', all values greater than 10 don't hide. When I open up the Chrome debugger it states that: a.setVisible is not a function What can I do to solve this problem. This is a requirement, while it may seem minor. I would appreciate any sort of tips or maybe some sort of example would be perfect. I can't show more code than what is shown. If you need me to explain more about the problem I will be glad to do so.

               (function (H) {
                    H.seriesTypes.mappoint.prototype.axisTypes = [ 'xAxis', 'yAxis', 'colorAxis'];
                    H.wrap(H.seriesTypes.mappoint.prototype, "translate", function (p) {
                        p.call(this);
                        H.seriesTypes.mappoint.prototype.translateColors.call(this);
                    });
                    H.seriesTypes.mappoint.prototype.translateColors = H.seriesTypes.heatmap.prototype.translateColors;
                    H.seriesTypes.mappoint.prototype.colorKey = 'value';

                })(Highcharts);


                // Initiate the chart
                $('#container').highcharts('Map', {
                    title: {
                        text: title
                    },
                    mapNavigation: {
                        enabled: false,
                    },
                    colorAxis: {
                        dataClasses: [{
                                from: 0,
                                to: 3,
                                color: "#66FFFF"
                            }, {
                                from: 4,
                                to: 9,
                                color: "#0099FF"
                            }, {
                                from: 10,
                                color: "#0000FF"
                            }
                            ]
                    },
                    tooltip:
                            {
                                enabled: true
                            }
                    ,
                    series: [{
                            mapData: Highcharts.maps['countries/us/us-fl-all'],
                            name: 'Basemap',
                            borderColor: '#A0A0A0',
                            nullColor: 'rgba(200, 200, 200, 0.3)',
                            showInLegend: false,
                        },
                        {
                            // Specify points using lat/lon
                            type: 'mappoint',
                            name: 'A',
                            turboThreshold: 2000000,
                            data: p_data,
                            dataLabels: {
                                enabled: false

                            }
                        },
                        {
                            // Specify points using lat/lon
                            type: 'mappoint',
                            name: 'B',
                            turboThreshold: 2000000,
                            data: m_data,
                            dataLabels: {
                                enabled: false

                            }
                        },
                        {
                            // Specify points using lat/lon
                            type: 'mappoint',
                            name: 'C',
                            turboThreshold: 2000000,
                            data: h_data,
                            dataLabels: {
                                enabled: false

                            }
                        }



                    ]});

A sample to play with: http://jsfiddle.net/dlope073/4mabw6zr/2/

1

There are 1 answers

0
Paweł Fus On BEST ANSWER

Use setVisible method from default map series. Like this: http://jsfiddle.net/4mabw6zr/3

(function (H) {
    H.seriesTypes.mappoint.prototype.axisTypes = ['xAxis', 'yAxis', 'colorAxis'];   
    H.seriesTypes.mappoint.prototype.pointClass.prototype.setVisible = H.seriesTypes.map.prototype.pointClass.prototype.setVisible; // use the same setVisible method as map type.

    H.wrap(H.seriesTypes.mappoint.prototype, "translate", function (p) {
        p.call(this);
        H.seriesTypes.mappoint.prototype.translateColors.call(this);
    });
    H.seriesTypes.mappoint.prototype.translateColors = H.seriesTypes.heatmap.prototype.translateColors;
    H.seriesTypes.mappoint.prototype.colorKey = 'value';
})(Highcharts);