0

I'm using jqBarGraph to draw a graph on a page, but after the page loads, the graph updates with new values. How do I redraw the graph?

I'm updating the array I'm used to initialize the graph and then re-using it to initalize the graph (occurs within an each()).

Initial array:

array_msa_graph_1 = new Array(
    [12300, 'MSA', '#88c100'],
    [0, 'Gap', '#5e8500'],
    [12300, 'ATB', '#74a400']
);

jQuery('#msa_graph_1').jqbargraph({
    data: array_msa_graph_1
});

Updating array:

var graph_id = $(this).find('.msa_graph').attr('id');
var array_name = 'array_' + graph_id;
var graph_array = eval(array_name);

var msa_value = getMSA(graph_id);

graph_array[0][0] = msa_value;

$('#' + graph_id).jqbargraph({
    data: graph_array
});

However, in the redraw process, it seems the array gets appended to the already existing graph and doesn't update the existing columns and labels.

What am I doing wrong?

Anriƫtte Myburgh
  • 13,347
  • 11
  • 51
  • 72

1 Answers1

1

Woah, this is quite an old post. I am also implementing bar graph using this plugin. I was having this trouble yesterday. I managed to solve this issue by taking a look at their page source. I found out that the person was able to clear the modification made on the graph. Hence, is this line of code that reset the values. $('#DivforGraph').html(''); //reset graph during dynamic change :)

*I will post the solution here.Maybe it might benefit someone who is facing the same problem as us! Cheers! ^_^

user3659911
  • 177
  • 1
  • 1
  • 12