问题
I plotted a graph with jqplot and included the dragable functionality. The whole point is a user can modify the graph based on what they want.
$.jqplot.config.enablePlugins = true;
var demandPlot = $.jqplot('myDiv', [ myArray ], {
title : 'My Graph',
seriesDefaults: {
fill: true
},
axes : {
xaxis : {
label: 'My X axis'
},
yaxis : {
label:'My Y axis'
}
},
series:[{
color:"green",
dragable: {
color: '#ff3366',
constrainTo: 'y'
},
trendline: {
color: '#cccccc'
}
}]
});
I would like to retrieve the final array after changes are made. Any ideas on how get the array back?
回答1:
You'll find the updated data in the chart series[serieIndex].data
property:
http://jsfiddle.net/coma/jvGHH/10/
$(function(){
$.jqplot.config.enablePlugins = true;
var data = [['23-May-08', 1],['24-May-08', 4],['25-May-08', 2],['26-May-08', 6]];
var chart = $.jqplot('chart', [data], {
title : 'My Graph',
seriesDefaults: {
fill: true
},
axes : {
xaxis : {
label: 'My X axis',
renderer: $.jqplot.DateAxisRenderer
},
yaxis : {
label: 'My Y axis'
}
},
highlighter: {
sizeAdjust: 10
}
});
var log = function(seriesIndex, pointIndex, pixelposition, data) {
console.log(chart.series[0].data);
};
$('#chart')
.bind('jqplotSeriesPointChange', log)
.bind('jqplotDragStop', log);
});
Btw, there are several events you'll fine useful.
来源:https://stackoverflow.com/questions/16742486/jqplot-how-do-get-array-back-from-already-created-graph