How to add a vertical line in a horizontal bar cha

2019-08-06 16:25发布

I'm using primefaces + jqplot to create a Horizontal and Stacked bar chart:

Code ( Example - Primefaces ):

http://www.primefaces.org/showcase/ui/chart/bar.xhtml

I need to add a line in chart like this image: ( Red line in Vertical )

http://peltiertech.com/Excel/pix1/AddLine.gif

Can i do this with Primefaces + Jqplot ? If it's possible, someone can help me to understand ?

1条回答
我只想做你的唯一
2楼-- · 2019-08-06 17:04

Finally solved my problem:

1 - Add a extender in Managed Bean with name of extender:

 horizontalBarModel.setExtender("NAME");

2 - Create a javascript function in xhtml:

function NAME(){}

3 - Add a Canvas Overlay:

function NAME()
{
 this.cfg.canvasOverlay = {
                show: true,
                objects: [{verticalLine:{
                "shadow":"false",
                "lineWidth":5,
                "color":"rgb(255,0,0)",
                "x":50 
 }}]};

}

4 - This vertical/horizontal lines depend on the following files (using Primefaces 5.0):

jqplot.canvasOverlay.js

You can find this file in Bitbucket Cleonello Jqplot.

5 - Add Labels and Tooltips with: Bitbucket Cleonello Jqplot - Support to canvas overlay lines.

查看更多
登录 后发表回答