¿Cómo puedo construir un gráfico de barras jquery / flot, sin las líneas del eje vertical?

I am exploring flot, the jquery graphing library.

I'd like to be able to create a bar chart. Seems like it was not really set up for this. If I contort my data a little, I can get it to mostly do what I envision. Using this code:

  var dataSet = [
    [ 15132, "Inez" ],
    [ 21441, "Rocky" ],
    [ 29141, "Jim" ],
    [ 18211, "Sophia" ],
    [ 17556, "Perry" ],
    [ 32251, "Jorge" ],
    [ 43560, "Madison" ],
    [ 20180, "Gil" ],
    [ 12180, "Fran" ],
    [ 31018, "Sheila" ],
    [ 45143, "Nial" ],
  ];


  function plotChart() {
    var d1, xaxisLabels = [], i=0;

    d1 = dataSet.map(function(elt){return {label: elt[1], data: [[i++, elt[0]]]};});
    i = 0;
    // example for xaxis option: {ticks: [[1,'One'], [2,'Two'], [3,'Three'], [4,'Four'], [5,'Five']]},
    xaxisLabels = dataSet.map(function(elt) { return [i++, elt[1]]; });
    $.plot($("#chart1"),
           d1,
           {
             legend: {
               show: true,
               container: $('#legend1'),
             },
             series: {
                   bars: {
                     show       : true,
                     align      : 'center',
                     //dataLabels : true,
                     barWidth : 0.4
                   }
             },
             xaxis: { ticks: xaxisLabels },
             yaxis: {
                   ticks: 10
             },
             grid: {
                   show: true,
                   backgroundColor: { colors: ["#fff", "#eee"] }
             }
           });
}

$(document).ready(plotChart);

Esto es lo que obtengo:

enter image description here

That's pretty good. But I'd like to remove the vertical axis lines. These might make sense in a line chart, but not in a bar chart.

¿Alguien sabe cómo puedo hacer eso?

preguntado el 27 de agosto de 11 a las 19:08

1 Respuestas

Todo lo que necesitas es

xaxis: { tickLength: 0 }

Respondido 28 ago 11, 00:08

Whoa! Really? I thought I had tried that. Thanks - much simpler. How embarassing! - Cheeso

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.