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

  • Home
  • SEARCH
  • 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 7539507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:24:00+00:00 2026-05-30T07:24:00+00:00

I am using Flot to create graphs. This is my Code here jsFiddle code

  • 0

I am using Flot to create graphs.
This is my Code here jsFiddle code

function drawSeriesHook(plot, canvascontext, series) {
var ctx = canvascontext,
    plotOffset = plot.offset(),
    labelText = 'VALUE', // 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.color === '#F8C095') {
    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();
}
}
  1. In My drawseriesHook function i need to get the x axis labels like Data1,Data2,Data3,Data4
  2. Is there any way to uniquely identify the last data item without using series.label & series.color.Currently i have identified it by modifying the series.color in the function
  • 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-30T07:24:01+00:00Added an answer on May 30, 2026 at 7:24 am

    1.) Ok, I think you want to set labelText for each bar. Add the following line in the for-loop:

    labelText = series.xaxis.ticks[i / ps].label;
    

    Also see the updated example.

    2.) You can add own values to data, e.g. to mark the last one:

    var data = [
        {
            label : 'Used',
            color : '#EF7816',
            data : [ [ 1, 85], [ 2, 50 ], [ 3, 18], [ 4, 8 ] ],
            last : false
        },
        ...
        {
            color : '#F8C095',
            data : [ [ 1, 12], [ 2, 10], [ 3, 3], [ 4, 2] ],
            last : true
        }
    ];
    

    In your hook you can check the flag:

    if (series.last) { ...
    

    Also see the next updated example.

    • 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 generate bar graphs. Here is my code bar graph
I'm using flot api to draw charts. Look at this chart type HERE .
I'm using a javascript library called flot (http://code.google.com/p/flot/) to render graphs and charts and
Hi I need to create a flot graph. for that I am using this
I have a bar chart created using flot jsFiddle Code Now i need to
Can I plot charts like this http://developer.yahoo.com/yui/examples/charts/charts-rotation.html using flot ? I mean, I have
Okay to get started I am using Jquery-Flot to plot a radial graph I
I am using flot to create bar charts like I need to specify a
I'm using Flot and would like to associate text with each individual plot point
I'm running the code below and getting an empty chart using Flot/jQuery. Ideally what

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.