Black frame androidPlot

When I mySimpleXYPlot.getGraphWidget().getBorderPaint().setColor(Color.WHITE); code below and add mySimpleXYPlot.getGraphWidget().getBorderPaint().setColor(Color.WHITE);

The application starts when I launch it on my device.

what I'm trying to do is get rid of the black border around the entire chart. it has a thickness of about 2 cm, located on the upper, left and lower sides of the diagram. Is there any way to get rid of this black border?

 public class MainActivity extends Activity { private XYPlot mySimpleXYPlot; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create a couple arrays of y-values to plot: Number[] days = { 1 , 2 , 3 , 4 , 5 , 6 , 7 }; Number[] values = { 380, 1433, 1965, 3200, 3651, 3215, 3217 }; // initialize our XYPlot reference: mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot); mySimpleXYPlot.getBackgroundPaint().setColor(Color.WHITE); mySimpleXYPlot.setBorderStyle(XYPlot.BorderStyle.NONE, null, null); mySimpleXYPlot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE); mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE); // Domain mySimpleXYPlot.getGraphWidget().setDomainLabelPaint(null); mySimpleXYPlot.getGraphWidget().setDomainOriginLinePaint(null); mySimpleXYPlot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, days.length); mySimpleXYPlot.setDomainValueFormat(new DecimalFormat("0")); //Range mySimpleXYPlot.getGraphWidget().setRangeOriginLinePaint(null); mySimpleXYPlot.setRangeStep(XYStepMode.SUBDIVIDE, values.length); mySimpleXYPlot.setRangeValueFormat(new DecimalFormat("0")); //Remove legend mySimpleXYPlot.getLayoutManager().remove(mySimpleXYPlot.getLegendWidget()); mySimpleXYPlot.getLayoutManager().remove(mySimpleXYPlot.getDomainLabelWidget()); mySimpleXYPlot.getLayoutManager().remove(mySimpleXYPlot.getRangeLabelWidget()); mySimpleXYPlot.getLayoutManager().remove(mySimpleXYPlot.getTitleWidget()); // Turn the above arrays into XYSeries': XYSeries series1 = new SimpleXYSeries( Arrays.asList(days), Arrays.asList(values), "Series1"); // Set the display title of the series // Create a formatter to use for drawing a series using LineAndPointRenderer: LineAndPointFormatter series1Format = new LineAndPointFormatter( Color.rgb(0, 200, 0), // line color Color.rgb(0, 100, 0), // point color Color.CYAN); // fill color // setup our line fill paint to be a slightly transparent gradient: Paint lineFill = new Paint(); lineFill.setAlpha(200); lineFill.setShader(new LinearGradient(0, 0, 0, 250, Color.WHITE, Color.GREEN, Shader.TileMode.MIRROR)); series1Format.setFillPaint(lineFill); // add a new series' to the xyplot: mySimpleXYPlot.addSeries(series1, series1Format); // by default, AndroidPlot displays developer guides to aid in laying out your plot. // To get rid of them call disableAllMarkup(): mySimpleXYPlot.disableAllMarkup(); } } 
+6
source share
3 answers

If you want to get rid of all the color behind the graph, you will need the following three methods. Each of them gets rid of different parts.

 //This gets rid of the gray grid mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.TRANSPARENT); //This gets rid of the black border (up to the graph) there is no black border around the labels mysimpleXYPlot.getBackgroundPaint().setColor(Color.TRANSPARENT); //This gets rid of the black behind the graph mySimpleXYPlot.getGraphWidget().getBackgroundPaint().setColor(Color.TRANSPARENT); //With a new release of AndroidPlot you have to also set the border paint plot.getBorderPaint().setColor(Color.TRANSPARENT); 

Hope this helps.

+11
source

The boundary line can be hidden using this method:

 plot.setBorderPaint(null); plot.setPlotMargins(0, 0, 0, 0); 
+3
source

I managed to figure out how to fix the schedule with this information, but I had to collect information from several of these messages. There seem to be four different areas of the background: * grid (and axis labels) * area around the graph * border around the graph. * border around the border

  • The background color for the grid and range / domain labels is set using plot.getGraphWidget().getBackgroundPaint().setColor(background_color);

  • The area around the grid can be set as follows: plot.getBackgroundPaint().setColor(background_color);

  • This still leaves a border that is drawn around the graph. You can either get rid of the border: plot.setBorderPaint(null);

or set the background color

plot.getBorderPaint().setColor(background_color);

  1. This leaves a margin around the entire site. This can be removed using plot.setPlotMargins(0, 0, 0, 0);

There should be a way to change the color for the field instead of just deleting it, but didn't bother to figure it out.

0
source

Source: https://habr.com/ru/post/947772/


All Articles