我正在尝试创建佛罗里达州的点密度图。虽然我知道Highmaps不支持带有色点的色轴。我对其进行了扩展,但它具有副作用。当我单击图例中的类别之一时,不会发生隐藏。例如,如果我单击“> 10”,则不会隐藏所有大于10的值。当我打开Chrome调试器时,它指出:a.setVisible不是函数可以解决此问题。这是一项要求,尽管它似乎很小。我将不胜感激任何技巧,或者也许会有一些例子很完美。我不能显示比显示的更多的代码。如果您需要我更多地说明问题,我会很乐意这样做。

               (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

                            }
                        }



                    ]});


要使用的示例:http://jsfiddle.net/dlope073/4mabw6zr/2/

最佳答案

使用默认setVisible系列中的map方法。像这样: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);

10-01 03:55