Skip to content Skip to sidebar Skip to footer

Flot Charts- Producing Custom Trend With Unique X-axis Values

I have DB relation that holds information that I wish to display. each record holds a numerical value, and a 'name' that looks like '20140325_064532'. The order of creating the rec

Solution 1:

Well, you got most of the way there, I just finished it off for you...

Basic issues:

  • Data format is [[x1,y1],[x2,y2],...

     data: [[all_series_data[i][0],all_series_data[i][1]]]
    
  • Specify ticks correctly (this just grabs every odd one)

    tick_labels = []
    for series, i in all_series
        if i % 2
            tick_labels.push [i,series]
        else
            tick_labels.push [i,'']  
    

and then in your plot options:

xaxis:ticks:tick_labels
  • include the tooltip library and use it in the default way. I used a copy from a CDN.
  • fix a basic coffeescript syntax error (probably just from copying it over here). In your GenerateChartOptions you open a ( and never close it at the end.

Here's a working example: http://jsfiddle.net/ryleyb/0tn1uzs9/2/

Based on comments I added this to the example:

#in the flot options
        tooltipOpts:
            content: Chart.getToolTip

#to the Chart object
getToolTip: (label, xval, yval, flotItem) ->
    return'Run: '+raw_data[xval][3]+': value: '+Chart.commify(yval)
commify: (x) ->
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");

Post a Comment for "Flot Charts- Producing Custom Trend With Unique X-axis Values"