faheem801 / flot

Automatically exported from code.google.com/p/flot
MIT License
0 stars 0 forks source link

data transfer with Flot and PHP #414

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello! I have a code for Flot chart building in my PHP project:
(as example http://people.iola.dk/olau/flot/examples/selection.html)

<script id="source" language="javascript" type="text/javascript">

$(function () {
    //data for chart build
    var datasets = {
        "DP": {
            label: "DP / ln(t)",
            data: [<?php
            for ($g=2; $g<$b-1; $g++) echo "[".$lnT[$g].", ".$DP[$g]."],";
                echo "[".$lnT[$g].", ".$DP[$g]."]";
                $g=2;
                ?>]
                }
    };

    //select on function of flot
    var options = {
        series: {
            lines: { show: true },
            points: { show: true }
        },
        legend: { noColumns: 1 }, //кол-во колонок легенды
        crosshair: { mode: "x" }, //включение прицела
        grid: { hoverable: true, autoHighlight: false },
        yaxis: { min: 0 }, //начало отсчета координат для оси 0Y
        selection: { mode: "x" } //включаем функцию выделения части графика
    };

    // select color
    var i = 0;
    $.each(datasets, function(key, val) {
        val.color = i;
        ++i;
    });

    // insert checkbox
    var choiceContainer = $("#choices");
    $.each(datasets, function(key, val) {
        choiceContainer.append('<br/><input type="checkbox" name="' + key +
                               '" checked="checked" id="id' + key + '">' +
                               '<label for="id' + key + '">'
                                + val.label + '</label>');
    });
    choiceContainer.find("input").click(plotAccordingToChoices);

    // print Flot Chart
    function plotAccordingToChoices() {
        var data = [];

        choiceContainer.find("input:checked").each(function () {
            var key = $(this).attr("name");
            if (key && datasets[key])
                data.push(datasets[key]);
        });

        if (data.length > 0)
            $.plot($("#placeholder1"), data, options);
    }
    plotAccordingToChoices();

    //print select X1 & X2 

    var placeholder = $("#placeholder1");
        placeholder.bind("plotselected", function (event, ranges) {
        $("#selection_start").text(ranges.xaxis.from.toFixed(3));
        $("#selection_end").text(ranges.xaxis.to.toFixed(3));

        var zoom = $("#zoom").attr("checked");
        if (zoom)
            plot = $.plot(placeholder, data,
                          $.extend(true, {}, options, {
                              xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
                          }));
    });

    placeholder.bind("plotunselected", function (event) {
        $("#selection_start").text("");
        $("#selection_end").text("");
    });

});

 // transfer selected data X1 to server
function start_math(){

    window.location.href="/index.php?iii="+ranges.xaxis.from;
    alert("Transfer : " + ranges.xaxis.from);
}
</script>

I need transfer selected X data to server , this part of JavaScript responsible 
for transferring, but don't work.

What is the problem? 

Thanks for help!

Original issue reported on code.google.com by anthony....@gmail.com on 7 Sep 2010 at 9:52

Attachments:

GoogleCodeExporter commented 9 years ago
agreed
I add to Flot JavaScript :

var x1,x2;
x1 = ranges.xaxis.from; 
x2 = ranges.xaxis.to;

function start_math(){
    window.location.href="/index.php?x1=" + x1 + "x2=" + x2;
}

Original comment by anthony....@gmail.com on 8 Sep 2010 at 5:06

GoogleCodeExporter commented 9 years ago
Hi!

Problems with your code is something you should take up on the Flot mailing 
list/forum, if you haven't figured it out already.

Original comment by olau%iol...@gtempaccount.com on 14 Dec 2010 at 9:42

GoogleCodeExporter commented 9 years ago

Original comment by dnsch...@gmail.com on 4 Jun 2012 at 2:39