Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String based axis for jQuery Flot graphs?

How do I get non-numeric values on a Flot graph axis?

For example, on the Y-axis I would like to have (excuse the crappy graph):

/*
    A|
    B|          _/*----------*
    C|        _/              \
    D|      _/                 \
    E|    _/                    \
    F|   /                       \
    G|  *                         *
      --------------------------------
       100        200       300   400

The data I would provide will look like this: var data = [[100, 'G'], [200, 'B'], [300, 'B'], [400, 'G']];

like image 365
Bill Software Engineer Avatar asked Dec 29 '22 06:12

Bill Software Engineer


1 Answers

You can also associate text with a tick value, like this:

ticks: [[0, "G"], [1, "F"], [2, "E"], [3, "D"]], // so on

The nice thing about doing it this way is you can control it completely at runtime from your AJAX call (assuming you pass down the axis configuration using JSON), whereas the currently posted solution requires a hard-coded function.

like image 171
DarrellNorton Avatar answered Dec 31 '22 15:12

DarrellNorton