You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何参照plus图标实现方式为Highcharts自定义location定位SVG符号

自定义add_location定位图标实现方案

1. 注册自定义图标

和原plus图标逻辑一致,直接在Highcharts的SVGRenderer原型上扩展新的symbol类型即可,路径适配了Material Icons的add_location风格比例:

Highcharts.SVGRenderer.prototype.symbols.addLocation = function (x, y, w, h) {
  return [
    // 定位标识外轮廓
    'M', x + w/2, y,
    'A', w/2, w/2, 0, 0, 1, x + w, y + w/2,
    'L', x + w, y + h * 0.6,
    'L', x + w/2, y + h,
    'L', x, y + h * 0.6,
    'L', x, y + w/2,
    'A', w/2, w/2, 0, 0, 1, x + w/2, y,
    // 中间加号
    'M', x + w * 0.3, y + h * 0.4,
    'L', x + w * 0.7, y + h * 0.4,
    'M', x + w * 0.5, y + h * 0.2,
    'L', x + w * 0.5, y + h * 0.6,
    'z'
  ];
};

2. 图标调用方式

替换原plus调用时的symbol名称即可,其余配置项完全兼容原有逻辑:

this.iConobject = this.highChart.renderer
  .symbol('addLocation', 0, 0, iconSize, iconSize)
  .attr({
    fill: 'blue',
    stroke: 'black',
    'stroke-width': 1
  })
  .add()
  .toFront()
  .hide();

3. 动态坐标设置

和原有plus图标的坐标设置逻辑完全一致,无需额外修改:

this.iConobject.addLocationIcon
  .attr({
    x: normalizedEvent.chartX - iconSize / 2,
    y: myObj.highChart.plotTop - iconSize / 2
  })
  .show();

内容的提问来源于stack exchange,提问作者deep sinha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 14:57:02