Jqplot - How do get array back from already created graph

喜你入骨 提交于 2019-12-24 19:03:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!