Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script language="javascript" type="text/javascript" src="flot/jquery.js"></script>
- <script language="javascript" type="text/javascript" src="flot/jquery.flot.js"></script>
- <script type="text/javascript">
- $(document).ready( function() {
- // Setup flot
- var options = {
- lines: { show: true },
- points: { show: true },
- xaxis: { tickDecimals: 0, tickSize: 1 }
- };
- var data = [];
- var chart = $("#chart");
- $.plot(chart, data, options);
- // Bind select
- $("#series").change( function() {
- requestData($(this).val());
- });
- // Send request
- function requestData(series) {
- $.ajax({
- url: "flotdata.cfm",
- method: "GET",
- data: {"series": series},
- dataType: "json",
- success: onData
- });
- }
- // Handle response
- function onData(series) {
- data[0] = series;
- $.plot(chart, data, options);
- }
- });
- </script>
- </head>
- <body>
- <select id="series">
- <option value="a">Series A</option>
- <option value="b">Series B</option>
- </select>
- <div id="chart" style="height:300px;width:600px;" />
- </body>
- </html>
Add Comment
Please, Sign In to add comment