Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7591399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:38:30+00:00 2026-05-30T20:38:30+00:00

I am using flot to generate bar graphs. Here is my code bar graph

  • 0

I am using flot to generate bar graphs.
Here is my code bar graph code

  1. I need to make the y axis tick to disappear.
  2. I need to put some label on the top of each bar

How to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:38:31+00:00Added an answer on May 30, 2026 at 8:38 pm

    Okay, after a lot of mucking around with Flot and downloading the source, I finally figured out a good starting point for you.

    The jsFiddle demo is here.

    The guts of the code is using a hook for drawSeries which draws the label:

    function drawSeriesHook(plot, canvascontext, series) {
        var ctx = canvascontext,
            plotOffset = plot.offset(),
            labelText = 'TEST', // customise this text, maybe to series.label
            points = series.datapoints.points,
            ps = series.datapoints.pointsize,
            xaxis = series.xaxis,
            yaxis = series.yaxis,
            textWidth, textHeight, textX, textY;
        // only draw label for top yellow series
        if (series.label === 'baz') {
            ctx.save();
            ctx.translate(plotOffset.left, plotOffset.top);
    
            ctx.lineWidth = series.bars.lineWidth;
            ctx.fillStyle = '#000'; // customise the colour here
            for (var i = 0; i < points.length; i += ps) {
                if (points[i] == null) continue;
    
                textWidth = ctx.measureText(labelText).width; // measure how wide the label will be
                textHeight = parseInt(ctx.font); // extract the font size from the context.font string
                textX = xaxis.p2c(points[i] + series.bars.barWidth / 2) - textWidth / 2;
                textY = yaxis.p2c(points[i + 1]) - textHeight / 2;
                ctx.fillText(labelText, textX, textY); // draw the label
            }
            ctx.restore();
        }
    }
    

    See the comments for where you can customise the label.

    To remove the y-axis ticks, that is just a simple option setting. In addition, you can work out the maximum y-value for each of the bar stacks and then add about 100 to that to set a maximum Y value that will allow for the space taken up by the labels. The code for all of that then becomes:

    // determine the max y value from the given data and add a bit to allow for the text
    var maxYValue = 0;
    var sums = [];
    $.each(data,function(i,e) {
        $.each(this.data, function(i,e) {
            if (!sums[i]) {
                sums[i]=0;
            }        
            sums[i] += this[1]; // y-value
        });
    });
    $.each(sums, function() {
        maxYValue = Math.max(maxYValue, this);
    });
    maxYValue += 100; // to allow for the text
    
    
    var plot = $.plot($("#placeholder"), data, {
        series: {
            stack: 1,
            bars: {
                show: true,
                barWidth: 0.6,
            },
            yaxis: {
                min: 0,
    
                tickLength: 0
            }
        },
        yaxis: {
            max: maxYValue, // set a manual maximum to allow for labels
            ticks: 0 // this line removes the y ticks
        },
        hooks: {
            drawSeries: [drawSeriesHook]
        }
    });
    

    That should get you started. You can take it from here, I’m sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Flot to create graphs. This is my Code here jsFiddle code
I have a bar chart created using flot jsFiddle Code Now i need to
I am using flot to create bar charts like I need to specify a
Hi I need to create a flot graph. for that I am using this
I am trying to generate a graph using Flot library. var d= [ [1293840000000,332],[1293926400000,321],[1294012800000,310],[1294099200000,299],[1294185600000,288],[1294272000000,277],[1294358400000,266],[1294444800000,255],[1294531200000,244],[1294617600000,233],[1294704000000,222],[1294790400000,211],[1294876800000,200],[1294963200000,189],[1295049600000,178],[1295136000000,167],[1295222400000,156],[1295308800000,145],[1295395200000,134],[1295481600000,123],[1295568000000,112],[1295654400000,101],[1295740800000,90],[1295827200000,79],[1295913600000,68],[1296000000000,57],[1296086400000,46],[1296172800000,35],[1296259200000,24],[1296345600000,13]];
I'm using jqgrid and i need to update a graph (jquery flot) based on
I'm using a javascript library called flot (http://code.google.com/p/flot/) to render graphs and charts and
I am using Flot to graph some of my data and I was thinking
I'm trying to generate that kind of JSON String using Java (purpose : flot
I am using Flot to chart some data that I pull back from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.