[Charts| Generating Graphic| Creating Graphic]

Slides:



Advertisements
Similar presentations
Introduction to Web Design Lecture number:. Todays Aim: Introduction to Web-designing and how its done. Modelling websites in HTML.
Advertisements

Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
PHP Sample Application Simple graphics and database.
Laboratory Study II October, Java Programming Assignment  Write a program to calculate and output the distance traveled by a car on a tank of.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
With Microsoft ® Excel 2010© 2011 Pearson Education, Inc. Publishing as Prentice Hall1 GO! with Microsoft ® Excel 2010 Chapter 1 Creating a Worksheet and.
GO! with Microsoft® Excel e
Using Microsoft Office Excel 2007
With Microsoft ® Excel e © 2013 Pearson Education, Inc. Publishing as Prentice Hall1 Excel 2010 Chapter 9 Creating a Worksheet and Charting Data.
Tutorial 5 Working with the Box Model. XP Objectives Understand the box model Create padding, margins, and borders Wrap text around an image Float a block-level.
Microsoft Excel 2010 Chapter 7
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 14 Graphics.
Higher-level PHP constructs for manipulating image files (contd.)
Agenda For Feb Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4.Read Unit 3 carefully (pages ) then.
Adobe Photoshop CS Design Professional COLORS ADJUSTING.
© 2011 Delmar, Cengage Learning Chapter 11 Adjusting Colors.
Chapter 11 Adjusting Colors. Chapter Lessons Correct and adjust color Enhance colors by altering saturation Modify color channels using levels Create.
P366: Lecture #1 Use of Excel for analysis Lei Chen, MD Jan 6, 2002.
Adobe Dreamweaver CS3 Revealed CHAPTER FIVE: USING HTML TABLES TO LAY OUT A PAGE.
PROCESSING & JAVA An Introduction to Computing. Objectives Be able to state and apply phases of development Be able to state and describe the goals of.
In this chapter, we will look at some charts and graphs used to summarize categorical data.
How To Use This Template The blank slide below will be your canvas for creating your very own custom header image! The slide has already been sized to.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved CheckWriter Application Introducing Graphics and Printing.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 2 Graphics Programming with C++ and the Dark GDK Library Starting.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
圖形處理 PHP 可讀取、產生 Gif 、 Jpg 、 Png 的 圖形,以及其他的圖形 操作,不過必須注意以下幾點: 1. 系統上必須安裝 GD Library (可用 phpinfo() 函數檢查) 2.GD 1.5 (含)以下支援 Gif 、 Jpg , GD 1.6 以上支援 Png 、 Jpg.
2.2 ORGANIZING QUANTITATIVE DATA OBJECTIVE: GRAPH QUANTITATIVE DATA Chapter 2.
Title 30 point second line if required Sub-title 24 point Second line if required.
1 Media Software Design DIG 3134 Fall 2012 Lecture 15: Graphics J. Michael Moshell University of Central Florida Original image* by Moshell et al.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 2 – Welcome Application Introduction to Graphical.
Creating a Java Application and Applet
PHP: Beyond the Basics. Beyond the Basics Error Reporting Exception Handling Variable Interpolation Cookies Headers Image Manipulation Including/Organizing.
Chapter 13 Spreadsheets and Business Graphics: Facts and Figures.
Section 4.2.  Label the quadrants on the graphic organizer  Identify the x-coordinate in the point (-5, -7)
Chapter 7 Creating Templates, Importing Data, and Working with SmartArt, Images, and Screen Shots Microsoft Excel 2013.
April 9 th, Saturday PDP N° Malik Koné. I. Cells A. The Concept B. Properties, Types and Formats II. Spreadsheets A. Spreadsheet’s Elements B. Selection.
Submitted By: Shantam Dubey Website:
GD Library in PHP CH. Pradeep Reddy Assistant Professor VIT University, Vellore.
Bar Graphs and Line Graphs
Add More Zing to your Dashboards – Creating Zing Plot Gadgets
Chapter 21 – Graphics/Tk Outline 21.1 Introduction 21.2 GD Module: Creating Simple Shapes 21.3 GD Module: Image Manipulation 21.4 Chart Module 21.5 Introduction.
Inserting and Working with Images
Flash Interface, Commands and Functions
Chapter 2 – Introduction to the Visual Studio .NET IDE
Madam Hazwani binti Rahmat
Graphical Representation of Linear Equations and Functions
Converting a Definite Integral to a limit of a Riemann Sum and converting a limit of a Riemann Sum to a Definite Integral This template can be used as.
PHP Image Manipulation
2.2 Bar Charts, Pie Charts, and Stem and Leaf Diagram
Project Objectives Open an image Save an image Resize an image
CS 106A, Lecture 12 More Graphics
How To Use This Template
Chapter 2 – Introduction to the Visual Studio .NET IDE
PLACE YOUR TITLE HERE **Poster Author(s) Go Here
Chapter 2 Graphics Programming with C++ and the Dark GDK Library
Advanced Plotting Techniques
COMS 161 Introduction to Computing
Lecture 9 GUI and Event Driven CSE /16/2019.
Objectives At the end of this session, students will be able to:
Chapter 13 Graphics.
GO! with Microsoft® Excel 2010
Barcode Software and Designing Process of 2D Barcode- Aztec Font
Chapter 13 Graphics.
Chapter 7 The Game Loop and Animation
How to Use Microsoft Excel for Data Entry
CA203 Presentation Application
Presentation transcript:

