Applying custom style on ticks of Highchart

倖福魔咒の 提交于 2019-12-24 07:46:01

问题


I want to apply custom style on xAis ticks of Highcharts. I want to style ticks in the form of circle instead of line. like ticks.chart.renderer.cirlce();

Not able to find a way to get it done.


回答1:


You can wrap getMatkPath function, to render another tick, see: http://jsfiddle.net/Yrygy/83/

Highcharts.wrap(Highcharts.Tick.prototype, 'getMarkPath', function (prev, x, y, tickLength, tickWidth, horiz, renderer) {
    return renderer.circle(x, y, tickLength);
});

Edit:

When using zoom/panning etc from Highcharts or Highstock, it is required to returned data from getMarkPath is array of path (d for SVG).

For example: http://jsfiddle.net/AVhaL/1/

Update: (2016-01-28):

In Highcharts 4.2.x new method is required (we should return path for tickmark, not the rendered object):

Highcharts.wrap(Highcharts.Tick.prototype, 'getMarkPath', function(prev, x, y, tickLength, tickWidth, horiz, renderer) {
  return renderer.symbol('circle', x - tickLength / 2, y - tickLength / 2, tickLength, tickLength);
});


来源:https://stackoverflow.com/questions/21136568/applying-custom-style-on-ticks-of-highchart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!