SlideShare una empresa de Scribd logo
1 de 17
Crtanje grafova
Nove tehnologije u razvoju društva, © 2014
HTML Canvas Cookbook
 Preko 80 Canvas primjera
 Eric Rowell
 Publish by Packt Publishing Ltd. (Nov 2011)
 HTML5 Canvas – Native Interactivity and Animation for the Web
 Steve Fulton and Jeff Fulton
 Publis by O’Reilly Media Inc. (May 2011)
 Safari HTML5 Canvas Guide
 Apples Developers
 2013-09-18 | Copyright © 2013 Apple Inc. All Rights Reserved.
227.4.2014.
 HTML objekt
 The <canvas> tag is new in HTML5.
 APPLE > 2004 ; Standard > 2005
 Javascript
 CSS
 Raster based
 Podržava
 video, audio, crtanje objekata
 igre, transformacije, animacije
…allows dynamic, scriptable rendering of 2D shapes and bitmap images…
327.4.2014.
Compatibility
http://caniuse.com/canvas
<!DOCTYPE html>
<html>
<head>
<script>
window.onload = function () {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
// crtanje…
};
</script>
</head>
<body>
<canvas id="myCanvas" width="578" height="200">
This text is displayed if your browser does not support HTML5 Canvas!
</canvas>
</body>
</html>
427.4.2014.
window.onload = function(){
// get the canvas DOM element by its ID
var canvas = document.getElementById("myCanvas");
// declare a 2-d context using the getContext() method of the
// canvas object
var context = canvas.getContext("2d");
// set the line width to 10 pixels
context.lineWidth = 10;
// set the line color to blue
context.strokeStyle = "blue";
// position the drawing cursor
context.moveTo(50, canvas.height - 50);
// draw the line
context.lineTo(canvas.width - 50, 50);
// make the line visible with the stroke color
context.stroke();
};
527.4.2014.
 http://www.mrspeaker.net/dev/parcycle/
 http://bomomo.com/
 http://hakim.se/experiments/html5/magnetic/02/
 http://kennethjorgensen.com/blog/2014/canvas-trees/
 http://www.relfind.com/game/magician.html
 http://hakim.se/experiments/html5/origami/
 http://hakim.se/experiments/html5/wave/03/
 http://hakim.se/experiments/html5/trail/03/
 http://peterned.home.xs4all.nl/3d/
 https://developer.mozilla.org/en-US/demos/detail/zen-photon-garden/launch
 http://codepen.io/suffick/pen/KrAwx
 http://www.freeriderhd.com/t/1010-contest-entry
 http://www.jqueryrain.com/?usKWk5aQ
627.4.2014.
http://chartjs.devexpress.com/?gclid=CMuS3a_fgL4
CFWzHtAodFwQAkw
http://blog.isomorphic.com/html5-charts-with-
mobile-
support/?gclid=CJuypLDfgL4CFZDKtAodFS4AKA
 http://www.chartjs.org/
http://igrapher.com/#
 http://canvasjs.com/
727.4.2014.
 http://www.chartjs.org/
//Get the context of the canvas element we want to select
var ctx = document.getElementById("myChart").getContext("2d");
var myNewChart = new Chart(ctx).PolarArea(data);
827.4.2014.
var data = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
fillColor: "rgba(220,220,220,0.5)",
strokeColor: "rgba(220,220,220,1)", pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
data: [65, 59, 90, 81, 56, 55, 40]
},
{
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,1)", pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
data: [28, 48, 40, 19, 96, 27, 100]
}
]
}
927.4.2014.
1027.4.2014.
function CreatePieChart(c, data) {
//dohvat objekata
var ctx = c.getContext("2d");
var lastend = 0; //zadnja vrijednost
var myTotal = 0; //ukupna vrijednost podataka
var data = [200, 60, 15, 90]; //dodavanje vrijdnosti
var myColor = ['red', 'green', 'blue', 'gray']; //uz vrijednosti, ide i boja
//čistimo radnu površinu
ctx.clearRect(0, 0, c.width, c.height);
for (var e = 0; e < data.length; e++) {
myTotal += data[e]; //zbrajamo ukupnu vrijednost
}
for (var i = 0; i < data.length; i++) {
ctx.fillStyle = myColor[i]; //uzimamo boju
ctx.beginPath(); //početak crtanja
ctx.moveTo(c.width / 2, c.height / 2); //pozicioniramo se na početak
ctx.arc(c.width / 2, c.height / 2, c.height / 2, lastend, lastend + (2 * Math.PI * (data[i] / myTotal)), false);
ctx.lineTo(c.width / 2, c.height / 2); //crtamo liniju prema centru
ctx.fill(); //punimo se bojom
lastend += Math.PI * 2 * (data[i] / myTotal); //pamtimo zadnju poziciju
}
}
1127.4.2014.
27.4.2014. 12
Parametar Opis parametra
x The x-coordinate of the center of the circle
y The y-coordinate of the center of the circle
r The radius of the circle
sAngle The starting angle, in radians (0 is at the 3
o'clock position of the arc's circle)
eAngle The ending angle, in radians
counterclock
wise
Optional. Specifies whether the drawing should
be counterclockwise or clockwise. False is
default, and indicates clockwise, while true
indicates counter-clockwise.
 Prikupiti podatke
 Više izvora
 Jedna HTML stranica
 No refresh!!!
 Prikazati na grafu
 Promjene…
 Prezentacija
