highcharts - Highmaps map 比例

标签 highcharts

如何调整给定图表 div 容器中 map 形状的大小? 我没有看到任何设置比例的方法。我正在尝试做类似 demo 的事情但仅使用几个州(彼此接壤)。当我删除未使用的状态时,剩余的状态在给定的图表区域内仍然显得很小。深入到某个状态后,您可以看到适合容器大小的放大版本。现在,当您单击“向上钻取”按钮时,您会看到 map 路径现在填充了图表容器。这是一个粗略的example 。 这是 div 容器:

<div id="container" style="height: 500px; min-width: 310px; max-width: 800px; margin: 0 auto"></div>

这是用于生成图表的代码(测试数据请参见 jsfiddle):

    // Set drilldown pointers
    $.each(Highcharts.maps['US-FL'], function () {
        this.drilldown = this.id;
    });

    // Add some real data
    $.each(Highcharts.maps['US-FL'], function () {
        //this.value = Math.round(Math.random() * 100);
        var theID = this.id.toString();
            var theData;
            data1.some(function (arrayItem) {
                var x = arrayItem[0];
                console.log(x);
                if (x == theID) {
                    theData = arrayItem[1];
                    return theData;
                }
            });
            this.value = theData;
    });

    $.each(drilldownSeries, function () {
        $.each(this.data, function () {
            var theID = this.id.toString();
            var theData;
            data1.some(function (arrayItem) {
                var x = arrayItem[0];
                //console.log(x);
                if (x == theID) {
                    theData = arrayItem[1];
                    return theData;
                }
            });
            this.value = theData;
        });
    });

    // Some responsiveness
    var small = $('#container').width() < 400;

    // Instanciate the map
    $('#container').highcharts('Map', {
        chart: {
            events: {
                drilldown: function (e) {
                    this.setTitle(null, {
                        text: e.point.name
                    });
                    e.seriesOptions.name = e.point.name;
                },
                drillup: function (e) {
                    this.setTitle(null, {
                        text: 'Florida'
                    });
                }
            }
        },

        title: {
            text: 'Highcharts Map Drilldown'
        },

        subtitle: {
            text: 'Florida',
            floating: true,
            align: 'right',
            y: 50,
            style: {
                fontSize: '16px'
            }
        },

        legend: small ? {} : {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle'
        },

        colorAxis: {
            min: 0
            //max: yMaxVal,
            //minColor: '#E6E7E8',
            //maxColor: '#005645'
        },

        mapNavigation: {
            enabled: true,
            buttonOptions: {
                verticalAlign: 'bottom'
            }
        },

        plotOptions: {
            map: {
                states: {
                    hover: {
                        color: '#EEDD66'
                    }
                }
            }
        },

        series: [{
            data: Highcharts.maps['US-FL'],
            name: 'State of Florida',
            dataLabels: {
                //enabled: true,
                formatter: function () {
                    return this.point.id.substr(3, 2);
                },
                format: null
            }
        }],

        drilldown: {
            series: drilldownSeries,
            activeDataLabelStyle: {
                color: 'white'
            },
            drillUpButton: {
                relativeTo: 'spacingBox',
                position: {
                    x: 0,
                    y: 60
                }
            }
        }
    });
});

最佳答案

事实上,它看起来像是一个可能的错误,在这里报告 https://github.com/highslide-software/highcharts.com/issues/2750目前它是测试版,因此可能包含一些错误。

关于highcharts - Highmaps map 比例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22018958/

相关文章:

javascript - Highcharts - 突出显示两个 y 值之间的区域

javascript - 如何在悬停在 Highcharts JAVASCRIPT 上时去除外部阴影

javascript - Highcharts:将工具提示放置在条形图上的条形上方

javascript - Highcharts 上的导出按钮以打开新选项卡

javascript - highcharts 可点击标签如何转到 anchor

c# - 在 C# ASP.NET 中预处理 HighCharts JS 中的数据

highcharts - 减少 Bar Highchart 中系列数据之间的差距

javascript - Highcharts - 棒图时间序列的一种破解

ios - 我们可以使用 HighCharts 重叠多个图表吗

javascript - HighCharts 图形无法在 Internet Explorer 上运行