跳到内容

Protovis Loader

v0.3.0

seancarmody · 2010年9月10日 上架

Creates a shortcode to faciliate the use of Protovis data visualization scripts in blog posts.

正在使用
10 以下
评分
暂无
累计下载
1,883
最近更新
2010年9月20日
需要 WordPress 2.8.0+已测试到 3.0.5

贡献者

截图

Using the shortcode in a blog post
Using the shortcode in a blog post
The end result.
The end result.

Protovis Loader is a plugin which faciliates the use of Protovis scripts. Protovis is a javascript data visualisation library being developed at Stanford, which allows the creation of interactive charts on web pages.

Incorporating Javascript code into WordPress posts can be tricky as it (deliberately) sanitises text typed into posts, which interferes with Javascript. When I first began experimenting with Javascript, this cause me some difficulties, as described in this post. In the end, I decided to roll up my sleeves and write a plugin to make the whole process a lot easier. Protovis Loader was the result.

Protovis Loader makes the whole process a lot easier in two ways:

  1. It ships with a copy of the Protovis javascript library and once the plugin is activated, links to the library will automatically be included in page headers.
  2. It creates a shortcode called [pvis] which makes it very easy to include Protovis scripts in blog posts and pages.

Usage:

Simply use the [pvis] shortcode in your posts and pages where you want to include a Protovis chart. There are a number of optional parameters:

  • type: ‘chart’ (default) displays a chart in a box with an optional caption, ‘inline’ has no box (e.g. useful for sparklines)
  • src: path to a Protovis (javascript) code file
  • height: height of canvas box for the chart
  • width: width of canvas box for the chart
  • img: path to a fallback image to use when scripts are blocked or the browser does not support Protovis
  • alt: alt text for the fallback image
  • caption: image caption

If any content is supplied between the opening [pvis] tag and the closing [/pvis] tag, it is taken to be javascript for inclusion. It may also be interpreted as a caption, but only if a caption field is not supplied and a src field is supplied.

Here is an example of use of the tag:

[pvis src=”http://www.example.com/chart.js” img=”fails.png” height=”125px”]My Caption![/pvis]

You can see the plugin in action on the Stubborn Mule.

To-Do List

This list is not really prioritised yet.

  1. Improve user-agent (browser) detection
  2. Create an options page
  3. Allow custom CSS files
  4. Allow for alterntive specification of the protovis js library
  5. Replace tags in the imported script to allow shortcode parameters to be used in the script

I’m sure there’ll be a lot more!

Plums

按场景查找 WordPress 插件。安装量、评分和兼容版本来自官方目录。

导航

说明

WordPress 是 WordPress Foundation 的商标。本站与 WordPress Foundation、Automattic 没有隶属关系。这里不托管插件文件,下载和安装以 WordPress.org 上的页面为准。

© 2026 Plums