2

I was able to create a single bar graph using the code from Samir Talwar by modifying the renderer as the following:

 vis.setRendererFactory(new RendererFactory() {
        Renderer yAxisRenderer = new AxisRenderer(Constants.RIGHT, Constants.TOP);
        Renderer xAxisRenderer = new AxisRenderer(Constants.CENTER, Constants.FAR_BOTTOM);
        Renderer barRenderer = new ShapeRenderer() {
                protected Shape getRawShape(VisualItem item) {
                        double x = item.getX();
                        double y = item.getY();
                        if (Double.isNaN(x) || Double.isInfinite(x))
                                x = getInsets().left + axisWidth + totalBarWidth / 2;
                        if (Double.isNaN(y) || Double.isInfinite(y))
                                y = 0;

                        double width = totalBarWidth / (barCount + 1) - barGap;
                        double height = getHeight() - getInsets().bottom - axisHeight - y;
                        x -= width / 2;

                        item.setFillColor(item.getStrokeColor());
                        return rectangle(x, y, width, height);
                }
        };

        public Renderer getRenderer(VisualItem item) {
                return item.isInGroup("ylab") ? yAxisRenderer :
                       item.isInGroup("xlab") ? xAxisRenderer :
                       barRenderer;
        }

Anyhow, I have tried look on the possibility on creating clustered bar graphs where there are multiple bar for a single value but having difficulties. Also, the reason why I do not use JFreechart is because I need prefuse's filtering and searching functions which prove to be very useful in terms of analysis in my research.

Amro
  • 123,847
  • 25
  • 243
  • 454
chaky
  • 31
  • 8
  • 2
    see here [http://stackoverflow.com/questions/793712/how-do-i-create-a-bar-chart-using-the-java-prefuse-library][1] [1]: http://stackoverflow.com/questions/793712/how-do-i-create-a-bar-chart-using-the-java-prefuse-library – S. M. Shahinul Islam Jan 28 '12 at 11:51

0 Answers0