Jquery按钮以图表答案为条件

时间:2015-12-16 08:53:34

标签: jquery button graph

我进行在线实验。其中一个问题涉及通过拖放五个数据点在图表上绘制关系。我记录了他们所拥有的价值和掉落的价值。数据点(请参阅代码末尾的函数UpdatedSeries)。

我需要添加一个检查表明他们正在进行有意识的努力,即至少需要从原始位置(y轴值为25的直线)改变5个数据点中的4个,然后才可以点击提交'按钮。如果他们点击它而没有拖出五分中的四分,我需要提供一条消息。

但是,我不知道如何制定按钮的条件并将其插入代码中。自从我开始研究这段代码以来已经过去了一年,我似乎已经没有实践了......

function Relation()
{
    $("#chart1").dialog(
    {
        title: "Relationship",
        modal:true,
        resizable:false,
                height: 600,
                width:940,
        show: "fade", 
        hide: "explode",
    buttons: 
        [
            {text: "submit", click: function()
                {
                    $(this).dialog("close");
                    Completion();
                }}
        ]   
    });

        $.jqplot.config.enablePlugins = true;

  s1 = [[2,25],[50,25],[100,25],[150,25],[200,25],[250,25]];

  plot1 = $.jqplot('chart1',[s1],{
     title: 'Please draw the relationship between the promotional expenditure and rise in sales you inferred from the graphs by dragging and dropping the data points. Change at least 4 data points from their original position.',
    series: [
    {
        label: 'Relation',
        dragable: {
            constrainTo: 'y'
        },
        isDragable: true
    }
],
        axes: {
         xaxis: {

          label:'Promotional expenditure',
          tickInterval:50, 
          min:0, 
          max:300
         },
         yaxis: {

          label:'Sales increase (percentage)' ,
          tickInterval: 10,
          min:0,
          max:60
         }
     },

     cursor: {
         show: true
     }
  });
// add our hook, to fire after a series update
  $.jqplot.postDrawSeriesHooks.push(updatedSeries);

  function updatedSeries() {
    console.log(plot1.series[0].data); //data for the series is here
    var dragArray = plot1.series[0].data;
    $.getJSON("savedrag.php", {dragArray:dragArray});
  }
}

0 个答案:

没有答案