MaGenTa Practical WPF Charts and Graphics

[Pages:709]The EXPERT's VOIce? in .net

Practical

WPF Charts and Graphics

Advanced chart and graphics programming with the Windows Presentation Foundation

Jack Xu

Practical WPF Charts and Graphics

Advanced Chart and Graphics Programming with the Windows Presentation Foundation

Jack Xu

i

Practical WPF Charts and Graphics

Copyright ? 2009 by Jack Xu

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.

ISBN-13 (pbk): 978-1-4302-2481-5

ISBN-13 (electronic): 978-1-4302-2482-2

Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1

Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.

Lead Editor: Ewan Buckingham Technical Reviewer: Todd Meister Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony

Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Copy Editor: Elliot Simon Compositor: MacPS, LLC Indexer: BIM Indexing and Proofreading Services Artist: April Milne

Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail ordersny@springer-, or visit .

For information on translations, please e-mail info@, or visit .

Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales?eBook Licensing web page at .

The information in this book is distributed on an "as is" basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work.

The source code for this book is available to readers at . You will need to answer questions pertaining to this book in order to successfully download the code.

ii

For my family, Ruth, Anna, Betty, and Tyler iii

Contents at a Glance

Contents at a Glance.............................................................................................iv Contents.................................................................................................................v About the Author .................................................................................................xv Technical Reviewer ............................................................................................xvi Acknowledgments .............................................................................................xvii Introduction ........................................................................................................xix Overview of WPF Programming.............................................................................1 2D Transformations .............................................................................................11 WPF Graphics Basics in 2D..................................................................................59 Colors and Brushes............................................................................................123 2D Line charts....................................................................................................163 Specialized 2D Charts........................................................................................217 Stock Charts ......................................................................................................275 Interactive 2D Charts.........................................................................................305 2D Chart Controls ..............................................................................................333 Data Interpolations ............................................................................................393 Curve Fitting ......................................................................................................419 3D Transformations ...........................................................................................445 WPF Graphics Basics in 3D................................................................................499 3D Charts with the WPF 3D Engine ....................................................................531 3D Charts Without the WPF 3D Engine..............................................................571 Specialized 3D Charts........................................................................................633 Index ..................................................................................................................673

iv

Contents

Contents at a Glance.............................................................................................iv Contents.................................................................................................................v About the Author .................................................................................................xv Technical Reviewer ............................................................................................xvi Acknowledgments .............................................................................................xvii Introduction ........................................................................................................xix

Chapter 1: Overview of WPF Programming ...........................................................1 New features in WPF ...................................................................................................... 1 XAML Basics ................................................................................................................... 2

Why Is XAML Needed?........................................................................................................................... 2 Creating XAML Files............................................................................................................................... 2 Code-Behind Files ................................................................................................................................. 3

Your First WPF Program.................................................................................................. 4

Properties in XAML ................................................................................................................................ 5 Event Handlers in Code-Behind Files .................................................................................................... 5

Code-Only Example......................................................................................................... 7 XAML-Only Example ....................................................................................................... 9 Chapter 2: 2D Transformations............................................................................11 Basics of Matrices and Transformations ...................................................................... 11

Vectors and Points............................................................................................................................... 11 Scaling................................................................................................................................................. 12 Reflection ............................................................................................................................................ 13 Rotation ............................................................................................................................................... 13 Translation........................................................................................................................................... 14

Homogeneous Coordinates........................................................................................... 15

Translation in Homogeneous Coordinates ........................................................................................... 15

v

Scaling in Homogeneous Coordinates ................................................................................................. 16 Rotation in Homogeneous Coordinates ............................................................................................... 17 Combining Transforms ........................................................................................................................ 18

vi

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches