Book Image

Highcharts Cookbook

By : Nicholas Terwoord
Book Image

Highcharts Cookbook

By: Nicholas Terwoord

Overview of this book

<p>Highcharts is a JavaScript library that enables web developers to create a wide range of different, highly customized charts. Highcharts easily integrates with existing JavaScript frameworks and is simple enough to make a column chart in a few lines of code, but flexible enough to handle more complex charting scenarios such as viewing multiple chart types with different data sources on a multitude of devices and form-factors.</p> <p>"Highcharts Cookbook" is a practical guide that provides you with clear, step-by-step recipes to create dynamic, functional charts in your web applications using Highcharts. With "Highcharts Cookbook", you will create and design dynamic and versatile charts in different scenarios.</p> <p>"Highcharts Cookbook" through its wide array of recipes will walk you through everything you need to know about Highcharts and will enable you to unleash its full potential in your web applications quickly and easily.</p> <p>You will learn how to integrate Highcharts with different frontend and backend libraries such as ExtJS, jQuery, and the Yii framework with some examples in Python, PHP, and NodeJS. You will also cover how to handle user interactions like form input and mouse events, how to fetch remote data in CSV, XML, and JSON format, and how to render charts for offline usage. If you want to learn the different ways you can leverage the power of Highcharts to create, integrate and extend its features in your application, then this book is for you.</p>
Table of Contents (19 chapters)
Highcharts Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Welcome to Highcharts Cookbook. Highcharts is a charting library that makes it easy to create interactive, configurable charts using just pure JavaScript and HTML5. It supports a variety of different chart types, has an extensive set of documentation, and even has helpful support available. This book explores how it is possible to integrate Highcharts into a variety of applications, focusing on some of the more common applications.

If it seems daunting to get started with something new, such as Highcharts, there's no need to worry. Everyone has been where you are now: beginning a journey to learn something new. In this case, if you're unfamiliar with Highcharts (or even JavaScript) that's fine; step by step, this book will walk you through simple recipes in the first few chapters to get you up-to-speed and make you more comfortable.

If you've used Highcharts before, then you can take a look through the different recipes at your leisure, and you can work to improve your understanding of the library and how it can fit into applications. You can build on the examples to create something great. Each recipe and chapter will help you to focus on a particular area to grow and improve.

If you're a JavaScript expert, then this book will provide a lot of shortcuts. There's no need to reinvent the wheel; just find out what you want to do to accomplish your goals, get a feel for what needs to be done, and use this book to speed yourself along. Whether you are an expert or a novice, I hope that you find the recipes of this book useful, and that they aid you in accomplishing your goals.

What this book covers

Chapter 1, Getting Started with Highcharts, covers the basics of setting up a simple page with Highcharts and quickly explores common scenarios a developer may encounter.

Chapter 2, Processing Data, dives into the different input sources for a chart and how those sources connect to our chart.

Chapter 3, Handling User Interaction, shows how we can customize charts to provide richer interactions and visualizations.

Chapter 4, Sharing Charts on the Web, demonstrates how we can send charts to others, online or offline.

Chapter 5, Integrating with ExtJS, shows how we can start building rich desktop-like applications using Highcharts.

Chapter 6, Integrating with jQuery, covers how we can leverage jQuery and its various plugins to create and display charts.

Chapter 7, Integrating with the Yii Framework, demonstrates how we can use Highcharts in a PHP application.

Chapter 8, Integrating with Other Frameworks, looks at some of the more popular Web frameworks and tools and how we can get them up and running with Highcharts.

Chapter 9, Extending Highcharts, takes us one step further into working with the internals of Highcharts and how we can create our own chart extensions.

Chapter 10, Math and Statistics, dives into how we can use Highcharts to graph and display data of a more mathematical and scientific nature.

Chapter 11, System Integration, covers a few interesting connections with system resources and how we can use Highcharts to visualize that data.

Chapter 12, Other Inspirational Uses, takes a look at how we can use what we've learned in the previous chapters as well as leveraging HTML5 APIs and other odds and ends to create really interesting applications without a lot of code.

What you need for this book

While this book focuses primarily on Highcharts, there are a number of tools that we will leverage to make the recipes possible. Usually, all the required tools are mentioned in the Getting ready section of a recipe. The following are a few of the required tools:

  • Node.js (http://nodejs.org/): This is a platform for creating JavaScript applications on the server side. This book was written assuming version 0.10.24 or higher is being used.

  • Bower (http://bower.io/): This is a package manager for our JavaScript dependencies. This book was written assuming version 1.2.8 or higher is being used.

  • Git (http://git-scm.com): This is a distributed version control system needed for certain recipes and to install certain packages with Bower. This book was written assuming version 1.8 or higher is being used.

  • Python (http://www.python.org/): This is a programming language used in some recipes for server-side examples. This book was written assuming version 2.7 of Python is being used, and it is unlikely that these examples will work in Python 3 or higher.

  • pip (http://pip-installer.org/): This is a package manager for Python. This book was written assuming version 1.4 or higher is being used.

  • PHP (http://php.net): This is a general-purpose scripting language used in some recipes for server-side examples. This book was written assuming version 5.3 or higher is being used.

  • Web browser: Any recent version of Firefox, Chrome, Internet Explorer, or Safari should work fine.

Who this book is for

I've done my best to make this book as easy to read as possible for anyone with a technical background. However, this book will be easier to understand and more useful for JavaScript developers or other developers working on web applications.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Charts are created by making instances of a Highcharts.Chart object, either directly via its constructor or indirectly using plugins developed for different JavaScript frameworks."

A block of code is set as follows:

{
  "name": "my-project",
  "dependencies": {
    "highcharts": "~3.0",
    "jquery": "^1.9"
  }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

var options = {
    // ...
    tooltip: {
        formatter: function() {
            return 'We have ' + this.y + ' ' + this.point.options.category + 's'
        }
    }
}

Any command-line input or output is written as follows:

pip install bottle==0.11.6

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the By hour button, as shown in the following screenshot."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/9688OT_Images.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.