27.4.2014. 13
27.4.2014. 14
SignalR
real-time web functionality
http://smoothiecharts.org/http://signalr.net
1527.4.2014.
http://bit.ly/1fq7OpR
http://is.gd/v7p8MX
 Budućnost
 Nove stvari
 Frameworci
 Aplikacije
 Prezentacije
 Poslovni sustavi
 ….
 Jednostavnost & Fleksibilnost
 Javascript
 Odlične performanse
1627.4.2014.
No matter what platform or tools you use, the HTML5 revolution
will soon change the way you build web applications, if it hasn't
already.
1727.4.2014.
Neven Palčec
neven.palcec@gmail.com
Boris Ćorković
boris.corkovic@outlook.com

Más contenido relacionado

La actualidad más candente

HTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the WebHTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the WebRobin Hawkes
 
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...Dmitry Zinoviev
 
Stupid Canvas Tricks
Stupid Canvas TricksStupid Canvas Tricks
Stupid Canvas Tricksdeanhudson
 
Talk at NCRR P41 Director's Meeting
Talk at NCRR P41 Director's MeetingTalk at NCRR P41 Director's Meeting
Talk at NCRR P41 Director's MeetingDeepak Singh
 
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)Future Insights
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tipsLearningTech
 
Human-powered Javascript Compression for Fun and Gummy Bears
Human-powered Javascript Compression for Fun and Gummy BearsHuman-powered Javascript Compression for Fun and Gummy Bears
Human-powered Javascript Compression for Fun and Gummy BearsRui Lopes
 
SenchaCon 2016: Developing COSMOS Using Sencha Ext JS 5 - Shenglin Xu
SenchaCon 2016: Developing COSMOS Using Sencha Ext JS 5 - Shenglin XuSenchaCon 2016: Developing COSMOS Using Sencha Ext JS 5 - Shenglin Xu
SenchaCon 2016: Developing COSMOS Using Sencha Ext JS 5 - Shenglin XuSencha
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1Bitla Software
 
University of Bedford Knowledge Network 2.12.13
University of Bedford Knowledge Network 2.12.13University of Bedford Knowledge Network 2.12.13
University of Bedford Knowledge Network 2.12.13Business BUZZ - Watford
 
GraphConnect 2014 SF: Betting the Company on a Graph Database - Part 2
GraphConnect 2014 SF: Betting the Company on a Graph Database - Part 2GraphConnect 2014 SF: Betting the Company on a Graph Database - Part 2
GraphConnect 2014 SF: Betting the Company on a Graph Database - Part 2Neo4j
 
Machine Tags
Machine TagsMachine Tags
Machine Tagshchen1
 
Introduction to d3js (and SVG)
Introduction to d3js (and SVG)Introduction to d3js (and SVG)
Introduction to d3js (and SVG)zahid-mian
 
Business Networking Cambridge April 2014
Business Networking Cambridge April 2014Business Networking Cambridge April 2014
Business Networking Cambridge April 2014Business BUZZ - Watford
 
Javascript Libraries & Frameworks | Connor Goddard
Javascript Libraries & Frameworks | Connor GoddardJavascript Libraries & Frameworks | Connor Goddard
Javascript Libraries & Frameworks | Connor GoddardConnor Goddard
 
GraphQL - APIs The New Way
GraphQL - APIs The New WayGraphQL - APIs The New Way
GraphQL - APIs The New WayVladimir Tsukur
 

