Jqplot-如何从已创建的图形中取回数组 [英] Jqplot - How do get array back from already created graph

查看:103
本文介绍了Jqplot-如何从已创建的图形中取回数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用jqplot绘制了一个图,并包含了可拖动功能.关键是用户可以根据自己的需求修改图形.

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?

推荐答案

您将在图表series[serieIndex].data属性中找到更新的数据:

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.

这篇关于Jqplot-如何从已创建的图形中取回数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