Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to change the constant barwidth in JQuery flot bar char to variable barwidth
    primarykey
    data
    text
    <p>I am plotting a dynamic barchart using flot. I have managed to plot with constant barwidth. Now I want the barwidth to vary based on the output of my analysis. I set <code>var options = { series: { bars:{show:true, barWidth: BarWidth, fillColor: "lightgreen", fill: true }</code> In this code, <code>BarWidth</code> is a javascript variable. My bar starts to plot and gets overlapped when my BarWidth changes. Does anyone has any clue how I can solve my problem? </p> <p>Thank you in advance!</p> <p>@DNS This is my plot function</p> <pre><code>function plot_status(statusData, no_strips) { new_data = new_data.concat([statusData]); var options = { series: { bars:{show:true, barWidth: no_strips*72, fillColor: "lightgreen", fill: true } }, grid: {clickable: true, hoverable: true, borderWidth: 1 } }; $(document).ready(function() { chart1 = $.plot($("#placeholder"), [{ data: new_data, threshold: { below: 0, color: "red" }, color: "black", xaxis: {ticks:8,minTickSize: 1}, yaxis: {min:-1,max:3,tickSize:1}, grid: { borderWidth: 1 } }],options) }); </code></pre> <p>Every four seconds, <code>statusData</code> and <code>no_strips</code> change. new_data contains a series of data that is plotted. The barchar grows with time as long as statusData is concatenated to new_data. <code>no_strips</code> determine the barWidth of each plot of the barchart. I will also include sample of barchart I would like to produce. </p> <p>With a constant <code>barWidth</code> this is what I produce</p> <p><img src="https://i.stack.imgur.com/TO1Ok.png" alt="This is a bar chart with 1200 &lt;code&gt;barWidth&lt;/code&gt;"></p> <p>This is my data: <code>[[0, 1], [1200, 1], [2400, -1], [3600, 1], ... ]; rather I was sending it</code> for my above plot. </p> <p>This is the the data I want to plot [[0, 1], [72, 1], [144, -1], [432, 1],[504,1],...]<code>every</code>[a,b]` is added every four seconds.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload