开发者

jQplot dragable

开发者 https://www.devze.com 2023-03-10 00:08 出处:网络
I\'m using jQplot within jQuery and am trying to make the points dragable. jqplot has this functionality through the jqplot.dragable plugin

I'm using jQplot within jQuery and am trying to make the points dragable. jqplot has this functionality through the jqplot.dragable plugin

I should say that I am new to jQplot, but I do have it plotting my information correctly.

I think that I am using the dragability option correctly. (Use that link and find 'dragable:' to see an example), but something must be wrong in my code.


Here is my code. Any help is greatly appreciated.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript" src="javascript/jquery-1.5.2.min.js"></script>
<script language="javascript" type="text/javascript" src="javascript/jqplot/jquery.jqplot.js"></script>
<script language="javascript" type="text/javascript" src="javascript/jqplot/plugins/jqplot.highlighter.js"></script>
<script language="javascript" type="text/javascript" src="javascript/jqplot/plugins/jqplot.dateAxisRenderer.js"></script>
<script language="javascript" type开发者_如何转开发="text/javascript" src="javascript/jqplot/plugins/jqplot.barRenderer.js"></script>
<script language="javascript" type="text/javascript" src="javascript/jqplot/plugins/jqplot.dragable.js"></script>

<style type="text/css">
.jqplot-axis {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 90%; 
}
.jqplot-highlighter-tooltip {
    background-color: #CCC;
    padding: 5px;
    border-radius: 5px;
}
</style>

<script language="javascript" type="text/javascript">
$(function() {
    <?php 
        $series = "";

        $start = strtotime("Jan 1 2001 00:00:00");
        $end = strtotime("Dec 31 2001 00:00:00");
        for ($i = $start; $i <= $end; $i += 432000) {
            if ($i > $start) {
                $series .= ", ";
            }
            $series .= "['" . date("m/d/Y", $i) . " 00:00:00', 2]";
        }
    ?>

    var series = [<?php echo $series; ?>];

    var plot1 = $.jqplot('Chart1', [series], {
        seriesDefaults: {

        },
        series: [
            { label: 'Importance' }
        ],
        axes: {
            xaxis: {
                renderer: $.jqplot.DateAxisRenderer,
                tickOptions: { formatString: '%b %e' },
                min: "12-27-2000 00:00:00",
                max: "12-31-2001 00:00:00",
                tickInterval: "15 days"
            },
            yaxis: {
                min: -10,
                max: 10
            }
        },
        highlighter: {
            show: true,
            showMarker: false,
            tooltipAxes: 'xy',
            formatString: '%s<br />%s'
        },
        dragable: {
            color: '#FF0000',
            constrainTo: 'none'
        }
    });

    var xaxis = $('.jqplot-axis.jqplot-xaxis div');
    xaxis.first().css('display', 'none');
    xaxis.last().css('display', 'none');
});
</script>
</head>

<body>
<div id='Chart1'></div>
</body>
</html>


I was able to find the answer. 'dragable' is not a configuration option in the base of the jqplot object. 'dragable' is a configuration option within a 'series'. Also, the series must have 'isDragable' set to true.

Here the modified code for the 'series' configuration option.

series: [
    {
        label: 'Importance',
        dragable: {
            color: undefined,
            constrainTo: 'y'
        },
        isDragable: true
    }
],

ref: jqPlot options tutorial

0

精彩评论

暂无评论...
验证码 换一张
取 消