简体   繁体   English

将代码添加到Flot条形图

[英]Add ticker to Flot bar chart

I have created a chart using Flot library. 我已经使用Flot库创建了一个图表。 I need to add a tick mark for showing comparison between last two bars. 我需要添加一个刻度线以显示最后两个小节之间的比较。 I am not able to get the height of the bars using any method how can I plot that. 我无法使用任何方法获取条形图的高度。

Here is the example what I am looking for. 这是我正在寻找的示例。

在此处输入图片说明

I am done with just simple flot chart code which is here. 我已经完成了这里的简单浮点图代码。 I am not getting how to approach because unable to find any event or anything that give me bar height. 我找不到方法,因为找不到任何事件或任何使我身高高低的东西。

 var data = [ {data: [[0,1]], color: "red"}, {data: [[1,2]], color: "yellow"}, {data: [[2,3]], color: "green"} ]; $.plot("#placeholder",data, { series: { bars: { show: true, barWidth: 0.3, align: "center", lineWidth: 0, fill:.75 } }, xaxis: { ticks: [[0,"Red"],[1,"Yellow"],[2,"Green"]] } }); 
 <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://www.flotcharts.org/flot/jquery.flot.js"></script> <div id="placeholder" style="width: 400px; height: 300px; padding: 0px; position: relative;"></div> 

I got a solution. 我有解决办法。 There is a marking option in the Flot library itself which I can use. 我可以使用Flot库本身中的一个标记选项。 It is not providing me the arrow but atleast I can add a line with it. 它没有为我提供箭头,但至少可以为其添加一条线。

 var data = [ {data: [[0,1]], color: "red"}, {data: [[1,2]], color: "yellow"}, {data: [[2,3]], color: "green"} ]; $.plot("#placeholder",data, { series: { bars: { show: true, barWidth: 0.3, align: "center", lineWidth: 0, fill:.75 }, }, grid: { markings: [{ xaxis: { from: 1, to: 2 }, yaxis: { from: 2, to: 2 }, color: "#bb0000" }] }, xaxis: { ticks: [[0,"Red"],[1,"Yellow"],[2,"Green"]] } }); 
 <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://www.flotcharts.org/flot/jquery.flot.js"></script> <div id="placeholder" style="width: 400px; height: 300px; padding: 0px; position: relative;"></div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM