Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Sencha Charts Essentials
Sencha Charts Essentials

Sencha Charts Essentials: Create stunning charts and visualizations for both web and mobile applications

eBook
$18.99 $21.99
Paperback
$26.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Sencha Charts Essentials

Chapter 2. Working with Out-of-the-box Charts

In the previous chapter, we saw how one can create a chart using the Sencha Charts Surface API. The only issue is that Surface is still a very low-level API providing drawing primitives, which can be used to create any drawing, including charts. We will have to write a lot of code to create a chart using these drawing primitives, handling events, resizing charts, data binding, theming, and so on.

In this chapter, we will move up in terms of API abstraction and look at the chart-related API, which we can use for visual presentation. In this chapter, you will learn the following topics:

  • Creating cartesian charts—line, bar, area charts
  • Creating polar charts—pie chart
  • Creating spacefilling charts—gauge chart
  • Theming your charts
  • Engaging users with gestures

Types of charts

Sencha Charts supports the following types of charts:

  • Cartesian charts: These charts are based on a two-dimensional coordinate system or the cartesian coordinate system. This is where the position of a point is determined based on its (x, y) coordinate. Typical examples are area charts, bar charts, and line charts.
  • Polar charts: These charts are based on the polar coordinate system. This is a two-dimensional coordinate system where the position of a point in the plane is determined based on its distance from a fixed point and angle from a fixed direction. Typical examples are Pie and Radar.
  • Spacefilling charts: These charts fill the entire space/area of the chart. For example, Treemap and Gauge.

The following screenshot shows the different types of Sencha Charts:

Types of charts

Anatomy of a chart

A chart has different areas. Each area has its own name. These names will act as the terminology that Sencha Charts will use and they will be used throughout this book. The following diagram depicts a cartesian chart created using Sencha Charts with its different areas:

Anatomy of a chart

Let's take a look at a few of the terminologies highlighted in the preceding figure:

  • Sprite: This is an object that is rendered on a drawing surface—Ext.draw.Surface—which we discussed in the previous chapter. Sencha Charts offers many different types of sprite, such as arc, circle, rectangle, path, and text, all of which are used internally to create different types of chart. They can also be added directly to a chart. In the preceding diagram, a text sprite is used to show the chart title.
  • Series: This class is very specific to the type of chart that we want to draw. For example, Sencha Charts uses area series to draw area charts, whereas bar series draw bar charts. Based on the samples...

Creating a cartesian chart