La actualidad más candente (20)

HTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the WebHTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the Web
 
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...
“A Quaint and Curious Volume of Forgotten Lore,” or an Exercise in Digital Hu...
 
Variables
VariablesVariables
Variables
 
Stupid Canvas Tricks
Stupid Canvas TricksStupid Canvas Tricks
Stupid Canvas Tricks
 
Drawing images
Drawing imagesDrawing images
Drawing images
 
Talk at NCRR P41 Director's Meeting
Talk at NCRR P41 Director's MeetingTalk at NCRR P41 Director's Meeting
Talk at NCRR P41 Director's Meeting
 
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
Game dev 101 part 3
Game dev 101 part 3Game dev 101 part 3
Game dev 101 part 3
 
Game dev 101 part 2
Game dev 101   part 2Game dev 101   part 2
Game dev 101 part 2
 
Human-powered Javascript Compression for Fun and Gummy Bears
Human-powered Javascript Compression for Fun and Gummy BearsHuman-powered Javascript Compression for Fun and Gummy Bears
Human-powered Javascript Compression for Fun and Gummy Bears
 
SenchaCon 2016: Developing COSMOS Using Sencha Ext JS 5 - Shenglin Xu
SenchaCon 2016: Developing COSMOS Using Sencha Ext JS 5 - Shenglin XuSenchaCon 2016: Developing COSMOS Using Sencha Ext JS 5 - Shenglin Xu
SenchaCon 2016: Developing COSMOS Using Sencha Ext JS 5 - Shenglin Xu
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1
 
University of Bedford Knowledge Network 2.12.13
University of Bedford Knowledge Network 2.12.13University of Bedford Knowledge Network 2.12.13
University of Bedford Knowledge Network 2.12.13
 
GraphConnect 2014 SF: Betting the Company on a Graph Database - Part 2
GraphConnect 2014 SF: Betting the Company on a Graph Database - Part 2GraphConnect 2014 SF: Betting the Company on a Graph Database - Part 2
GraphConnect 2014 SF: Betting the Company on a Graph Database - Part 2
 
Machine Tags
Machine TagsMachine Tags
Machine Tags
 
Introduction to d3js (and SVG)
Introduction to d3js (and SVG)Introduction to d3js (and SVG)
Introduction to d3js (and SVG)
 
Business Networking Cambridge April 2014
Business Networking Cambridge April 2014Business Networking Cambridge April 2014
Business Networking Cambridge April 2014
 
Javascript Libraries & Frameworks | Connor Goddard
Javascript Libraries & Frameworks | Connor GoddardJavascript Libraries & Frameworks | Connor Goddard
Javascript Libraries & Frameworks | Connor Goddard
 
GraphQL - APIs The New Way
GraphQL - APIs The New WayGraphQL - APIs The New Way
GraphQL - APIs The New Way
 

Destacado

Interactive Vector-Graphics in the Browser
Interactive Vector-Graphics in the BrowserInteractive Vector-Graphics in the Browser
Interactive Vector-Graphics in the Browsertec
 
HTML Canvas tips & tricks - Lightning Talk by Roman Rodych
 HTML Canvas tips & tricks - Lightning Talk by Roman Rodych HTML Canvas tips & tricks - Lightning Talk by Roman Rodych
HTML Canvas tips & tricks - Lightning Talk by Roman RodychPivorak MeetUp
 
【J-SHIS】地震の発生確率と地震動の超過確率
【J-SHIS】地震の発生確率と地震動の超過確率【J-SHIS】地震の発生確率と地震動の超過確率
【J-SHIS】地震の発生確率と地震動の超過確率NIED
 
Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)Peter Lubbers
 
Rucksack 裝滿神奇 css 的後背包
Rucksack 裝滿神奇 css 的後背包Rucksack 裝滿神奇 css 的後背包
Rucksack 裝滿神奇 css 的後背包Anna Su
 
從一個超簡單範例開始學習 Canvas
從一個超簡單範例開始學習 Canvas從一個超簡單範例開始學習 Canvas
從一個超簡單範例開始學習 CanvasAnna Su
 

Destacado (8)

Working With Canvas
Working With CanvasWorking With Canvas
Working With Canvas
 
ES6
ES6ES6
ES6
 
Interactive Vector-Graphics in the Browser
Interactive Vector-Graphics in the BrowserInteractive Vector-Graphics in the Browser
Interactive Vector-Graphics in the Browser
 
