• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sparklines?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sparklines?


  • Subject: Re: Sparklines?
  • From: Joshua Paul <email@hidden>
  • Date: Mon, 16 Jun 2008 17:21:35 -0700

Found this in my code hairball. YMMV...

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;

import javax.imageio.ImageIO;

import com.representqueens.spark.BarGraph;
import com.representqueens.spark.LineGraph;
import com.representqueens.spark.SizeParams;

import com.webobjects.foundation.NSArray;
import com.webobjects.foundation.NSData;

public class AVSparklineUtility {

public static NSData smallBar(NSArray values) {
return graph(40, 15, values, false);
}
public static NSData largeBar(NSArray values) {
return graph(320, 120, values, false);
}
public static NSData smallLine(NSArray values) {
return graph(40, 15, values, true);
}
public static NSData largeLine(NSArray values) {
return graph(320, 120, values, true);
}

private static NSData graph(int width, int height, NSArray integerArray, boolean isLine) {
SizeParams params;
BufferedImage i;
Enumeration e;
Vector<Integer> vector;
Integer[] values;
ByteArrayOutputStream baos;
params = new SizeParams(width, height, 1);
vector = new Vector<Integer>();
if (integerArray.count() > 0) {
e = integerArray.objectEnumerator();
while (e.hasMoreElements()) {
vector.add(new Integer((Integer) e.nextElement()));
}
}
values = ((Integer[]) vector.toArray(new Integer[vector.size()]));
if (isLine) {
i = LineGraph.createGraph(values, params, Color.blue.darker());
}
else {
i = BarGraph.createGraph(values, params, Color.blue.brighter(), Color.blue.darker(), Color.magenta);
}
baos = new ByteArrayOutputStream();
try {
ImageIO.write(i, "png", baos);
return new NSData(baos.toByteArray());
} catch (IOException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
return null;
}
}
}


On Jun 16, 2008, at 3:11 PM, Alex Cone wrote:

Anyone have a suggestion for something simple to drop into a WO  
application to display sparklines?

Sparkline - Wikipedia, the free encyclopedia

__alex cone
   ceo  codefab  inc
   212 465-8484 x101
   email@hidden
   http://www.codefab.com


If you are not living on the edge, you are taking up too much space.

--
Josh Paul
email@hidden

twitter: joshpaul
linkedin: joshpaul


NOTICE: This e-mail message and all attachments transmitted with it are intended solely for the use of the addressee and may contain legally privileged and confidential information. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately by replying to this message and please delete it from your computer.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: ReportMill can't find Framework?
  • Next by Date: Re: WebObjects 5.4 on Linux (Red Hat Enterprise)
  • Previous by thread: Re: Sparklines?
  • Next by thread: (no subject)
  • Index(es):
    • Date
    • Thread