/
SinhFunction.java
55 lines (46 loc) · 1.58 KB
/
SinhFunction.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package org.achartengine.chartdemo.demo.chart;
import java.util.ArrayList;
import java.util.List;
import org.achartengine.ChartFactory;
import org.achartengine.chart.PointStyle;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
public class SinhFunction extends AbstractDemoChart{
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getDesc() {
// TODO Auto-generated method stub
return null;
}
@Override
public Intent execute(Context context) {
String[] titles = new String[] { "sin + cos"};
List<double[]> x = new ArrayList<double[]>();
List<double[]> values = new ArrayList<double[]>();
int step = 4;
int count = 360 / step + 1;
x.add(new double[count]);
double[] sinValues = new double[count];
values.add(sinValues);
for (int i = 0; i < count; i++) {
int angle = i * step;
x.get(0)[i] = angle;
double rAngle = Math.toRadians(angle);
sinValues[i] = Math.sinh(rAngle);
}
int [] colors = new int[] { Color.RED};
PointStyle[] styles = new PointStyle[] { PointStyle.POINT };
XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
setChartSettings(renderer, "Trigonometric functions", "X (in degrees)", "Y", 0, 360, -2, 2,
Color.GRAY, Color.LTGRAY);
renderer.setXLabels(20);
renderer.setYLabels(10);
return ChartFactory.getLineChartIntent(context, buildDataset(titles, x, values), renderer);
}
}