DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Languages
  4. How to Display a Trendline with ExtJS 3.4

How to Display a Trendline with ExtJS 3.4

Gary Sieling user avatar by
Gary Sieling
·
Nov. 05, 12 · Interview
Like (0)
Save
Tweet
Share
5.59K Views

Join the DZone community and get the full member experience.

Join For Free

problem:

you want to display a trendline on a scatter chart in extjs 3.4.

scatter chart with trendline (extjs)
solution

use the ext.chart.chart class, but add an extra series for the trend-line, and make the colors match the corresponding series related to the trend.

discussion

extjs is able to make nice-looking charts, using yui charts, but seems to be missing basic features like trend-lines. you can simulate this behavior by pre-computing points along the line, and setting the color to match that of the relevant series. using a robust backend makes this fairly easy to compute, for instance r has functions which do most of the work for you .

using this technique you can put many series/trendlines on the same graph, and model different types of trends (e.g. logarithmic, parabolic). for further discussion of issues with the ext 3.4 charts, see the scatter plot example .

in the example below, the series are differentiated with the “alpha” parameter (visibility). it may be helpful to set the min/max on a chart like this, and if using ext 3.4 or earlier, it is necessary to set the url to the yui charts to point to a local copy of the swf file.

ext.onready(function() {
ext.chart.chart.chart_url = 'ext-3.4.0/resources/charts.swf';
   var store = new ext.data.jsonstore({
    fields: ['year', 'action', 'trend'],
    data: [
        {year: 2005, action: 23890000, trend: 26110000},
        {year: 2006, action: 38900000, trend: 36915000},
        {year: 2007, action: 50410000, trend: 47720000},
        {year: 2008, action: 56070000, trend: 58525000}
        ]
  });
 
  new ext.panel({
    width: 390,
    height: 400,
    renderto: 'container',
    title: 'scatter plot - takings by genre',
    items: {
      xtype: 'linechart',
      store: store,
      xfield: 'year',
      xaxis: new ext.chart.numericaxis({
        minimum: 2004,
        maximum: 2009,
        majorunit: 1
 
      }),
      yaxis: new ext.chart.numericaxis({
        labelrenderer: ext.util.format.usmoney,
        minimum: 20000000,
        maximum: 60000000
      }),
      series: [{
        yfield: 'action',
        displayname: 'action',
        style: {
          linealpha: 0.0
        }
      },{
        yfield: 'trend',
        displayname: 'trend',
        style: {
          linealpha: 1.0
        }
      }]
    }
  });
});


Chart trends R (programming language) Graph (Unix)

Published at DZone with permission of Gary Sieling, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Top 5 Java REST API Frameworks
  • Key Considerations When Implementing Virtual Kubernetes Clusters
  • Stream Processing vs. Batch Processing: What to Know
  • Quick Pattern-Matching Queries in PostgreSQL and YugabyteDB

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: