如何在Highmaps中移除图例名称?基于双击缩放示例场景
How to Remove Numeric Labels (1, 10, 100, 1k) from Highmaps Legend
Got it, let's fix this quickly! When building on that double-click zoom Highmaps demo and wanting to get rid of those numeric labels in the legend, the solution lies in customizing the legend's label formatter for the color axis.
Here's the straightforward approach:
- Locate the
colorAxissection in your Highmaps configuration (this is where the value scale legend is controlled). - Add or modify the
legendproperty insidecolorAxis, and override thelabelFormatterfunction to return an empty string.
Here's the code snippet to implement this:
colorAxis: { min: 1, max: 1000, type: 'logarithmic', legend: { enabled: true, // This overrides default label text, returning nothing to hide the numeric labels labelFormatter: function() { return ''; } } }
Why this works:
The labelFormatter function dictates what text gets rendered next to each color segment in the legend. By returning an empty string, we suppress those numeric labels (1, 10, 100, 1k) entirely while keeping the color gradient bar intact. If you ever need to add custom text later, you can just adjust the return value in this function.
内容的提问来源于stack exchange,提问作者user1219310
相关产品推荐
相关产品推荐

