Achartengine does not display the last value on the line - android

hello guys i'm trying to write a simple line graph but it does not render the last value on the lines. I want to show all the values on the linegraph.
http://imgur.com/EHFh1xP
http://imgur.com/CWl8CDi
the code is tried is
XYSeriesRenderer rendererLijn0 = new XYSeriesRenderer();
rendererLijn0.setColor(Color.RED);
rendererLijn0.setChartValuesTextSize(rendererLijn0.getChartValuesTextSize()+20);
rendererLijn0.setDisplayChartValues(true);
rendererLijn0.setPointStyle(PointStyle.CIRCLE);
rendererLijn0.setFillPoints(true);
rendererLijn0.setDisplayBoundingPoints(true);
XYSeriesRenderer rendererLijn1 = new XYSeriesRenderer();
rendererLijn1.setDisplayChartValues(true);
rendererLijn1.setPointStyle(PointStyle.CIRCLE);
rendererLijn1.setFillPoints(true);
rendererLijn1.setDisplayBoundingPoints(true);
AlleSeries.addSeries(GrafiekDataLijn0);
AlleSeries.addSeries(GrafiekDataLijn1);
AlleRenderers.addSeriesRenderer(rendererLijn0);
AlleRenderers.addSeriesRenderer(rendererLijn1);
AlleRenderers.setXTitle("Tijden");
AlleRenderers.setYTitle("Waarde Lijnen");
AlleRenderers.setYAxisMin(0);
AlleRenderers.setYAxisMax((hoogste + 20));
AlleRenderers.setZoomEnabled(true);
AlleRenderers.setZoomButtonsVisible(true);
AlleRenderers.setXLabelsAlign(Align.CENTER);
AlleRenderers.setXAxisMin(0-0.2);
AlleRenderers.setXAxisMax(GrafiekDataLijn1.getItemCount());
GraphicalView Grafiek = ChartFactory.getLineChartView(
getBaseContext(), AlleSeries, AlleRenderers);
lnGrafiek.addView(Grafiek);

Try giving some padding to your view:
Grafiek.setPadding(0,0,20,0);//(left, top, right, bottom);

Related

achartengine fill out side in linechart

I have a problem with fill out side in linechart below. Here is a demo that i have draw. How can i remove the area in red block.
XYSeriesRenderer renderer = new XYSeriesRenderer();
renderers.addSeriesRenderer(renderer);
renderer.setLineWidth(2f);
renderer.setPointStrokeWidth(7f);
renderer.setPointStyle(PointStyle.CIRCLE);
FillOutsideLine below = new FillOutsideLine(FillOutsideLine.Type.BELOW);
renderer.addFillOutsideLine(below);

Android achartengine FillOutsideLine with gradient color

Can we use a gradient style for FillOutsideLine of achartlibrary to color the below side of the line ?
so far I managed to use simple Color.argb(), but I can't use any xml to make it gradient or it will crash
can we fix this issue ?
code:
FillOutsideLine fill = new FillOutsideLine(FillOutsideLine.Type.BOUNDS_ALL);
fill.setColor(Color.argb(55, 62, 117, 163));
renderer.addFillOutsideLine(fill);
Well, it's bit tricky, but you can set FillOutsideLine ABOVE with your background color, make chart background transparent, and add gradient background to GraphicalView.
Upd
I'm using Xamarin for now, that's why C#. Anyway, hope it helps :)
XYSeriesRenderer renderer = new XYSeriesRenderer();
...
//Set up fill
XYSeriesRenderer.FillOutsideLine fill = new XYSeriesRenderer.FillOutsideLine(XYSeriesRenderer.FillOutsideLine.FillOutsideLineBehaviorType.Above);
fill.Color = Color.White.ToAndroid();
renderer.AddFillOutsideLine(fill);
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
mRenderer.AddSeriesRenderer(renderer);
//Set chart background
mRenderer.BackgroundColor = Color.Transparent.ToAndroid();
...
chartView = ChartFactory.GetLineChartView(Forms.Context, dataset, mRenderer);
//Set gradient background
chartView.SetBackgroundResource(Droid.Resource.Drawable.chart_gradient);

Formatting achartengine line graph

