How to add a scroll bar to X-axis or Y-axis in can

2019-02-19 00:27发布

http://i.stack.imgur.com/O8fiZ.jpg
I have a multi-series flot graph which is plotted in a canvas of width and height. When the flot graph has multi series it tries to compress within the height and width of the canvas and the flot graph wont't be seen clearly.

In order to obtain a clear graph with all the series visible with all the nodes I want to introduce a scroll bar in such a way that the scroll bar fits only few series at first then by scrolling the rest of the series should be seen .

How do i do it?

enter image description here

3条回答
Lonely孤独者°
2楼-- · 2019-02-19 00:44

Put it in a div:

<div class="graph">
   <!-- here the graph -->
</div>

CSS:

 .graph
 {
 width: 200px;
 overflow-y:scroll; 
 overflow-x:hidden;
 }

WIth the overflow attribute, you can control where a scrollbar should be.

查看更多
成全新的幸福
3楼-- · 2019-02-19 00:45

If you don't want to use the panning and zooming plugin (as @MF82 suggests) and want a true scroll bar, just wrap the container target div in another div:

<div 
  style="width:315px;height:300px;overflow-y:scroll">
    <div class="chart" id="placeholder1" style="width:300px;height:1000px;">
     </div>
</div>

Fiddle example here.

查看更多
太酷不给撩
4楼-- · 2019-02-19 00:50

I think you can pass some options to Flot (with Navigation plugin), such as:

pan: {
    interactive: true
},
xaxis: {
    panRange: [Your xmin, your xmax]
} 

where panRange means:

"panRange" confines the panning to stay within a range, e.g. with panRange: [-10, 20] panning stops at -10 in one end and at 20 in the other. Either can be null.

Navigation example

查看更多
登录 后发表回答