How can I limit the length of a HighCharts PlotLine on the Y-Axis for a BoxPlot?

送分小仙女□ 提交于 2019-12-24 15:40:28

问题


I am using highchairs 3.0 to create a graph that has N Boxes on it. So far so good. However, one of the user desires is to draw a few plotLines (based on values on the Yaxis) for each Box on the graph. The catch is that the information is different for each of the boxes, so they want the plotLine to just extend from the start of the box on the left side (x-axis basis) to the right of the single box.

Highchairs by default draws the y-axis plotLines (and plotBands, looked at those too) all the way from left to right, causing a very chaotic chart indeed!

Is there a way to limit the length (start / end on the x-axis I guess) of a plotLine in a box plot to just the width of the box?? I guess I basically want to overlay lines onto the area of each Box on the graph.

Thanks!


回答1:


The best way that I have found to do this is by extending the marker symbol types to create a horizontal line. Use this as the marker symbol type for a scatter series to accomplish what you're looking for.

Highcharts.Renderer.prototype.symbols.hline = function(x, y, width, height) {
    return ['M',x ,y + height / 2,'L',x+width,y + width / 2];
};

Example:

  • http://jsfiddle.net/jlbriggs/m85yv3aq/

Required inputs of: radius, lineWidth, color

((also a useful way to build bullet charts:

  • http://jsfiddle.net/jlbriggs/UGs2E/

))



来源:https://stackoverflow.com/questions/30669241/how-can-i-limit-the-length-of-a-highcharts-plotline-on-the-y-axis-for-a-boxplot

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