Multi bar chat with Flot

15,873

Solution 1

Updated Info: Andión's answer makes reference to this library. Bars-side-by-side

You can download the code here: http://www.benjaminbuffet.com/public/js/jquery.flot.orderBars.js

The result is : http://i.stack.imgur.com/7X76o.png

Solution 2

Have you tried the orderBars plugin? Flot orderBars plugin

You can download the code here

Solution 3

You have to treat each bar as its own data series, so if you see 11 bars you need to create 11 data series.

Here's sample code for 2 bars.

<script id="source" language="javascript" type="text/javascript">
$(function () {

var d1 =[0, 2];
var d2 =[1,3];

var startData = [
    {   //first series
        label:"d1",
        data: [d1],
        bars:{
            show: true,
            fill: true,
            fillColor: "red"
        }
    },
    {   //second series
        label:"d2",
        data: [d2],
        bars:{
            show: true,
            fill: true,
            fillColor: "blue"
        }
    }
];

var option={
        series: {
                bars:{
                        show: true,
                        fill: true
                }
        },
        grid: {
                hoverable: true,
                clickable: true
        },
        yaxis: { ticks: 5 }
    };

$.plot($("#placeholder"),startData,option  );

});

Share:
15,873
user431514
Author by

user431514

Updated on June 05, 2022

Comments

  • user431514
    user431514 about 2 years

    Any sample code for chart with multiple bars using flot ??alt text

    similar to this example . The given patched files are not working for me. Anywhere I can download the latest files for multi bar graph.

    Update

    I am sure Flot is a very good library but plugins/add-ons are not available easily and the examples given on the website are very basic, so I decided to use jqPlot instead

  • Joe
    Joe over 13 years
    this does not work for me, i'm using flot 0.6, copy pasted this code and the bars just end up rendering over each other
  • pcproff
    pcproff about 12 years
    I would be curious to see what you are using it for Peter.
  • AbdullahDiaa
    AbdullahDiaa about 11 years
  • Andión
    Andión over 10 years
    I updated the outdated links as noted by @AbdullahDiaa and pmking