Categories
SVG

Comments line graph

I had promised a WordPress pluggable version of the comments line graph and here it is. The line graph application is in two pieces: one to place in your theme directory and include in your page template; and a plug-in that will create the cached comment count file.

File one is graphcomments.php, which is installed in your theme. You’ll include the following in your web page template where you want the graph positioned:

<object style="width: 810px" data="/wp/theme/graphcomments.php" type="image/svg+xml" ></object>

Change the location for your environment. The element needs to be styled to fit the preferred width. The number of comments remains the same, but the graph resizes based on this width. The following is the same graph, but the containing element is set to 500 pixels wide.

[object removed]

In addition, the graphcomments.php has a style section with three values that you can change: line width (stroke-width), color (stroke), and opacity (stroke-opacity, a value between 0 and 1, with 0 being transparent, 1 being fully opaque).

The second piece is the plug-in, store_comments.php, which needs to be added to your plug-in directory. Both of the files require access to a single file, called comments.csv. This is a file that must be writable by the world, stored wherever you want. You can make it by creating an empty text file, and then use “chmod 766” to make it writable. If you don’t make this file, the application will attempt to create the file, which means the whole directory has to be world writable.

Both store_comments.php and graphcomments.php have a constant, FILENAME, which needs to be altered to fit the location of where the comments.csv file is stored.

How the comment graph line works is that whenever a new comment is saved, the comments.csv is updated to reflect the comment counts from the most recent 100 posts. The application that generates the SVG reads this file for the comma-separated values, and then creates the line graph.

At this time, the comments line graph is restricted to 100 comments or less, so, be forewarned if you get those 130+ comment days, the peak will be truncated.

The graphcomments.php application can be used on any data that is located in the file, each value separated by a comma. You can use it for category counts, unique visitor counts, anything that has simple totals over time.

Version 1.0 beta:

graphcomments.php store_comments.php

Steps:

  • Click the links and save the files, changing the extension to php from phps.
  • Place the graphcomments.php in your theme.
  • Place the store_comments.php in your plug-ins directory.
  • Create an empty text file named comments.csv, and place it in a directory. The directory does not have to be web accessible.
  • Change the file permissions to world writable, chmod 766.
  • Change the FILENAME value in both graphcomments.php and store_comments.php to the location of comments.csv file.
  • Add the line graph object element, example given above, to wherever your want the line graph to display.
  • Style the object element and the line graph.

The line graph is created using SVG. You don’t have to serve your pages as XHTML when you include SVG via an object element, as this application does. The line graph should work in IE if the person has the Adobe SVG plug-in installed, but no promises. Or you can set a container DIV element in which the object is installed to not display for IE. Check my header to see how to create IE specific style sheets.

I tried to center the line graph so that the tips aren’t truncated until after the 100 comment mark. There is white space at the top and bottom, but using negative margins for the top and bottom should eliminate most of it.

NOTE:

Safari fills in the background with white, by default, for the object container. I’m exploring how to change this, but I don’t expect to have a lot of luck. It looks like this behavior is a bug (or as planned, but not wanted). Feel free to use, but the graph won’t have a transparent background like the graph in my header, which is inline SVG. Of course, you can also copy my inline SVG, but then you’ll have to serve your pages as XHTML.

Categories
Standards SVG XHTML/HTML

Even the mistakes are fun

Anne Van Kesteren:

A new survey reveals that at least Microsoft and IBM think the HTML charter does not cover the canvas element.

I have to wonder, when reading the survey results, how much the people who voted actually used either SVG or the Canvas element. I covered both SVG and the Canvas Element in the book, but I focused more on SVG. Comparing the two–SVG and Canvas–is like comparing the old FONT element with CSS.

The Canvas element requires scripting. The SVG element doesn’t, even for animation if you use the animate elements. In addition, mistakes in SVG can be fun, as I found when I missed a parameter value in mistaken animation. A couple lines of markup. No script. Both Opera and Safari do an excellent job with the animation elements. I’m expecting Firefox to join this group in the next year.

If you use scripting, you can access each element in the SVG document as a separate element. You can’t do that with Canvas.

I still don’t think the Canvas element should be part of a new HTML 5, whatever the grand plans. However, since all but IE supports the Canvas element, it would be foolish to drop it. A better option would be to consider the Canvas element a bitmapped version of SVG and create a separate group to ensure it grows in a standard manner.

I did like what David Dailey wrote in the survey results:

I have considerable ambivalence about <canvas> as I have noted previously. If we were designing HTML 5 from the ground up , SVG and canvas ought to share syntax and ought not to duplicate so much functionality. <canvas> brings a few needed things with it, though it seems rather a bit of poor planning on the part of the advocates of <canvas> that has gotten us to this point. Those historically frustrated with W3C chose to ignore SVG and now seem to want W3C to ignore SVG in favor of a lesser technology. At the same time, <canvas> does enable client-side image analysis by giving the developer access to pixel values, and that alone allows for some tolerance of what otherwise seems to be a curious decoupling of reason from politics. Does it re-invent the wheel? — only about 95% of it is redundant with 20% of SVG.

