diegoaguilar
diegoaguilar

Reputation: 8376

Plotting x and y axis in a JavaScript generated chart with Flot library?

I'm using flot library and I found from the docs that I can send a json object with any option I can right at the charting call.

So let's say I call:

$.plot($("#placeholder"), [ [] ], { yaxis: { show: true, max: 100, min: -100 }, xaxis: { show: true, max: 100, min: -100} });

However this is what I get as result (with a non empty data argument):

Obtained plot

But I don't want vertical lines marked at every axis tick, but two lines corresponding to the axis.

I don't want ending with the x=0 and y=0 plots. I would even have to obtains points arrays for it. How can I do this with flot or is there any recommended library to plot x,y points series with not much thrills.

Upvotes: 0

Views: 257

Answers (1)

Raidri
Raidri

Reputation: 17550

To get lines on the axes, add this to your options object:

grid: { markings: [{ xaxis: { from: 0.0, to: 0.0 }, color: 'black', lineWidth: 1 },
      { yaxis: { from: 0.0, to: 0.0 }, color: 'black', lineWidth: 1 }] };

If the other lines are still present after adding this, please provide a more complete example (e.g. a fiddle).

Upvotes: 1

Related Questions