[Charts| Generating Graphic| Creating Graphic] CHAPTER 6 GRAPHIC USAGE [Charts| Generating Graphic| Creating Graphic] Madam Hazwani binti Rahmat http://fsktm2.uthm.edu.my/hazwani/v2/

CREATING GRAPHICS GD is an open PHP source code library for dynamic creation of images. GD is used for creating PNG, JPEG and GIF images . It is commonly used to generate charts, graphics, thumbnails. GD library allows alteration, manipulation, and creation of images through programming such as: Create new images Create text Manipulate image Manipulate text

CREATING GRAPHICS Creating a new image requires STEPS in defining the following in order: Steps Syntax and example image type Syntax: header("Content-type: image/type(png/gif/jpg)"); Example: header ("Content-type: image/png"); image dimension Syntax: imagecreate(width, height); Example: imagecreate(300, 300); Creation command Syntax: imagepng(dimension); Example: imagepng($image); Deletion command Syntax: imagedestroy(dimension); Example: imagedestroy($image);

CREATING GRAPHICS Example: creating rectangle <?php //Step1: Set the correct content type header('content-type: image/png'); // Step2: Create our basic image stream $image = imagecreate(125, 125); //Set the background color $blueBG = imagecolorallocate($image, 0, 0, 255); // Step3: save the image as a png and output imagepng($image); // Step4: Clear up memory used imagedestroy($image); ?>

CREATING GRAPHICS Creating a new text requires the following command syntax: ImageString(dimension, size, Xcoordinate, Ycoordinate, string, color); where; dimension – width and height of the image canvas size - an integer between 1 to 5 x coordinate – x position on screen y coordinate – y position on screen string - text to display color – fill color using imagecolorallocate()

CREATING GRAPHICS <?php FORM| $_POST| $_GET //Step1: Set the correct content type header('content-type: image/png'); // Step2: Create our basic image stream $image = imagecreate(125, 125); //Set the background color $bg = imagecolorallocate($image, 0, 0, 255); //Set the text color $txt_color = imagecolorallocate($image, 0, 0, 0); //Set the text ImageString ($image, 5, 5, 18, “Hello", $txt_color); // Step3: save the image as a png and output imagepng($image); // Step4: Clear up memory used imagedestroy($image); ?> FORM| $_POST| $_GET

CREATING GRAPHICS Manipulating text WITH FONT requires the following command syntax: imagettftext(dimension, size, rotation, Xcoordinate, Ycoordinate, color, font, string); where; dimension - width and height of the image canvas size – font size rotation – degrees to rotate text x coordinate – x position on screen y coordinate – y position on screen color – fill color using imagecolorallocate() font - font name/ ttf file location string - text to display

CREATING GRAPHICS <?php FORM| $_POST| $_GET //Step1: Set the correct content type header('content-type: image/png'); // Step2: Create our basic image stream $image = imagecreate(125, 125); //Set the background color $bg = imagecolorallocate($image, 0, 0, 255); //Set the text color $txt_color = imagecolorallocate($image, 0, 0, 0); //Set the text imagettftext($image, 20, 0, 10, 30, $txt_color, “aparaj.ttf”, “Hello”); // Step3: save the image as a png and output imagepng($image); // Step4: Clear up memory used imagedestroy($image); ?> FORM| $_POST| $_GET