HTML Canvas tips & tricks - Lightning Talk by Roman Rodych
 HTML Canvas tips & tricks - Lightning Talk by Roman Rodych HTML Canvas tips & tricks - Lightning Talk by Roman Rodych
HTML Canvas tips & tricks - Lightning Talk by Roman Rodych
 
【J-SHIS】地震の発生確率と地震動の超過確率
【J-SHIS】地震の発生確率と地震動の超過確率【J-SHIS】地震の発生確率と地震動の超過確率
【J-SHIS】地震の発生確率と地震動の超過確率
 
Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)
 
Rucksack 裝滿神奇 css 的後背包
Rucksack 裝滿神奇 css 的後背包Rucksack 裝滿神奇 css 的後背包
Rucksack 裝滿神奇 css 的後背包
 
從一個超簡單範例開始學習 Canvas
從一個超簡單範例開始學習 Canvas從一個超簡單範例開始學習 Canvas
從一個超簡單範例開始學習 Canvas
 

Similar a Canvas & Charts

Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Remy Sharp
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02PL dream
 
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....Patrick Lauke
 
Brave new world of HTML5
Brave new world of HTML5Brave new world of HTML5
Brave new world of HTML5Chris Mills
 
webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5smueller_sandsmedia
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreRemy Sharp
 
The things browsers can do! SAE Alumni Convention 2014
The things browsers can do! SAE Alumni Convention 2014The things browsers can do! SAE Alumni Convention 2014
The things browsers can do! SAE Alumni Convention 2014Christian Heilmann
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video gamedandylion13
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)Oswald Campesato
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Patrick Chanezon
 
HTML5 and CSS3 Shizzle
HTML5 and CSS3 ShizzleHTML5 and CSS3 Shizzle
HTML5 and CSS3 ShizzleChris Mills
 
Canvas
CanvasCanvas
CanvasRajon
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Sadaaki HIRAI
 

Similar a Canvas & Charts (20)

Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02
 
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
 
Brave new world of HTML5
Brave new world of HTML5Brave new world of HTML5
Brave new world of HTML5
 
webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
Html5 Overview
Html5 OverviewHtml5 Overview
Html5 Overview
 
The things browsers can do! SAE Alumni Convention 2014
The things browsers can do! SAE Alumni Convention 2014The things browsers can do! SAE Alumni Convention 2014
The things browsers can do! SAE Alumni Convention 2014
 
HTML 5 - Overview
HTML 5 - OverviewHTML 5 - Overview
HTML 5 - Overview
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video game
 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
HTML5 and CSS3 Shizzle
HTML5 and CSS3 ShizzleHTML5 and CSS3 Shizzle
HTML5 and CSS3 Shizzle
 
HTML5 for Mobile
HTML5 for MobileHTML5 for Mobile
HTML5 for Mobile
 
Canvas
CanvasCanvas
Canvas
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
 

Último

The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 

Último (20)

The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 

