Page 1 of 2 12 LastLast
Results 1 to 10 of 28

Thread: Ext.ux.chart.SmartLegend - Multi-column self adjusting Chart Legend

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha - Ext JS Dev Team nohuhu's Avatar
    Join Date
    Jun 2011
    Location
    Redwood coast
    Posts
    393
    Vote Rating
    78
      0  

    Default Ext.ux.chart.SmartLegend - Multi-column self adjusting Chart Legend

    Stock Ext JS Chart Legend is not very usable for charts with many Series points, which happens quite often. This class implements a Legend that will adjust itself to Chart dimensions to avoid ugly-looking charts.

    It looks like this:
    Screen shot 2011-11-20 at 8.21.06 PM.png

    And this:
    Screen shot 2011-11-20 at 8.33.39 PM.png

    Legend can be placed at top, bottom, left or right edge, with Chart adjusting its size accordingly. Legend items sizes are based on font used for item titles.

    Usage is very easy; in fact SmartLegend was intended a drop-in replacement for stock Legend class. See demo application for details.

    Source code is released under GPL 3.0 on Github: https://github.com/nohuhu/Ext.ux.chart.SmartLegend. Commercial licensing is also available.

    Live demo: http://nohuhu.org/demos/demo_smartlegend.html

    Sencha Market page: https://market.sencha.com/users/30/extensions/59

    Regards,
    Alex.
    Last edited by nohuhu; 14 Aug 2012 at 3:15 PM. Reason: Added demo link

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,551
    Vote Rating
    1271
      0  

    Default

    Would love to see the chart package handle this natively but now we have this! Great job!
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha - Ext JS Dev Team nohuhu's Avatar
    Join Date
    Jun 2011
    Location
    Redwood coast
    Posts
    393
    Vote Rating
    78
      0  

    Default

    Well, I said commercial licensing is available. Make me an offer.

    Regards,
    Alex.

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,551
    Vote Rating
    1271
      0  

    Default

    How about $5 USD?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  5. #5
    Sencha - Ext JS Dev Team nohuhu's Avatar
    Join Date
    Jun 2011
    Location
    Redwood coast
    Posts
    393
    Vote Rating
    78
      0  

    Default

    Mitchell,

    You mean $5 per copy? I'll throw TitleChart in for $7 and call it a deal. What say you?

    Regards,
    Alex.

  6. #6
    Sencha - Ext JS Dev Team nohuhu's Avatar
    Join Date
    Jun 2011
    Location
    Redwood coast
    Posts
    393
    Vote Rating
    78
      0  

    Default

    Version 0.99 supports Ext JS 4.1.
    Regards,
    Alex.

  7. #7
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    1,017
    Vote Rating
    125
      0  

    Default

    I just tried it. Works nicely! The only thing I didn't admit is:
    Code:
    chart.legend.redraw(); 
    chart.redraw();
    in the Demo.

    I would use it like this:
    Code:
    Ext.chart.Chart.prototype.initComponent = Ext.Function.createSequence(Ext.chart.Chart.prototype.initComponent, function() {
        this.legend = Ext.create('Ext.ux.chart.SmartLegend', {
            position: 'right',
            chart: this,
            rebuild: true,
            boxStrokeWidth: 1
        });
    });
    Object.NET
    Frameworks and Tools for .NET Developers
    --------------------------------------------------
    Ext.NET - Ext JS for ASP.NET - Examples | Twitter
    Bridge.NET - Write C#. Run JavaScript! - Live | Twitter
    --------------------------------------------------

  8. #8
    Sencha - Ext JS Dev Team nohuhu's Avatar
    Join Date
    Jun 2011
    Location
    Redwood coast
    Posts
    393
    Vote Rating
    78
      1  

    Default

    Daniil,

    Is there any compelling reason to use prototype munging instead of the normal class inheritance model? I don't see any, and you shouldn't, too.

    Regards,
    Alex.
    Regards,
    Alex.

  9. #9
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    1,017
    Vote Rating
    125
      0  

    Default

    Hi @nohuhu,

    I think it is my bad habit, thank you for pointing that out.

    You meant that I should write something like this:
    Code:
    Ext.chart.Chart.override({
        initComponent: function() {
            this.callParent();
            this.legend = Ext.create('Ext.ux.chart.SmartLegend', {
                position: 'right',
                chart: this,
                rebuild: true,
                boxStrokeWidth: 1
            });
        }
    });
    or create a new class inheriting from Chart, right?
    Object.NET
    Frameworks and Tools for .NET Developers
    --------------------------------------------------
    Ext.NET - Ext JS for ASP.NET - Examples | Twitter
    Bridge.NET - Write C#. Run JavaScript! - Live | Twitter
    --------------------------------------------------

  10. #10
    Sencha - Ext JS Dev Team nohuhu's Avatar
    Join Date
    Jun 2011
    Location
    Redwood coast
    Posts
    393
    Vote Rating
    78
      1  

    Default

    @Daniil,

    Not exactly. To override a stock class, use Ext.define instead:

    PHP Code:
    Ext.define('MyOverrides.chart.Chart', {
        
    override'Ext.chart.Chart',
        ...
    }); 
    This will allow you to take advantage of the class system, dynamic loading and Sencha Cmd build process. However, the preferred way to reuse the code is class inheritance. See my Stackoverflow answer for more explanations.

    Regards,
    Alex.
    Regards,
    Alex.

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •