Highcharts提示框 – 如何去掉标记点?

huangapple go评论83阅读模式
英文:

Highcharts Tooltip - Getting rid of the marker dot?

问题

我想要去掉工具提示框中左上角的小点。我正在使用Highcharts。您可以帮助我修改这个功能吗,这是我的代码:

tooltip: {
    useHTML: true,
    pointFormat: '{point.name} <br> <div style="display: inline-block;" class="square-answer1-globe"></div>{{question["answer1"]}}: {point.value1}% <br> <div style="display: inline-block;" class="square-answer2-globe"></div>{{question["answer2"]}}: {point.value2}%',
    backgroundColor: 'black',
    style: {
        color: 'white'
    },
}

要去掉工具提示框中的小点,您可以在tooltip对象中添加"marker"属性,并将其设置为false,如下所示:

tooltip: {
    useHTML: true,
    pointFormat: '{point.name} <br> <div style="display: inline-block;" class="square-answer1-globe"></div>{{question["answer1"]}}: {point.value1}% <br> <div style="display: inline-block;" class="square-answer2-globe"></div>{{question["answer2"]}}: {point.value2}%',
    backgroundColor: 'black',
    style: {
        color: 'white'
    },
    marker: false  // 添加这一行
}

这将禁用工具提示框中的小点。

英文:

I would like to get rid of the small dot in my tooltip display. I am using High-charts. I Can you please help in modifying this feature, here is my code:

 Highcharts.getJSON(
  &#39;https://code.highcharts.com/mapdata/custom/world.topo.json&#39;,
  topology =&gt; {
 
    const chart = Highcharts.mapChart(&#39;container&#39;, {
      chart: {
        map: topology
      },
 
      title: {
        text: &#39;&#39;
      },
 
      legend: {
         enabled: false,
         align: &#39;center&#39;,
         verticalAlign: &#39;bottom&#39;,
         itemStyle: {
             fontWeight: &#39;bold&#39;,
             fontSize: &#39;20px&#39;
         }
     },
 
      mapNavigation: {
        enabled: true,
        enableDoubleClickZoomTo: true,
        buttonOptions: {
          align: &#39;right&#39;,
          verticalAlign: &#39;bottom&#39;
        }
      },
 
      mapView: {
        maxZoom: 30,
        projection: {
          name: &#39;Orthographic&#39;,
          rotation: [60, -30]
        }
      },
 
      colorAxis: {
                         min: 0,
                         max: 100,
                         text: &#39;&#39;,
                         stops: [[0, &#39;darkgrey&#39;, &#39;&#39;], [0, &#39;#5ce1e6&#39;, &#39;{{question[&#39;answer1&#39;]}}&#39;], [0.49, &#39;#c9f5f7&#39;, &#39;&#39;], [.50, &#39;#aee0a0&#39;, &#39;&#39;], [.51, &#39;#fff4c8&#39;, &#39;&#39;], [1, &#39;#ffde59&#39;, &#39;{{question[&#39;answer2&#39;]}}&#39;]],
                         title: {
                          text: &#39;&#39;,
                          },
                     },
 
      credits: {
        enabled: false
      },
 
      tooltip: {
        useHTML: true,
        pointFormat: &#39;{point.name} &lt;br&gt; &lt;div style=&quot;display: inline-block;&quot; class=&quot;square-answer1-globe&quot;&gt;&lt;/div&gt;{{question[&quot;answer1&quot;]}}: {point.value1}% &lt;br&gt; &lt;div style=&quot;display: inline-block;&quot; class=&quot;square-answer2-globe&quot;&gt;&lt;/div&gt;{{question[&quot;answer2&quot;]}}: {point.value2}%&#39;,
        backgroundColor: &#39;black&#39;,
        style: {
        color: &#39;white&#39;
         },         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
     },

      plotOptions: {
        series: {
          animation: {
            duration: 750
          },
          clip: false

        }
      },
 
      mapline: {
             color: Highcharts.getOptions().colors[0]
           },
      series: [{ 
           name: &#39;Graticule&#39;,
           id: &#39;graticule&#39;,
           type: &#39;mapline&#39;,
           data: getGraticule(),
           nullColor: &#39;lightgrey&#39;,
           color: &#39;lightgrey&#39;,
           accessibility: {
          enabled: false
        },
        enableMouseTracking: false
         },
        
      
      {
        data,
        joinBy: &#39;name&#39;,
        name: &#39;&#39;,
        states: {
          hover: {
             color: &#39;&#39;,
            borderColor: &#39;#000000&#39;
          }
        },
     
        accessibility: {
          exposeAsGroupOnly: true
        }
      }]
    });

Here is an image of what is displayed: enter image description here

I want to get rid of the little dot in the top left of the tooltip box. I have been trying everything and it always seems to appear there. I have tried adding in "Marker: false", but maybe I am not inputting it in the correct spot (not sure if this is the correct code).

答案1

得分: 1

你可以使用 formatter 选项来设置工具提示,类似于这样,但要添加你自己的数值:

tooltip: {
  formatter: function(tooltip) {
    return `${question1}: <b>${percentage1}</b><br/>`
  }
},

这里有关于它的文档:https://api.highcharts.com/highcharts/tooltip.formatter

英文:

You can use formatter option for the tooltip, something like this, but add your values:

  tooltip: {
    formatter: function(tooltip) {
      return `${question1}: &lt;b&gt;${percentage1}&lt;/b&gt;&lt;br/&gt;`
    }
  },

Here is documentation about it: https://api.highcharts.com/highcharts/tooltip.formatter

huangapple
  • 本文由 发表于 2023年2月18日 00:19:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75486781.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定