Dojo, Now with Drawing Tools!
Listing 5. Preview of Dojo's Charting API
//////////////////////////////////////////////////////
// This function demonstrates the general form of
// putting Dojo's charting API built on top of
// gfx to use. Pass in a node, customize the chart,
// and let Dojo take care of the rest
//////////////////////////////////////////////////////
new dojox.charting.Chart2D(node))
.setTheme(dojox.charting.themes.PlotKit.blue)
.addPlot("default", {
type: "Default",
lines: true,
markers: true,
tension: 2
})
.addAxis("x", {
min: 0,
max: 6,
majorTick: { stroke: "black", length: 3 },
minorTick: { stroke: "gray", length: 3 }
})
.addAxis("y", {
vertical: true,
min: 0,
max: 10,
majorTick: { stroke: "black", length: 3 },
minorTick: { stroke: "gray", length: 3 }
})
.addSeries("Series A", [
{ x: 0.5, y: 5 },
{ x: 1.5, y: 1.5 },
{ x: 2, y: 9 },
{ x: 5, y: 0.3 }
])
.addSeries("Series B", [
{ x: 0.3, y: 8 },
{ x: 4, y: 6 },
{ x: 5.5, y: 2 }
])
.render()
;

Figure 9. An example of the charts you can draw with Dojo—no Flash required!

Figure 10. Another Example Chart Drawn with Dojo
Although only a teaser, it's worthwhile to note the charting API focus on charting—not on raw drawing operations—so you can focus on the semantics of the task at hand instead of the implementation details associated with lower-level operations. In general, you simply provide some data that says what kind of chart you'd like, how to customize the axes and pass in the series data. Setting up event handlers, legends and other related things all work much the same way.
2-D drawing is an enormous topic in and of itself, and no single article could cover all the nooks and crannies adequately. This article is designed to give you an idea of just how easy Dojo makes 2-D for the Web, which hopefully motivates you to start experimenting with the examples and check out the API docs.
Resources
Full Drag-and-Droppable Dominoes Code (Listing 4): ftp.linuxjournal.com/pub/lj/issue178/10308.tgz
“Dojo: the JavaScript Toolkit with Industrial-Strength Mojo” by Matthew Russell, LJ, July 2008: www.linuxjournal.com/article/9900
The Dojo Toolkit: dojotoolkit.org
The gfx API Documentation: docs.google.com/View?docid=d764479_1hnb2tn
Reflection with gfx: dojotdg.com/2008/09/a-simple-degradable-reflection-widget
Overview of Transformation Matrices: en.wikipedia.org/wiki/Transformation_matrix
Custom Fonts with gfx: www.sitepen.com/blog/2008/09/08/custom-fonts-with-dojoxgfx
Dojo: The Definitive Guide (O'Reilly, June 2008): oreilly.com/catalog/9780596516482
Dojo: The Definitive Guide (Official Online Compendium): dojotdg.com
Dojo Campus: dojocampus.org
Dojo Key Links: dojotoolkit.org/key-links
Dojo Foundation: dojofoundation.org
Matthew Russell is an open Web technology consultant and the author of Dojo: The Definitive Guide (O'Reilly, June 2008).
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
Web Development News
Developer Poll
| Speed Up Your Web Site with Varnish | Jun 19, 2013 |
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
- Speed Up Your Web Site with Varnish
- Containers—Not Virtual Machines—Are the Future Cloud
- Linux Systems Administrator
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Non-Linux FOSS: libnotify, OS X Style
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- RSS Feeds
- Reply to comment | Linux Journal
59 min 31 sec ago - Reply to comment | Linux Journal
4 hours 59 min ago - Yeah, user namespaces are
6 hours 15 min ago - Cari Uang
9 hours 46 min ago - user namespaces
12 hours 40 min ago - yea
13 hours 6 min ago - One advantage with VMs
15 hours 34 min ago - about info
16 hours 7 min ago - info
16 hours 8 min ago - info
16 hours 9 min ago








Comments
Please post missing file 10308.tgz
When I try this link in the resources:
ftp://ftp.linuxjournal.com/pub/lj/issue178/10308.tgz
It's a bad link. I found this
ftp://ftp.linuxjournal.com/pub/lj/listings/issue178/README178
10042.tgz -- Web 2.0 Development with the Google Web Toolkit
Federico Kereki
10308.tgz -- Dojo, Now with Drawing Tools!
Matthew Russell
but this file is missing: 10308.tgz
very interesting, good for
very interesting, good for gfx beginner just like me. thanks!
where is the download for listing 4
Trying to download the code from listing 4 from the ftp link in Resources. I get a "550 Failed to change directory" error.
Tried browsing the ftp site, but there seems to be nothing there for this issue (178).