我有一张静态图表,我希望在动态图表中进行转换。我能怎么做?这是代码:
MainActivity
public void lineGraphHandler (View view)
{
LineGraph line = new LineGraph();
Intent lineIntent = line.getIntent(this);
startActivity(lineIntent);
}
LineGraph
public class LineGraph{
public Intent getIntent(Context context) {
Random r = new Random();
Random a = new Random();
// Our first data
int[] x = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
int[] y = {29, 30, 34, 45, 57, 77, 89, 100, 111 ,123 ,145 }; // y values!
TimeSeries series = new TimeSeries("Line1");
for( int i = 0; i < 1000; i++)
{
int i1 = r.nextInt(80 );
int i2 = a.nextInt(80 );
series.add(i1, i2);
}
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(series);
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer(); // Holds a collection of XYSeriesRenderer and customizes the graph
XYSeriesRenderer renderer = new XYSeriesRenderer(); // This will be used to customize line 1
XYSeriesRenderer renderer2 = new XYSeriesRenderer(); // This will be used to customize line 2
mRenderer.addSeriesRenderer(renderer);
mRenderer.addSeriesRenderer(renderer2);
mRenderer.setChartTitle("EMG signal");
mRenderer.setXTitle("t [s]");
mRenderer.setYTitle("A [mV]");
mRenderer.setZoomButtonsVisible(true);
mRenderer.setChartTitleTextSize(50);
mRenderer.setLegendTextSize(35);
mRenderer.setLabelsTextSize(26);
mRenderer.setAxisTitleTextSize(30);
mRenderer.setXAxisMin(0);
mRenderer.setXAxisMax(1);
mRenderer.setPanEnabled(true, false);
// Customization time for line 1!
renderer.setColor(Color.WHITE);
renderer.setLineWidth(15);
renderer.setFillPoints(true);
Intent intent = ChartFactory.getLineChartIntent(context, dataset, mRenderer, "Line Graph Title");
return intent;
}
}
协调数据我想把它们带到dall&#39; activity main并将它们传递给第二个主要活动。 感谢。