jquery flot: axis options

73 Views Asked by At

I am using jquery flot to display a particle detector hits, and I am unable to get it right despite seeing no difference from example code.

var options = {
  points: { show: true, fill: true,fillColor: "rgba(255,0,0 ,1)"},
  xaxis: { min: 0,  max:63, ticks:16},
  yaxis: { min: 0,  max:9, ticks:9},
  colors: ["#FF0000"],
  };

$.plot($("#placeholder1"),[
   {
     data: d1,
     points: {show: true, fill: true , fillColor: "rgba(255,0,0,1)"},
     xaxis: { min: 0, max: 63, ticks: 63},
     yaxis: { min: 0, max:9, ticks:9},
     color: "#FF0000"
   }
]);

$.plot($("#placeholder2"), [d2], options);

I have three data arrays, d1, d2 and d3. I define a variable called "options" and it works fine for display of d2, see line below with placeholder2, which gets displayed correctly as "Y-Side" in the attached graphic.

However, the options dont work when I use it as in "placeholder1" (see code). The "colors" option is executed but the xaxis and yaxis settings are ignored (see attached graphic). Is something wrong with the syntax? Please help!!

My next requirement is to add the points in data d3 to the x-side plot with different colors, Please help how to get this, too. output of the attached code clipping

Thanks a lot!

1

There are 1 best solutions below

1
Senior0023 On

You are misusing jQuery plot function. It requires three parameters. The second should be data which is an array and the third one is the option for drawing. However,in your code, you don't have the third parameter. You mixed the second and the third one. https://github.com/flot/flot/blob/master/README.md Please have a look at this.

You can never use jQuery plot function like it if it's what you intended.