Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6683031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:46:26+00:00 2026-05-26T04:46:26+00:00

I have the script below for a graphing system named flot, available to download.

  • 0

I have the script below for a graphing system named flot, available to download. Basically what would be the best way to dynamically change the content of the array VAR data?? so I have a table of users and depending on the user I click on it populates that array with values, maybe when the page is first loaded i gather the data from php for all the users in the table (maybe 20 users max) then an onclick event which populates the var data variable and changes the graph. Just not sure how to go about doing it?? or even if I can.

Any help would be great thanks.

  <div id="placeholder" style="width:600px;height:300px"></div>
  <p><input id="clearSelection" type="button" value="Clear selection" />

  <input id="setSelection" type="button" value="Select year 1994" /></p>
  <p><label><input id="zoom" type="checkbox" />Zoom to selection.</label></p>

<script type="text/javascript">
$(function () {
var data = [
    {
        label: "United States",
        data: [[1990, 40.9], [1991, 18.7], [1992, 18.4], [1993, 19.3], [1994, 19.5], [1995, 19.3]]
    }
];

var options = {
    series: {
        lines: { show: true },
        points: { show: true }
    },
    legend: { noColumns: 2 },
    xaxis: { tickDecimals: 0 },
    yaxis: { min: 0 },
    selection: { mode: "x" }
};

var placeholder = $("#placeholder");

placeholder.bind("plotselected", function (event, ranges) {
    $("#selection").text(ranges.xaxis.from.toFixed(1) + " to " + ranges.xaxis.to.toFixed(1));

    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").text("");
});

var plot = $.plot(placeholder, data, options);

$("#clearSelection").click(function () {
    plot.clearSelection();
});

$("#setSelection").click(function () {
    plot.setSelection({ xaxis: { from: 1994, to: 1995 } });
});

});

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:46:27+00:00Added an answer on May 26, 2026 at 4:46 am

    If your user data on page load looked something like this

    var users = [
        {
            name: "User1",
            label: "United States",
            data: [[1990, 40.9], [1991, 18.7], [1992, 18.4], [1993, 19.3]]
        },
        {
            name: "User2",
            label: "Germany",
            data: [[1990, 40.6], [1991, 18.2], [1992, 18.9], [1993, 19.4]]
        },
        {
            name: "User3",
            label: "Mexico",
            data: [[1990, 30.6], [1991, 28.2], [1992, 38.9], [1993, 29.4]]
        }
    ];
    

    You could then dynamically write some clickable content . . .

    for(var i = 0; i < users.length; i++) {
        $('body').append('<div class="user">' + users[i].name + '</div>');
    
        //store the data on the element itself
        $('.user:last').data.user_data = users[i];
    }
    
    //set up the click events
    $('.user').each(function() {
        $(this).click(function(evt) {
            //set your data object using some of the user data
            data = $(this).data.user_data.data;
    
            //redraw the graph
        });
    });
    

    One thing to note is the data object you are using needs to be in a context/scope accessible from within the click event. I shortened the data sets just to demonstrate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have below script: $(document).ready(function () { $(#dpProject).change(function () { var idModel = $(this).val();
I have this script below, where I want to download a pdf from a
Hi I have script below: Basically I have a navigation anchors next and prev
I have a NAnt script like below: <if test=${a}>${b}> <call target=target/> </if> What I
I have a NAnt script like below: <target name=Init unless=${target::has-executed('Init')}> What I want is
I have a bash script as below, and I want it to read two
I have tested the below script on a demo page which is not using
I have a script snippet looks like below: <ItemGroup> <files Include=*.txt></files> </ItemGroup> <Message Text=@(files)>
I have a Perl script which nests foreach loops as seen below. It takes
I have a python script which outputs lots of data, sample is as below.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.