As for all the discussion about semantic API…years ago I, and others, made a fight for a model and associated XML vocabulary, RDF, we said would stand the test of time and hold up under use. The road’s been rough, and few people are going to defend reification, but RDF fuels the only truly open social graph in existence. Five years ago. That was about the time when everyone believed that all we’d need for semantics was RSS. Including Microsoft.

Categories
Critters

Squid Scandal

It’s not often that I can report a scandal for Squid Friday.

Wednesday night, the History channel aired a program from its new series, Monster Quest, about a supposed ‘giant’ Humboldt squid, and whether it could be the famed Kraken of the past. Though the Humboldt typically are no more than a couple of meters long, they are aggressive, a closer match for Kraken behavior than other, larger squid.

Now, Monster Quest is a pure cryptozoology show, though they do engage scientists, or least seem to engage scientists. This particular show tried something I’ve never seen tried previously: attaching a ‘squid cam’ to a Humboldt squid, and then filming what it uncovers as it dives to deeper depths.

The squid sank down, down, down. Along the way, Humboldts would ‘mouth’ the camera, whether as attack or curiosity is open to interpretation. It was at a 1000 feet that we caught a glimpse that, frankly, had me sitting up and out of my chair.

It was a beautiful, graceful, and large, squid, barely seen in the murky water. How big is hard to say, but you knew as soon as you looked at it, that it was significantly larger than the Humboldt carrying the camera. Here’s a portion of the video, though it doesn’t do justice to the larger squid image.

I immediately located a Tonmo thread on the film and have been following the debate associated with this film. It especially got interesting when Scott Cassell, who assisted with the show, left a note debunking most of the supposed facts, including the squid measurements.

The original size proposed by the show writers was that this squid was 108 feet long. They came up with this value by measuring distances based on what they decided was an eye reflection. Well, few people in the Tonmo thread bought into this, including Scott, but he did propose that it could be a 25 foot, or more, Architeuthis. That’s Latin for my favorite, Giant Squid.

If the squid was an Architeuthis, then this is still a very exciting discovery. The only other film of a live Architeuthis was hooked on a fishing line, which is an unnatural environment for the creature. This film would show the squid in very realistic surroundings. In addition, show it in waters that I didn’t think had evidence of Architeuthis.

Dr. O’Shea is attempting to get a better copy of the video, and I imagine he’ll have excellent input into what the squid is. In the meantime, the cryptos are having fun.

update

A better video.

Categories
Social Media

Twitterphiles

Recovered from the Wayback Machine.

I must seem like I’m filled with disdain for Twitter, Facebook, or any of these other jewels of social graphing, or whatever it’s called this week. However, I really don’t have anything against the tools, as much as I can’t stand the hyperbole.

I don’t think there’s anything wrong with using, and enjoying, Twitter, Facebook, GMail, or any other new darlings. But there’s a lemming like quality to the discussions surrounding these tools that brings out the Critic, the Cynic, and the Curmudgeon in me, almost as a counter balance to weigh down the mountains of fluff.

One would think that being a tech, I would be all over these new ‘forms’ of technology. However, as a tech, I recognize that there really isn’t anything particularly innovative about the technologies behind Twitter, Facebook, and the like. They’re more good examples of dealing with performance issues, and excellent marketing, more than something truly new in the field of technology. They enable social networking? We’ve had social networking through the internet for a half century forty years.

In the meantime, when something new, really new, does come along within the technology field, it’s lost in all of the fooflah about Facebook, Twitter, and so on. I worry, sometimes, that we’re at the end of innovation; that we’re caught up in a cycle of Silicon Valley marketspeak that will never allow anything exciting through.

Categories
Social Media

Google and the Vegemite Story

Jeneane Sessum was interviewed for ComputerWorld for the problems with missing GMail email. I find it fascinating when Google is asked about any problem with its services, it always states it can’t respond fully because of ‘privacy’ concerns.

I don’t use GMail or Yahoo mail or any centralized email service for my email, primarily because, as happened with Facebook, you never know when your interactions with your friends suddenly become marketing fodder. It’s one thing to subject yourself to stealth ads, quite another to do so to your mates.

Centralized data aside, I think the issues with Jeneane’s email, and especially Google’s non-response, demonstrates an increasing problem with Google: it’s spread too thin. If Google doesn’t have its hands in television, it has its hands now in cellphones, closed social networks–increasingly throwing out tendrils into virtually every known, and possibly unknown, form of internet-based interaction. All, of course, with the undercurrent that some day the ‘somethings’ Google puts out will eventually become ‘somethings-with-ads’.

Yahoo’s desperate explorations into the hip (last year, internet operating systems, this year social graph) in order to maintain it’s implicit coolness have been overshadowed by the Peanut Butter Manifesto, a company communication by a senior Yahoo executive worried that the company was spreading itself too thin.

If, however, Yahoo’s rather timid explorations are seen as spreading the company thin, like peanut butter, than Google’s own explorations must be seen as the Vegemite of the internets, as it seeks to scrape smears of itself on everything we touch.