I am using achartengine, to plot a line graph. I am trying to customize it to have Y axis lines which pass through the values, and show the values on top. Does any one have any idea, how can I achieve an effect like this one :
Here is what I currently have :
And here is the code Snippet :
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(series);
XYSeriesRenderer renderer = new XYSeriesRenderer();
renderer.setPointStyle(PointStyle.CIRCLE);
renderer.setFillPoints(true);
renderer.setColor(Color.WHITE);
renderer.setLineWidth(2f);
XYMultipleSeriesRenderer seriesRenderer = new XYMultipleSeriesRenderer();
seriesRenderer.addSeriesRenderer(renderer);
seriesRenderer.setLabelsTextSize(20); // Text size
seriesRenderer.setShowAxes(true); // show both axes
seriesRenderer.setShowLegend(false);
seriesRenderer.setShowGridX(true); // X grid helps identify values
seriesRenderer.setShowLabels(true); // See the values
seriesRenderer.setYLabelsAlign(Align.RIGHT);
seriesRenderer.setZoomButtonsVisible(false); // bye bye zoom
seriesRenderer.setXAxisMin(0);
seriesRenderer.setXAxisMax(10);
seriesRenderer.setTextTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Lifestyle Rounded M54.ttf"));
seriesRenderer.setPointSize(10f);
seriesRenderer.setPanEnabled(true, false);
View view = ChartFactory.getLineChartView(context, dataset, seriesRenderer);
return view;
Any input will be highly appreciated.
You can add annotation that can be displayed wherever you need on the graph:
series.addAnnotation(text, x, y);

Android AChartEngine graphicalView share events

First i give my View show below. and give some explanation:
In my ViewGroup i have two GraphicalView, each of them share the same size space. Let's just call the chart above chartA and below one chartB.
Then i have some questions:
If i make a move a movement on chartA ,how could i make the chartB move just as my finger moving on chartB?
If i pinch on chartA can also chartB change auto?
I want to add some callback function to some points? Does ACE supports this?
I do not want to show numbers negative while user pinching.How can I make this point?
Last is my chart code:
mDataset.addSeries(series);
PointStyle style = PointStyle.CIRCLE;
renderer = buildRenderer(lineColor, style, true);
setChartSettings(renderer, "X", "Y", 0, 50, yMin, yMax, Color.WHITE,
Color.WHITE, title,chartColor);
GraphicalView chart = ChartFactory.getLineChartView(context, mDataset, renderer);
layout.addView(chart, new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
HashMap map = new HashMap();
and the renderer:
protected XYMultipleSeriesRenderer buildRenderer(int color,
PointStyle style,
boolean fill) {
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
XYSeriesRenderer r = new XYSeriesRenderer();
r.setColor(color);
r.setPointStyle(style);
r.setFillPoints(fill);
r.setLineWidth(3);
renderer.addSeriesRenderer(r);
return renderer;
}
I random all the data i want.
You have to register a PanListener on your chartA and on every panApplied event, just do: rendererB.setXAxisMin(rendererA.getXAxisMin()); and the same for max X and for the Y axis and then call chartB.repaint();
Same as the above, just that you need to add a ZoomListener.
You can set a click listener: chartA.setOnClickListener();
Please reformulate into a separate question.
Also, see this code showing you how to use the above APIs.

Android: How to create negative values in plots axis based on achartengine lib?

I want to create XY plot with positive and negative numbers on both axys. By default achartnegine shows negative values of series but the start popint is always zero^ graph start from zero and next nubmer is something like -50, -40 etc. I have tried to avoid this but haven;t succed yet. Could you please suggest the right approach?
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(seriesXY);
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
//renderer.setXAxisMin(-10f);
//renderer.setYAxisMin(-250f);
//renderer.setBarSpacing(SPACING);
//renderer.setRange(new double[] { -250d, 250d});
XYSeriesRenderer sRenderer = new XYSeriesRenderer();
sRenderer.setColor(Color.BLUE);
sRenderer.setFillBelowLine(false);
sRenderer.setChartValuesSpacing(SPACING);
sRenderer.setFillBelowLineColor(Color.WHITE);
sRenderer.setFillPoints(false);
renderer.addSeriesRenderer(sRenderer);
renderer.setApplyBackgroundColor(true);
renderer.setBackgroundColor(Color.WHITE);
renderer.setMarginsColor(Color.WHITE);
renderer.setAxesColor(Color.BLACK);
renderer.setXLabelsColor(Color.BLUE);
renderer.setYLabelsColor(0, Color.BLUE);
renderer.setXLabelsAlign(Align.RIGHT);
renderer.setYLabelsAlign(Align.RIGHT);
GraphicalView chartView = ChartFactory.getLineChartView(
getActivity(),
dataset, renderer);
plot.removeAllViews();
plot.addView(chartView, new LayoutParams(
LayoutParams.MATCH_PARENT, 200));
chartView.repaint();
I use LineChartView
The answer is that you cannot put the axis in the center of the chart with AChartEngine as it is out of the box.

Categories

Resources