Emax
Emax

Reputation: 1047

jqplot chart with multiple line based on same Date or Time

I have the following data and i want to plot them with jqplot on line-chart with 2 lines.

series:[Time  Value1 Value2] 
      [13:51 22.875 9.275]

What I am looking for is a Chat with XAxis:Time L1:[Yaxis1:Value1] L2:[Yaxis2:Value2].

I can fairly change data structure into [Time Value1] and [Time Value2] or any other kind But It is important to plot them both in one chart together. Could you please write the scratch of the code or refer me to a proper example ? Thank you

Upvotes: 0

Views: 10640

Answers (3)

Subhash Chandra Medhi
Subhash Chandra Medhi

Reputation: 16

The 'multiple ticks for the same date' for the date-axis can be solved by including the following code snippet:

xaxis: { label: "Whatever you name it", renderer: $.jqplot.DateAxisRenderer,       min:dateVal[0], max:dateVal[dateVal.length-1], tickInterval: '1 day',

Please include min,max and tickInterval under 'xaxis:' and not under 'tickOptions:' . In my case i am having the date values in the array dateVal where the 0th element is the minimum value of date for the x-axis and the last element is the max date value. If you so wish you could hard-code the date values.

I hope this will be of help.

Upvotes: 0

Jorge Pereira
Jorge Pereira

Reputation: 11

If the time values are the same, you can do

var line1 = [val1_1, val1_2];
var line2 = [val2_1, val2_2];
var ticks = [time1, time2]
var plot = $.jqplot('chart1', [line1, line2], {
    xaxis: { ticks: ticks }
});

Upvotes: 1

Hyndrix
Hyndrix

Reputation: 4452

It's actually very easy. You define an array of values for each data line:

var line1 = [[date1, val1], [date2, val2]];
var line2 = [[date1, val11], [date2, val12]];
var plot = $.jqplot('chart1', [line1, line2]);

Upvotes: 7

Related Questions