ImageLine(dimension, xStart, yStart, xEnd, yEnd, color); CREATING GRAPHICS Creating a new line requires the following command syntax: ImageLine(dimension, xStart, yStart, xEnd, yEnd, color); where; dimension - width and height of the image canvas xStart- x axis line starting point on screen yStart– y axis line starting point on screen xEnd- x axis line starting point on screen yEnd– y axis line starting point on screen color - fill color using imagecolorallocate()

CREATING GRAPHICS FORM| $_POST| $_GET <?php //Step1: Set the correct content type header('content-type: image/png'); // Step2: Create our basic image stream $image = imagecreate(125, 125); //Set the background color $bg = imagecolorallocate($image, 0, 0, 255); //Set the line color $line_color = imagecolorallocate($image, 0, 0, 0); // set line position ImageLine($image, 65, 0, 130, 50, $line_color); // Step3: save the image as a png and output imagepng($image); // Step4: Clear up memory used imagedestroy($image); ?> FORM| $_POST| $_GET

imageellipse (dimension, xCenter, yCenter, width, height, color); CREATING GRAPHICS Creating an ecllipse requires the following command syntax: imageellipse (dimension, xCenter, yCenter, width, height, color); where; dimension - width and height of the image canvas xCenter- x axis line center coordinate on screen yCenter– y axis line center coordinate on screen width- x axis line starting point on screen height– y axis line starting point on screen color - fill color using imagecolorallocate()

CREATING GRAPHICS FORM| $_POST| $_GET <?php //Step1: Set the correct content type header('content-type: image/png'); // Step2: Create our basic image stream $image = imagecreate(125, 125); //Set the background color $bg = imagecolorallocate($image, 0, 0, 255); //Set the line color $line_color = imagecolorallocate($image, 0, 0, 0); // set line position imageellipse ($image, 65, 25, 100, 40, $line_color); // Step3: save the image as a png and output imagepng($image); // Step4: Clear up memory used imagedestroy($image); ?> FORM| $_POST| $_GET

CREATING BAR CHARTS A bar chart is simply a series of rectangles that represent the unit or percentage amount of a maximum value, starting from a logical 0 point and proceeding to the specified amount of the maximum value with a constant bar width. In image coordinate terms, this means that the rectangle starts at an (x1, y1) coordinate extending to a (x2, y2) coordinate, where x1 equals the starting horizontal position, y1 equals the starting vertical position, x2 equals the ending horizontal position, and y2 equals the ending vertical position. All of this information is created from a series of unit or percentage amounts converted to unit amounts.

CREATING BAR CHARTS Creating a bar chart requires the following: Image type Data to plot Image dimension (canvas size) Background color(canvas color) X and Y axis (line and color) Graph bar fill color First graph bar location Width and height of each graph bar Data plot Creation command

header("Content-type: image/jpeg"); CREATING BAR CHARTS Creating a bar chart requires the following: Image type header("Content-type: image/jpeg"); Data to plot $data = array('3000','2470','225','663','6666','3456','789'); Image dimension (canvas size) $height = 255; $width = 320; $im = imagecreate($width,$height);

CREATING BAR CHARTS Creating a bar chart requires the following: Background color(canvas color) $white = imagecolorallocate($im,240,240,255); X and Y axis (line and color) $black = imagecolorallocate($im,0,0,0); imageline($im, 10, 5, 10, 230, $black); imageline($im, 10, 230, 300, 230, $black); Graph bar fill color $blue = imagecolorallocate($im,0,64,128);

CREATING BAR CHARTS Creating a bar chart requires the following: First graph bar location $x = 15; $y = 230; Width and height of each graph bar $x_width = 20; $y_ht = 0;

CREATING BAR CHARTS Creating a bar chart requires the following: Data plot $sum = array_sum($data); for($i=0;$i<7;$i++) { $y_ht = ($data[$i]/$sum)* $height; imagefilledrectangle($im,$x,$y,$x+$x_width,($y-$y_ht),$blue); imagestring( $im,2,$x-1,$y+10,$data[$i],$black); $x += ($x_width+20); }

CREATING BAR CHARTS Creating a bar chart requires the following: Creation command imagejpeg($im);

CREATING BAR CHARTS

GENERATING GRAPHICS Available graphics stored in database can be generated using PHP. (Ex: Shopping catalog) Generating graphics from a database requires: Data table (to specify image location and name) Input page (catalog (product category) / search keyword) Action page (to pull out data requested)

GENERATING GRAPHICS Generating graphics from a database requires: Data Table

GENERATING GRAPHICS Generating graphics from a database requires: Input Page

GENERATING GRAPHICS Generating graphics from a database requires: Action Page