Canvas & Charts

  • 1. Crtanje grafova Nove tehnologije u razvoju društva, © 2014
  • 2. HTML Canvas Cookbook  Preko 80 Canvas primjera  Eric Rowell  Publish by Packt Publishing Ltd. (Nov 2011)  HTML5 Canvas – Native Interactivity and Animation for the Web  Steve Fulton and Jeff Fulton  Publis by O’Reilly Media Inc. (May 2011)  Safari HTML5 Canvas Guide  Apples Developers  2013-09-18 | Copyright © 2013 Apple Inc. All Rights Reserved. 227.4.2014.
  • 3.  HTML objekt  The <canvas> tag is new in HTML5.  APPLE > 2004 ; Standard > 2005  Javascript  CSS  Raster based  Podržava  video, audio, crtanje objekata  igre, transformacije, animacije …allows dynamic, scriptable rendering of 2D shapes and bitmap images… 327.4.2014. Compatibility http://caniuse.com/canvas
  • 4. <!DOCTYPE html> <html> <head> <script> window.onload = function () { var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); // crtanje… }; </script> </head> <body> <canvas id="myCanvas" width="578" height="200"> This text is displayed if your browser does not support HTML5 Canvas! </canvas> </body> </html> 427.4.2014.
  • 5. window.onload = function(){ // get the canvas DOM element by its ID var canvas = document.getElementById("myCanvas"); // declare a 2-d context using the getContext() method of the // canvas object var context = canvas.getContext("2d"); // set the line width to 10 pixels context.lineWidth = 10; // set the line color to blue context.strokeStyle = "blue"; // position the drawing cursor context.moveTo(50, canvas.height - 50); // draw the line context.lineTo(canvas.width - 50, 50); // make the line visible with the stroke color context.stroke(); }; 527.4.2014.
  • 6.  http://www.mrspeaker.net/dev/parcycle/  http://bomomo.com/  http://hakim.se/experiments/html5/magnetic/02/  http://kennethjorgensen.com/blog/2014/canvas-trees/  http://www.relfind.com/game/magician.html  http://hakim.se/experiments/html5/origami/  http://hakim.se/experiments/html5/wave/03/  http://hakim.se/experiments/html5/trail/03/  http://peterned.home.xs4all.nl/3d/  https://developer.mozilla.org/en-US/demos/detail/zen-photon-garden/launch  http://codepen.io/suffick/pen/KrAwx  http://www.freeriderhd.com/t/1010-contest-entry  http://www.jqueryrain.com/?usKWk5aQ 627.4.2014.
  • 8.  http://www.chartjs.org/ //Get the context of the canvas element we want to select var ctx = document.getElementById("myChart").getContext("2d"); var myNewChart = new Chart(ctx).PolarArea(data); 827.4.2014.
  • 9. var data = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [ { fillColor: "rgba(220,220,220,0.5)", strokeColor: "rgba(220,220,220,1)", pointColor: "rgba(220,220,220,1)", pointStrokeColor: "#fff", data: [65, 59, 90, 81, 56, 55, 40] }, { fillColor: "rgba(151,187,205,0.5)", strokeColor: "rgba(151,187,205,1)", pointColor: "rgba(151,187,205,1)", pointStrokeColor: "#fff", data: [28, 48, 40, 19, 96, 27, 100] } ] } 927.4.2014.
  • 11. function CreatePieChart(c, data) { //dohvat objekata var ctx = c.getContext("2d"); var lastend = 0; //zadnja vrijednost var myTotal = 0; //ukupna vrijednost podataka var data = [200, 60, 15, 90]; //dodavanje vrijdnosti var myColor = ['red', 'green', 'blue', 'gray']; //uz vrijednosti, ide i boja //čistimo radnu površinu ctx.clearRect(0, 0, c.width, c.height); for (var e = 0; e < data.length; e++) { myTotal += data[e]; //zbrajamo ukupnu vrijednost } for (var i = 0; i < data.length; i++) { ctx.fillStyle = myColor[i]; //uzimamo boju ctx.beginPath(); //početak crtanja ctx.moveTo(c.width / 2, c.height / 2); //pozicioniramo se na početak ctx.arc(c.width / 2, c.height / 2, c.height / 2, lastend, lastend + (2 * Math.PI * (data[i] / myTotal)), false); ctx.lineTo(c.width / 2, c.height / 2); //crtamo liniju prema centru ctx.fill(); //punimo se bojom lastend += Math.PI * 2 * (data[i] / myTotal); //pamtimo zadnju poziciju } } 1127.4.2014.
  • 12. 27.4.2014. 12 Parametar Opis parametra x The x-coordinate of the center of the circle y The y-coordinate of the center of the circle r The radius of the circle sAngle The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle) eAngle The ending angle, in radians counterclock wise Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise.
  • 13.  Prikupiti podatke  Više izvora  Jedna HTML stranica  No refresh!!!  Prikazati na grafu  Promjene…  Prezentacija 27.4.2014. 13
  • 14. 27.4.2014. 14 SignalR real-time web functionality http://smoothiecharts.org/http://signalr.net
  • 16.  Budućnost  Nove stvari  Frameworci  Aplikacije  Prezentacije  Poslovni sustavi  ….  Jednostavnost & Fleksibilnost  Javascript  Odlične performanse 1627.4.2014. No matter what platform or tools you use, the HTML5 revolution will soon change the way you build web applications, if it hasn't already.

Notas del editor

  1. HTML5 Canvas offers developers the chance to create animated graphics in ordinary web browsers using common tools: HTML and JavaScript. Canvas is one of the most visible parts of HTML5, fueling demo after demo, game after game. It offers interactivity with great visuals, and provides tremendous freedom to do whatever you want in the browser window. However, it differs enough from typical JavaScript development (as well as Flash and Silverlight development) that it needs careful exploration!