我有一个SVG

<g id="generic-_exportbutton" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
    <path d="M1.5,23 C1.22385763,23 1,22.7761424 1,22.5 L1,4.5 C1,4.22385763 1.22385763,4 1.5,4 L9.5,4 C9.77614237,4 10,4.22385763 10,4.5 C10,4.77614237 9.77614237,5 9.5,5 L2,5 L2,22 L16,22 L16,12.5 C16,12.2238576 16.2238576,12 16.5,12 C16.7761424,12 17,12.2238576 17,12.5 L17,22.5 C17,22.7761424 16.7761424,23 16.5,23 L1.5,23 Z M20,9.24416185 C20,9.43190751 19.9315607,9.59468208 19.7946821,9.73248555 C19.6578035,9.87028902 19.4950289,9.93872832 19.3063584,9.93780347 C19.1176879,9.93687861 18.9549133,9.86843931 18.8180347,9.73248555 L16.9105202,7.8249711 L11.8436994,12.8917919 C11.7715607,12.9639306 11.6883237,13 11.5939884,13 C11.4996532,13 11.4164162,12.9639306 11.3442775,12.8917919 L10.1082081,11.6557225 C10.0360694,11.5835838 10,11.5003468 10,11.4060116 C10,11.3116763 10.0360694,11.2284393 10.1082081,11.1563006 L15.1750289,6.08947977 L13.2675145,4.18196532 C13.1306358,4.04508671 13.0621965,3.88231214 13.0621965,3.69364162 C13.0621965,3.5049711 13.1306358,3.34219653 13.2675145,3.20531792 C13.4043931,3.06843931 13.5671676,3 13.7558382,3 L19.3049711,3 C19.4927168,3 19.6554913,3.06843931 19.7932948,3.20531792 C19.9310983,3.34219653 19.9995376,3.5049711 19.9986127,3.69364162 L20,9.24416185 Z" id="Combined-Shape" fill="#0081FF" fill-rule="nonzero"></path>
</g>


并且我想将其转换为Highcharts中的导出图标,但是我没有找到一种方法,因为我发现的唯一方法是this

问题是我不知道如何将我必须的SVG转换为Highcharts需要的类型

最佳答案

您可以编辑现有导出按钮d元素的path属性:

var exporting = $(".highcharts-exporting-group")[0].children[0].children[2];

exporting.setAttribute('d', "M1.5,23 C1.22385763,23 1,22.7761424 1,22.5 L1,4.5 C1,4.22385763 1.22385763,4 1.5,4 L9.5,4 C9.77614237,4 10,4.22385763 10,4.5 C10,4.77614237 9.77614237,5 9.5,5 L2,5 L2,22 L16,22 L16,12.5 C16,12.2238576 16.2238576,12 16.5,12 C16.7761424,12 17,12.2238576 17,12.5 L17,22.5 C17,22.7761424 16.7761424,23 16.5,23 L1.5,23 Z M20,9.24416185 C20,9.43190751 19.9315607,9.59468208 19.7946821,9.73248555 C19.6578035,9.87028902 19.4950289,9.93872832 19.3063584,9.93780347 C19.1176879,9.93687861 18.9549133,9.86843931 18.8180347,9.73248555 L16.9105202,7.8249711 L11.8436994,12.8917919 C11.7715607,12.9639306 11.6883237,13 11.5939884,13 C11.4996532,13 11.4164162,12.9639306 11.3442775,12.8917919 L10.1082081,11.6557225 C10.0360694,11.5835838 10,11.5003468 10,11.4060116 C10,11.3116763 10.0360694,11.2284393 10.1082081,11.1563006 L15.1750289,6.08947977 L13.2675145,4.18196532 C13.1306358,4.04508671 13.0621965,3.88231214 13.0621965,3.69364162 C13.0621965,3.5049711 13.1306358,3.34219653 13.2675145,3.20531792 C13.4043931,3.06843931 13.5671676,3 13.7558382,3 L19.3049711,3 C19.4927168,3 19.6554913,3.06843931 19.7932948,3.20531792 C19.9310983,3.34219653 19.9995376,3.5049711 19.9986127,3.69364162 L20,9.24416185 Z")

现场演示:http://jsfiddle.net/BlackLabel/bjzkun28/

关于javascript - 将SVG转换为Highcharts.SVGRenderer.prototype.symbols,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53280482/

10-09 15:16