Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function () {
- // set up plot
- $.jqplot.config.enablePlugins = true;
- s1 = [['23-May-08',1],['24-May-08',4],['25-May-08',2],['26-May-08', 6]];
- plot1 = $.jqplot('chart1',[s1],{
- title: 'Highlighting, Dragging, Cursor and Trend Line',
- axes: {
- xaxis: {
- renderer: $.jqplot.DateAxisRenderer,
- tickOptions: {
- formatString: '%#m/%#d/%y'
- },
- numberTicks: 4
- },
- yaxis: {
- tickOptions: {
- formatString: '$%.2f'
- }
- }
- },
- highlighter: {
- sizeAdjust: 10,
- tooltipLocation: 'n',
- tooltipAxes: 'y',
- tooltipFormatString: '<b><i><span style="color:red;">hello</span></i></b> %.2f',
- useAxesFormatters: false
- },
- cursor: {
- show: true
- }
- });
- // add our hook, to fire after a series update
- $.jqplot.postDrawSeriesHooks.push(updatedSeries);
- function updatedSeries(sctx, options) {
- console.log(plot1.series[0].data); //data for the series is here
- }
- });
- [
- Array[2]
- ,
- Array[2]
- ,
- Array[2]
- ,
- Array[2]
- ]
- $("#chart1").on("jqplotClick", function(ev, gridpos, datapos, neighbor) {
- if ( neighbor ) {
- // specific point that has been clicked
- console.log('x:' + neighbor.data[0] + ' y:' + neighbor.data[1]);
- }
- // all the data from this plot's single series
- console.log(plot1.series[0].data);
- });
- var plots = [
- $.jqplot('chart1', [s0], graph_opts),
- $.jqplot('chart2', [s1], graph_opts)
- ];
- $("#chart1, #chart2").on("jqplotClick", function(ev, gridpos, datapos, neighbor) {
- var data = [];
- $.each(plots, function(key, plot) {
- data[key] = plot.series[0].data;
- });
- var ajax_opts = {
- url: ajax_info.url,
- type: 'post',
- async: true,
- cache: false,
- dataType: 'json',
- data: {
- action: 'store_graphs',
- data: data
- },
- success: function( response ) {
- console.log(response);
- },
- error: function( xhr, textStatus, e ) {
- console.log(xhr.responseText);
- }
- };
- $.ajax(ajax_opts);
- });
Advertisement
Add Comment
Please, Sign In to add comment