How do I create a bar chart using the Java prefuse library? -


I currently got a scatter graph, where the name of the X-axis computer and the Y axis has got its temperature. How do I get it to draw bars instead of discrete digits

I'm currently using the following code to present the digits:

  ShapeAction size = New shape action (group, static. HAPE_RECTANGLE); Coloration stroke color = new dataclosure action (group, data type, constant. NERICL, visualimst. STRKECOLOR, ColorLabelet); ActionList Draw = new Expertist (); Draw.add (size); Draw.add (strokecolor); Draw.add (New ColorAction (Group, VisualItem.FILLCOLOR, 0)); Draw.add (New RepaintAction ()); M_vis.putAction ("Draw", Draw);  

Instead of a small square at every point, how do I optimize this code to get a graph, going from the bottom to a thick bar?

Thanks

I think I should probably say how I did this - stack overflow is considered to be a repository also, after all it was the first code the following:

  m_vis.setRendererFactory (new RendererFactory () {exponent yAxisRenderer = new AxisRenderer (Constants.LEFT, Constants.TOP); exponent xAxisRenderer = new AxisRenderer (constant. center, Constants.FAR_BOTTOM); exponent barRenderer = new ShapeRenderer (); public exponent getRenderer (VisualItem item) {item.isInGroup ( "yAxis") return yAxisRenderer: item.isInGroup ("XAxis") xAxisRenderer? BarRenderer;}});  

I always extended the shape renderer to return a rectangle of the right width and height and kept it half-left on the left side where it should have you want to position your bars in the center to yourself what you need to do - Prefuse will not help you

  m_vis.setRendererFactory (new RendererFactory () {exponent yAxisRenderer = new AxisRenderer (. Constants.LEFT, Constants. TOP); Examiner xAxisRenderer = New AxisRenderer (Constants.CENTER, Constants.FAR_BOTTOM); Exponent barRenderer = New ShapeRende rer () {protected size 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 () down - axisHeight - y; x - = width / 2, back rectangle (X, Y, width, height);}}; public renderer Rivenderr (Vijhua litem item) {item.isInGroup ( "yAxis" ) Return? YAxisRenderer: item.isInGroup ("XXIS")? XAxisRenderer: Bar Renderer; }});  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -