Results 1 to 4 of 4

Thread: Qwt Histogram Data Labels

  1. #1
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Qwt Histogram Data Labels

    Hello all,
    Does anyone know of a nifty way to add data labels (i.e. the value of the bar) on a histogram plot. I have a simple histogram displaying correctly, but would really like to be able to show the value of the bar on top, similar to an excel chart.

    I am running Windows Vista, Qt Creator 1.2.1 (Qt 4.5.2), Qwt5.2

    Thanks for any help you can provide!
    AlphaWolfXV

  2. #2
    Join Date
    Mar 2009
    Location
    Tennessee, US
    Posts
    41
    Thanks
    3
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Smile Re: Qwt Histogram Data Labels

    Does anyone know of a nifty way to add data labels (i.e. the value of the bar) on a histogram plot. I have a simple histogram displaying correctly, but would really like to be able to show the value of the bar on top, similar to an excel chart.
    You need to draw the text manually on top of your plot histogram. To do so, overlaod your HistPlot::drawCanvas function.
    Qt Code:
    1. class HistPlot : public QwtPlot
    2. {
    3. void drawCanvas(QPainter * painter)
    4. {
    5. // Let the original canvas draw itself.
    6. QwtPlot::drawCanvas(painter);
    7.  
    8. // Now draw your text on top
    9. }
    10.  
    11. };
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to amoswood for this useful post:

    penny (5th January 2011)

  4. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt Histogram Data Labels

    When you are using QwtPlotHistogram from trunk you could overload drawColumn. All you need to do is to add some layout code for the text rectangle and a painter->drawText() ( or better QwtPainter::drawText() if you want to print/export your plot ).

    Uwe

  5. The following user says thank you to Uwe for this useful post:

    AlphaWolfXV (10th June 2010)

  6. #4
    Join Date
    Mar 2009
    Location
    Tennessee, US
    Posts
    41
    Thanks
    3
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt Histogram Data Labels

    Yeah, that would probably be a better solution.
    Amos
    Qt Programmer Extraordinaire

    Current Work:
    Ripxx Sports Measurement Device - www.ripxx.com
    (Featured in MYTHBUSTERS on 2010-05-19 in S08E08)

Similar Threads

  1. Histogram
    By giusepped in forum Qwt
    Replies: 1
    Last Post: 9th March 2010, 08:54
  2. Gradient in histogram
    By giusepped in forum Qwt
    Replies: 1
    Last Post: 1st August 2009, 11:48
  3. Histogram axis labels as text
    By DKGear in forum Qwt
    Replies: 1
    Last Post: 30th December 2008, 08:54
  4. Qwt(histogram) in eclipse?
    By kid17 in forum Qwt
    Replies: 1
    Last Post: 29th November 2008, 12:38
  5. How display an histogram?
    By kid17 in forum Qt Programming
    Replies: 3
    Last Post: 24th November 2008, 15:22

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.