We will start by making a cartesian chart. A cartesian chart must have axes and a series along with the dataset:

  1. Create a project using Sencha Cmd with SCE as the application name.
  2. Edit the app/view/main/Main.js file and replace its contents with the following code to create a cartesian chart that shows quarterly sales and quarterly orders:
    Ext.define('SCE.view.main.Main', {
       extend: 'Ext.container.Container',
    
           xtype: 'app-main',
       
       layout: {
           type: 'fit'
       },
    
       items: [{
           xtype: 'cartesian',
           title: 'Chart',
           height: 500,
           width: 500,
           insetPadding: 40,
           legend: true,
           store: {
               fields: ['month', 'sales', 'order'],
               data: [
                   { month: 'Q1', sales: 100, order: 20 },
                   { month: 'Q2', sales: 250, order: 120 },
                   { month:...

Creating a polar chart

Pie and Radar are out-of-the-box polar charts provided by Sencha Charts. These charts use the polar coordinate system to draw sprites. Pie series does not require an axes configuration. However, Radar series does require axes configuration, one radial and another angular.

Let's see how we create a polar chart with a pie series.

Create a project using Sencha Cmd with SCE as the application name. Edit the app/view/main/Main.js file and replace its contents with the following code:

Ext.define('SCE.view.main.Main', {
   extend: 'Ext.container.Container',

       xtype: 'app-main',
   
   layout: {
       type: 'fit'
   },

   items: [{
       xtype: 'polar',
       title: 'Chart',
       height: 500,
       width: 500,
       store: {
           fields: ['sample', 'value'],
           data: [
               { sample: '1', value: 100 },
               { sample: '2', value...

Creating a spacefilling chart

A spacefilling chart does not have a coordinate requirement. It occupies the available area with the chart. Treemap, heatmap, and gauge charts are some examples. Treemap and heatmap charts do not come with Sencha Charts. Gauges, however, does come along with it. Let's see how to use it in an application.

Create a project using Sencha Cmd with SCE as the application name. Edit the app/view/main/Main.js file and replace its contents with the following code:

Ext.define('SCE.view.main.Main', {
   extend: 'Ext.container.Container',

       xtype: 'app-main',
   
   layout: {
       type: 'fit'
   },

   items: {
       xtype: 'spacefilling',
       series: {
           type: 'gauge',
           minimum: 100,
           maximum: 800,
           value: 400,
           donut: 30,
           needle: true,
           colors: ['orange', 'blue']

       }
   }
});

The preceding code uses...

Types of charts


Sencha Charts supports the following types of charts:

  • Cartesian charts: These charts are based on a two-dimensional coordinate system or the cartesian coordinate system. This is where the position of a point is determined based on its (x, y) coordinate. Typical examples are area charts, bar charts, and line charts.

  • Polar charts: These charts are based on the polar coordinate system. This is a two-dimensional coordinate system where the position of a point in the plane is determined based on its distance from a fixed point and angle from a fixed direction. Typical examples are Pie and Radar.

  • Spacefilling charts: These charts fill the entire space/area of the chart. For example, Treemap and Gauge.

The following screenshot shows the different types of Sencha Charts:

Anatomy of a chart


A chart has different areas. Each area has its own name. These names will act as the terminology that Sencha Charts will use and they will be used throughout this book. The following diagram depicts a cartesian chart created using Sencha Charts with its different areas:

Let's take a look at a few of the terminologies highlighted in the preceding figure:

  • Sprite: This is an object that is rendered on a drawing surface—Ext.draw.Surface—which we discussed in the previous chapter. Sencha Charts offers many different types of sprite, such as arc, circle, rectangle, path, and text, all of which are used internally to create different types of chart. They can also be added directly to a chart. In the preceding diagram, a text sprite is used to show the chart title.

  • Series: This class is very specific to the type of chart that we want to draw. For example, Sencha Charts uses area series to draw area charts, whereas bar series draw bar charts. Based on the samples/data, the series...

Creating a cartesian chart


We will start by making a cartesian chart. A cartesian chart must have axes and a series along with the dataset:

  1. Create a project using Sencha Cmd with SCE as the application name.

  2. Edit the app/view/main/Main.js file and replace its contents with the following code to create a cartesian chart that shows quarterly sales and quarterly orders:

    Ext.define('SCE.view.main.Main', {
       extend: 'Ext.container.Container',
    
           xtype: 'app-main',
       
       layout: {
           type: 'fit'
       },
    
       items: [{
           xtype: 'cartesian',
           title: 'Chart',
           height: 500,
           width: 500,
           insetPadding: 40,
           legend: true,
           store: {
               fields: ['month', 'sales', 'order'],
               data: [
                   { month: 'Q1', sales: 100, order: 20 },
                   { month: 'Q2', sales: 250, order: 120 },
                   { month: 'Q3', sales: 75, order: 40},
                   { month: 'Q4', sales: 120, order: 25}
               ]
           },
           axes: [{
        ...
Left arrow icon Right arrow icon

Description

If you are an Ext JS or Sencha Touch developer, designer, or architect who wants to build enterprise-scale data visualization capabilities using Sencha, then this book is ideal for you. You should have a knowledge of HTML, JavaScript, CSS, and Sencha Ext JS or Sencha Touch fundamentals, in particular. Some familiarity with SVG and HTML5 Canvas would be preferred, but not required.

Who is this book for?

If you are an Ext JS or Sencha Touch developer, designer, or architect who wants to build enterprise-scale data visualization capabilities using Sencha, then this book is ideal for you. You should have a knowledge of HTML, JavaScript, CSS, and Sencha Ext JS or Sencha Touch fundamentals, in particular. Some familiarity with SVG and HTML5 Canvas would be preferred, but not required.

What you will learn

  • Set up and configure Sencha Charts and understand its extensibility capabilities
  • Create interactive HTML5 charts that are portable across the Web and touch/mobile
  • Deliver rich, professional, and engaging visualizations of complex, customized data including financial data, infographics, and so on
  • Understand the basic building blocks and the overall architecture of Sencha Charts
  • Get to grips with SVG and Canvas APIs to draw basic geometrical shapes
  • Create different types of charts, such as cartesian, polar, and spacefilling, in your application using outofbox charts from Sencha Charts
  • Compare Sencha Charts with other charting libraries/SDKs

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 30, 2015
Length: 214 pages
Edition : 1st
Language : English
ISBN-13 : 9781785288487
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : May 30, 2015
Length: 214 pages
Edition : 1st
Language : English
ISBN-13 : 9781785288487
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 130.97
Sencha Charts Essentials
$26.99
Ext JS Application Development Blueprints
$48.99
Learning Ext JS_Fourth Edition
$54.99
Total $ 130.97 Stars icon

Table of Contents

10 Chapters
1. Fundamentals of Sencha Charts Chevron down icon Chevron up icon
2. Working with Out-of-the-box Charts Chevron down icon Chevron up icon
3. Sencha Charts Architecture Chevron down icon Chevron up icon
4. Creating a Custom Cartesian Chart Chevron down icon Chevron up icon
5. Creating a Custom Polar Chart Chevron down icon Chevron up icon
6. Creating a Custom Spacefilling Chart Chevron down icon Chevron up icon
7. Theming Chevron down icon Chevron up icon
8. Working with Touch Gestures Chevron down icon Chevron up icon
9. Comparison with Other JavaScript Charting Libraries Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(1 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Philip Arad Sep 02, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If you are an Ext JS or Sencha Touch developer who wants to build enterprise-scale data visualization using Sencha, this book is ideal for you.Sencha Charts is a new and powerful library used to create rich and beautiful charts for your Mobile Sencha Touch and Ext JS applications. Built in HTML5, Sencha Charts is optimized for performance and fully support gestures and touch devices on mobile, thus making visualizing data effortless.With your knowledge of HTML, JavaScript, CSS, and Sencha Ext JS or Sencha Touch fundamentals, you will be able to upgrade your application on desktop and mobile, to meet enterprise standard.First in the book, you will get familiar with charting fundamentals and then engage with the Sencha Charts architecture. You will then learn how to use out-of-the-box charts, and then create your own custom Cartesian, polar, and space filling charts to visualize your own data.Finally, you will see how Sencha Charts compares with other charting libraries for all your data expression needs.During your studies you will discover out-of-the-box enterprise visualizations, develop your own custom charts and learn to make your charts work on desktop and touch-sensitive devicesYou will create interactive HTML5 charts that are portable across the Web and touch/mobile and deliver rich, professional, and engaging visualizations of complex, customized data including financial data, infographics, and so on.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.