我用阿卡通做了普通的折线图,可以平移、缩放等。
最初,这张图表在平底锅上消失了。
我得到的opengl渲染警告-路径太大,无法渲染成纹理。
我把硬件加速变成了错误,这就解决了问题。
现在,当我缩放图表,如果数据点超出可见区域,图形消失,它将轴设置为10000到0万。
请参考随附的截图。
当点位于可见区域时:
当我缩放时,这些点超出了可见区域:
这是图书馆的问题吗?
如果有的话,有人能解决这个问题吗?
编辑:——
下面是一些代码:
mRenderer.setApplyBackgroundColor(true);
mRenderer.setBackgroundColor(Color.WHITE);
mRenderer.setMarginsColor(Color.WHITE);
mRenderer.setAxisTitleTextSize(16);
mRenderer.setChartTitleTextSize(20);
mRenderer.setLabelsTextSize(15);
mRenderer.setLegendTextSize(15);
mRenderer.setZoomButtonsVisible(false);
mRenderer.setPointSize(8);
if (mChartView == null) {
layout = (RelativeLayout) findViewById(R.id.chart);
leftDate = (TextView) findViewById(R.id.left_date);
rightDate = (TextView) findViewById(R.id.right_date);
layout.setEnabled(true);
mChartView = ChartFactory.getLineChartView(this, mDataset,
mRenderer);
// enable the chart click events
mRenderer.setClickEnabled(true);
mRenderer.setSelectableBuffer(10);
String seriesTitle = "Series " + (mDataset.getSeriesCount() + 1);
// create a new series of data
XYSeries series = new XYSeries(seriesTitle);
mDataset.addSeries(series);
mCurrentSeries = series;
// create a new renderer for the new series
XYSeriesRenderer renderer = new XYSeriesRenderer();
renderer.setColor(Color.BLACK);
renderer.setPointStyle(PointStyle.CIRCLE);
renderer.setPointStrokeWidth(5);
renderer.setShowLegendItem(false);
renderer.setFillPoints(true);
renderer.setFillBelowLine(true);
renderer.setFillBelowLineColor(getResources().getColor(
R.color.graph_green));
renderer.setFillPoints(true);
renderer.setDisplayChartValuesDistance(20);
mRenderer.addSeriesRenderer(renderer);
// set some renderer properties
mCurrentRenderer = renderer;
mRenderer.setAxisTitleTextSize(16);
// mRenderer.setChartTitleTextSize(20);
// mRenderer.setLabelsTextSize(15);
// mRenderer.setLegendTextSize(15);
mRenderer.setPanEnabled(true, false);
mRenderer.setYAxisAlign(Align.LEFT, 0);
mRenderer.setYLabelsAlign(Align.RIGHT, 0);
mRenderer.setXLabelsColor(Color.WHITE);
mRenderer.setApplyBackgroundColor(true);
mRenderer.setBackgroundColor(Color.WHITE);
mRenderer.setMarginsColor(Color.WHITE);
mRenderer.setPointSize(8f);
mRenderer.setAxesColor(Color.GRAY);
mRenderer.setLabelsColor(Color.BLACK);
try {
FetchWeight fetchWeight = FetchWeightCacheManager
.getObject(Controller.getAppBackgroundContext());
if (fetchWeight.getData().size() != 0) {
for (int i = 0; i < fetchWeight.getData().size(); i++) {
kilo = (long) fetchWeight.getData().get(i).getKilos();
weight_date = (long) fetchWeight.getData().get(i)
.getTimestamp();
if (count == 0) {
default_start_date = weight_date - 100000;
System.out.println("default start date = "
+ default_start_date);
mCurrentSeries.add(default_start_date, kilo);
weights.add(kilo);
dates.add(default_start_date);
count++;
}
System.out.println("time:" + weight_date);
System.out.println("kilo:" + kilo);
mCurrentSeries.add(weight_date, kilo);
weights.add(kilo);
dates.add(weight_date);
}
}
} catch (Exception e) {
System.out.println("No weights to fetch :" + e);
}
double minx = mRenderer.getXAxisMin();
double maxx = mRenderer.getXAxisMax();
System.out.println("min x = " + minx);
System.out.println("max x = " + maxx);
mRenderer.setRange(new double[] { default_start_date,
weight_date + 1000000, kilo - 20, kilo + 20 });
mY.setText("");
// repaint the chart such as the newly added point to be visible
mChartView.repaint();
下面是泛听众:
mChartView.addPanListener(new PanListener() {
private double timestampdouble;
private Integer image_index;
private int mid_value;
private Double max_double;
private Double min_double;
public void panApplied() {
// customListAdapter.setGraphTouched(true);
ArrayList<Long> insideweights = new ArrayList<Long>();
double minx = mRenderer.getXAxisMin();
double maxx = mRenderer.getXAxisMax();
long minx_default = (long) minx;
long maxx_default = (long) maxx;
// change UI onscrollview minx & maxx
leftDate.setText("" + getDateFormat(minx_default));
rightDate.setText("" + getDateFormat(maxx_default));
new AsyncScroll(minx_default, maxx_default).execute();
double getmax_weight = get_max_weight();
double getmin_weight = get_min_weight();
if (minx_default <= default_start_date) {
mRenderer.setRange(new double[] { default_start_date,
maxx, getmin_weight - 20, getmax_weight + 20 });
} else {
mRenderer.setRange(new double[] { minx, maxx,
getmin_weight - 20, getmax_weight + 20 });
}
}
GETXMax权重/GETA MIN权重从Y轴得到最小值和最大点,我用它们来渲染图。
这是一个混乱的代码,但我不能在这里张贴整个代码。
最佳答案
setFillBelowLine
和setFillBelowLineColor
已弃用。
尝试
FillOutsideLine fill = new FillOutsideLine(FillOutsideLine.Type.BOUNDS_ABOVE);
fill.setColor(Color.GREEN);
renderer.addFillOutsideLine(fill );