Last active
December 10, 2015 01:18
-
-
Save katychuang/4357163 to your computer and use it in GitHub Desktop.
line chart made with Flotr2.js library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <style> | |
| #samplechart { width:600px; height:300px;} | |
| .flotr-datagrid-container{border:1px solid #999;border-bottom:none;background:#fff} | |
| .flotr-datagrid{border-collapse:collapse;border-spacing:0} | |
| .flotr-datagrid td,.flotr-datagrid th{border:1px solid #ccc;padding:1px 3px;min-width:2em} | |
| .flotr-datagrid tr:hover,.flotr-datagrid col.hover{background:#f3f3f3} | |
| .flotr-datagrid tr:hover th,.flotr-datagrid th.hover{background:#999;color:#fff} | |
| .flotr-datagrid th{text-align:left;background:#e3e3e3;border:2px outset #fff} | |
| .flotr-datagrid-toolbar{padding:1px;border-bottom:1px solid #ccc;background:#f9f9f9} | |
| .flotr-datagrid td:hover{background:#ccc}.flotr-datagrid .first-row th{text-align:center} | |
| .flotr-canvas{margin-bottom:-3px;padding-bottom:1px}.flotr-tabs-group{border-top:1px solid #999} | |
| .flotr-tab{border:1px solid #666;border-top:none;margin:0 3px;padding:1px 4px;cursor:pointer; | |
| -moz-border-radius:0 0 4px 4px;-webkit-border-bottom-left-radius:4px;-webkit-border-bottom-right-radius:4px;border-radius:0 0 4px 4px;opacity:.5;-moz-opacity:.5} | |
| .flotr-tab.selected{background:#ddd;opacity:1;-moz-opacity:1} | |
| .flotr-tab:hover{background:#ccc} | |
| </style> | |
| </head> | |
| <body> | |
| <div id="samplechart"></div> | |
| <!--Scripts for Rendering Charts on page --> | |
| <!--[if IE]> | |
| <script type="text/javascript" src="flashcanvas.js"></script> | |
| <![endif]--> | |
| <script type="text/javascript" src="https://flotr.googlecode.com/svn-history/r319/branches/flotr2/flotr/flotr2/flotr2.min.js"></script> | |
| <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> | |
| <!--script type="text/javascript" src="jquery.flot.selection.js"></script--> | |
| <script type="text/javascript" src="LineChart-Flotr2.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Flotr2 line chart with data points and labels */ | |
| (function basic_bars(container, horizontal) { | |
| var | |
| horizontal = (horizontal ? true : false), // Show horizontal bars | |
| d1 = [[0, 18.9],[1, 20.2],[2, 18.1],[3, 20.4],[4, 16.7], [5, 14.6]], // data series | |
| point; // Data point variable declaration | |
| // Draw the graph | |
| Flotr.draw( | |
| container2, | |
| [d1], | |
| { | |
| mouse: { | |
| track: true, | |
| relative: true | |
| }, | |
| points : { show : true }, | |
| lines : { show : true }, | |
| markers: { | |
| show: true, | |
| position: 'ct' | |
| }, | |
| yaxis: { | |
| ticks : [0, 6, 15, 24], | |
| max : 24, | |
| min : 0 | |
| }, | |
| xaxis: { | |
| noTicks: 6, | |
| tickFormatter: function (x) { | |
| var | |
| x = parseInt(x), | |
| months = ['3 months', '6 months', '9 months', '1 year', '2 year', '3+ years']; | |
| return months[(x)%12]; | |
| } | |
| }, | |
| legend : { | |
| position : 'nw' | |
| }, | |
| spreadsheet : { | |
| show : true, | |
| tickFormatter : function (e) { return e+''; } | |
| } | |
| } | |
| ); | |
| })(document.getElementById("samplechart")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
