Mountain Chart Logarithmic - android

I'm trying to create a mountain chart using SciChart, but I need to create using Logarithmic, I tried the below code, but dont change chart and missing YAxis label.
I change the demo SciChart to it:
public class MountainChartFragment extends ExampleBaseFragment {
#BindView(R.id.chart)
SciChartSurface surface;
private double selectedLogBase = 10d;
#Override
protected int getLayoutId() {
return R.layout.example_single_chart_fragment;
}
#Override
protected void initExample() {
//final IAxis xBottomAxis = sciChartBuilder.newDateAxis().withGrowBy(0.1d, 0.1d).build();
final IAxis xBottomAxis = sciChartBuilder.newDateAxis().withGrowBy(0.1d, 0.1d).build();
final IAxis yRightAxis = sciChartBuilder.newLogarithmicNumericAxis().withScientificNotation(ScientificNotation.LogarithmicBase).withLogarithmicBase(selectedLogBase).withGrowBy(0.1d, 0.1d).build();
//final IAxis yRightAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.1d, 0.1d).build();
final PriceSeries priceData = DataManager.getInstance().getPriceDataIndu(getActivity());
final IXyDataSeries<Date, Double> dataSeries = sciChartBuilder.newXyDataSeries(Date.class, Double.class).build();
dataSeries.append(priceData.getDateData(), priceData.getCloseData());
final FastMountainRenderableSeries rSeries = sciChartBuilder.newMountainSeries()
.withZeroLine(0.001)
.withDataSeries(dataSeries)
.withStrokeStyle(0xAAFFC9A8, 1f, true)
.withAreaFillLinearGradientColors(0xAAFF8D42, 0x88090E11)
.build();
UpdateSuspender.using(surface, new Runnable() {
#Override
public void run() {
Collections.addAll(surface.getXAxes(), xBottomAxis);
Collections.addAll(surface.getYAxes(), yRightAxis);
Collections.addAll(surface.getRenderableSeries(), rSeries);
Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers().build());
sciChartBuilder.newAnimator(rSeries).withWaveTransformation().withInterpolator(new DecelerateInterpolator()).withDuration(3000).withStartDelay(350).start();
}
});
}
}
But dont worked

There are no labels because default TickProvider implementation for LogarithmicNumericAxis can't generate any ticks for auto calculated VisibleRange which is set for YAxis ( it has next values - Min = 10460.814629837885, Max = 13048.710993563885) The nearest values which which would satisfy LogBase = 10 would be 10000 and then 100000 and data set of example lies between these two values so TickProvider returns zero values to render.
In this case there are two possible workarounds:
Try to pick up some other LogBase value;
Set some alternative TickProvider implementation for YAxis (e.g. you can try to use TickProvider for NumericAxis or create your own implementation):
yRightAxis.setTickProvider(new NumericTickProvider());

I change the code and worked well. This is my code:
xAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.1d, 0.1d).withVisibleRange(1.1, 2.7).build();
yAxis = generateLogarithmicAxis();
//yAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.1d, 0.1d).build();
//yAxis.setTickProvider(new NumericTickProvider());
final SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMdd");
String data1 = "20190401";
Date date1 = null;
Calendar c = Calendar.getInstance();
final IXyDataSeries<Date, Double> dataSeries = sciChartBuilder.newXyDataSeries(Date.class, Double.class).build();
try {
date1 = formatDate.parse(data1);
for(int i = 0 ; i<1000 ; i+=10){
double random = Math.random() * 100.0 + 5;
dataSeries.append(date1, random);
c.setTime(date1);
c.add(Calendar.DATE, 1);
date1 = c.getTime();
}
} catch (ParseException e) {
e.printStackTrace();
}
final FastLineRenderableSeries rSeries = sciChartBuilder.newLineSeries().withZeroLine(0.01d).withDataSeries(dataSeries).withStrokeStyle(0xFF279B27, 1f, true).build();
UpdateSuspender.using(surface, new Runnable() {
#Override
public void run() {
Collections.addAll(surface.getXAxes(), xAxis);
Collections.addAll(surface.getYAxes(), yAxis);
Collections.addAll(surface.getRenderableSeries(), rSeries);
Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers().build());
sciChartBuilder.newAnimator(rSeries).withSweepTransformation().withInterpolator(new DecelerateInterpolator()).withDuration(3000).withStartDelay(350).start();
}
});

Related

How to set the starting point of x value to 0?

I want to set the starting point of x value to 0 instead of -1 when there is one data.
This is my execution screen. enter image description here
I tried many methods, but it didn't work.
Does anyone know a solution?
ArrayList values = new ArrayList<>();
for (int i = 0; i < userDataList.size(); i++) {
int time = userDataList.get(i).getTime();
values.add(new Entry(i, time));
}
final ArrayList<String> xLabelList = new ArrayList<String>();
for (int i = 0; i < userDataList.size(); i++) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyMMdd");
Date date = null;
try {
date = simpleDateFormat.parse(Float.toString(userDataList.get(i).getDate()));
} catch (ParseException e) {
e.printStackTrace();
}
SimpleDateFormat newFormat = new SimpleDateFormat("MM/dd");
String dateString = newFormat.format(date);
xLabelList.add(dateString);
}
xAxis.setValueFormatter(new ValueFormatter() {
#Override
public String getFormattedValue(float value) {
if(value<0)
return xLabelList.get(0);
return xLabelList.get((int) value);
}
});
You can try using xAxis.setAvoidFirstLastClipping(true) (it's Kotlin) so that the first and the last labels will be hidden.

DateTime Issue in MPAndroidChart

I toke as example this https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/LineChartTime.java
I adjusted to my needs. The problem is that for plotting data in X axis it need a float number and converting from long to float there is lost of datas. The trick in the example is to convert milliseconds time in HOURLY so there isn't lost of data but i need to convert to DAILY, I tried but couldn't get the results
I've tried to change TimeUnit.HOURS.toMillis((long) value); to TimeUnit.DAYS.toMillis((long) value); and I added timeInHours = TimeUnit.DAYS.toMillis(mDate.getTime());
public class ChartDailyActivity extends AppCompatActivity {
private LineChart chart;
DBOpenHelper mDB;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chart_daily);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setChart();
}
public void setChart(){
chart = findViewById(R.id.chart1);
XAxis xAxis = chart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.TOP_INSIDE);
xAxis.setTextSize(10f);
xAxis.setTextColor(Color.WHITE);
xAxis.setDrawAxisLine(false);
xAxis.setDrawGridLines(true);
xAxis.setTextColor(Color.rgb(255, 192, 56));
xAxis.setCenterAxisLabels(true);
//xAxis.setSpaceMin(1000f*60f*60f*24f);
xAxis.setValueFormatter(new IAxisValueFormatter() {
private final SimpleDateFormat mFormat = new SimpleDateFormat("dd/MM/yy", Locale.ITALIAN);
#Override
public String getFormattedValue(float value, AxisBase axis) {
long millis = TimeUnit.DAYS.toMillis((long) value);
return mFormat.format(new Date(millis));
}
});
mDB = new DBOpenHelper(this);
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
leftAxis.setTextColor(ColorTemplate.getHoloBlue());
leftAxis.setDrawGridLines(true);
leftAxis.setGranularityEnabled(true);
leftAxis.setAxisMinimum(0f);
leftAxis.setAxisMaximum((float) mDB.queryMaxTotaleBevuto());
leftAxis.setYOffset(-9f);
leftAxis.setTextColor(Color.rgb(255, 192, 56));
YAxis rightAxis = chart.getAxisRight();
rightAxis.setEnabled(false);
setData();
}
private void setData() {
ArrayList<Entry> values = new ArrayList<>();
ArrayList xList = new ArrayList<Integer>();
ArrayList yList = new ArrayList<String>();
DBOpenHelper mDB = new DBOpenHelper(this);
xList = mDB.queryTotaleBevutoData();
yList = mDB.queryTotaleBevuto();
float flX, flY;
int intX, intY;
for(int x=0; x<xList.size(); x++){
String givenDateString = (String)xList.get(x);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");
long timeInHours = 0;
try {
Date mDate = sdf.parse(givenDateString);
//Log.d("XLOGGIN:", "Date = " + givenDateString );
timeInHours = TimeUnit.DAYS.toMillis(mDate.getTime());
//timeInMilliseconds = mDate.getTime();
} catch (ParseException e) {
e.printStackTrace();
}
intX = (int)timeInHours;
intY = (int)yList.get(x);
flX = (float)intX;
flY = (float)intY;
/*
Log.d("XLOGGIN:Long", Long.toString(timeInMilliseconds));
Log.d("XLOGGIN:intX", Integer.toString(intX));
Log.d("XLOGGIN:flX", Float.toString(flX));
*/
values.add(new Entry(flX, flY));
}
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(values, "Drinked ml/Day");
set1.setAxisDependency(YAxis.AxisDependency.LEFT);
set1.setColor(ColorTemplate.getHoloBlue());
set1.setValueTextColor(ColorTemplate.getHoloBlue());
set1.setLineWidth(1.5f);
set1.setDrawCircles(false);
set1.setDrawValues(false);
set1.setFillAlpha(65);
set1.setFillColor(ColorTemplate.getHoloBlue());
set1.setHighLightColor(Color.rgb(244, 117, 117));
set1.setDrawCircleHole(false);
// create a data object with the data sets
LineData data = new LineData(set1);
data.setValueTextColor(Color.WHITE);
data.setValueTextSize(9f);
// set data
chart.setData(data);
}
}
The chart plots bad datetime (all dates are 01/01/1970) and the line is a orizzontal line
You are not converting your timestamp into a day equivalent. This is how you should do it (during setData()):
try {
Date mDate = sdf.parse(givenDateString);
//Log.d("XLOGGIN:", "Date = " + givenDateString );
timeInDays = TimeUnit.MILLISECONDS.toDays(mDate.getTime());
//timeInMilliseconds = mDate.getTime();
} catch (ParseException e) {
e.printStackTrace();
}

No data appears on BarChart for X entries when you use y-values as floats

I have tried to add a BarChart in my Code, nothing appear when I launch my app.
The purpose of my code is that: when the user enter the start date (StartDate), end date (EndDate) and the product name, the graph should show the show price evolution during that period.
I have tried the code below, but nothing appear on the graph.
Please help to find the issue, or propose to me another code.
public class ResultProductStatisticsActivity extends AppCompatActivity {
private String mCategory;
private String mName;
private long mStartDate;
private long mEndDate;
private int mNumber = 0;
private ProgressBar mProgressBar;
private ArrayList<ShopDetail> mDetail = new ArrayList<ShopDetail>();
private ArrayList<Float> mPriceList = new ArrayList<Float>();
protected Typeface mTfLight;
private Typeface mTypeFaceLight;
private TextView mMontextViewtest;
private BarChart mChart;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.result_product_statistics_activity);
mChart = (BarChart) findViewById(R.id.m_barchart);
// mChart.setOnChartValueSelectedListener(this);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
AxisValueFormatter xAxisFormatter = new DayAxisValueFormatter(mChart);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTypeface(mTfLight);
xAxis.setDrawGridLines(false);
xAxis.setGranularity(1f); // only intervals of 1 day
xAxis.setLabelCount(7);
xAxis.setValueFormatter(xAxisFormatter);
AxisValueFormatter custom = new MyAxisValueFormatter();
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setLabelCount(8, false);
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(mTfLight);
rightAxis.setLabelCount(8, false);
rightAxis.setValueFormatter(custom);
rightAxis.setSpaceTop(15f);
rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
Legend l = mChart.getLegend();
l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
l.setForm(Legend.LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
// l.setExtra(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
// "def", "ghj", "ikl", "mno" });
// l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
// "def", "ghj", "ikl", "mno" });
init();
mChart.setMarkerView(new XYMarkerView(this, xAxisFormatter));
}
private void init(){
mCategory = Myrecord.getSearchShopCategory(this);
mName = Myrecord.getSearchShopName(this);
mStartDate = Myrecord.getSearchStartTime(this);
mEndDate = Myrecord.getSearchEndTime(this);
if(mStartDate == -1){
mStartDate = Long.MIN_VALUE;
}
if(mEndDate == -1){
mEndDate = Long.MAX_VALUE;
}
Thread thread = new Thread(){
#Override
public void run() {
MyDB db = new MyDB(ResultProductStatisticsActivity.this);
ArrayList<MyDetail> detailList = db.getMyDetailByAll(mCategory, mName, -1, 0, -1);
for(int i = 0; i < detailList.size(); i ++){
MyDetail detail = detailList.get(i);
long date = detail.date;
if(date >= mStartDate && date <= mEndDate){
mPriceList.add(db.getPriceGoodsByOwnName("ALEVONS")+0f);
}
}
ResultProductStatisticsActivity.this.runOnUiThread(new Runnable() {
#Override
public void run() {
setData(mPriceList);
}
});
}
};
thread.start();
}
private void setData(ArrayList<Float> mPriceList) {
mChart.getXAxis().setAxisMinValue(mStartDate);
mChart.getXAxis().setAxisMaxValue(mEndDate);
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < mPriceList.size(); i++) {
yVals1.add(new BarEntry(i , mPriceList.get(i)));
}
BarDataSet set1;
if (mChart.getData() != null &&
mChart.getData().getDataSetCount() > 0) {
set1 = (BarDataSet) mChart.getData().getDataSetByIndex(0);
set1.setValues(yVals1);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
set1 = new BarDataSet(yVals1, "Evolution du prix produit");
set1.setColors(ColorTemplate.MATERIAL_COLORS);
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(dataSets);
data.setValueTextSize(10f);
data.setValueTypeface(mTfLight);
data.setBarWidth(0.9f);
mChart.setData(data);
}
}
}
A wild guess, without any more details provided: your're setting the x-axis min and max values to the start and end date. I'm guessing this is encoded in unix time, so you have something like 1470614400 and 1471219200.
Now looking at your data, it will start with 0 and go up to the number of prices you have in your price list (mPriceList.size()). So with 10 prices we'd have values at 0 through 9. However, since your x-axis starts at 1470614400, no data will be shown (although the axis, gridlines etc. should be visible).
So in order to fix your code (depending on how your price list is structured, this example assumes one price every hour), you'd need to change your code in setData to this:
for (int i = 0; i < mPriceList.size(); i++) {
yVals1.add(new BarEntry(mStartDate + i * 3600, mPriceList.get(i)));
}
If you have a list of dates associated with the price values, you can also simply do this:
for (int i = 0; i < mPriceList.size(); i++) {
yVals1.add(new BarEntry(mDateList.get(i), mPriceList.get(i)));
}
We the reply of(#TR4Android),
I have update my code such below and I can get the graph:
float start = 0f;
mChart.getXAxis().setAxisMinValue(start);
mChart.getXAxis().setAxisMaxValue(mPriceList.size());
for (int i = 0; i < mPriceList.size(); i++) {
yVals1.add(new BarEntry(i , mPriceList.get(i)));
}
But I have a bit issue with start date end date where each item has been bought. I have put each date in array list but I don't see how I can put it on xAxis. The Array list is :
private ArrayList<Long> mDateList = new ArrayList<Long>();
One example of mDateList value is 2016/08/13

Android: GraphView How do I implement time in the X axis?

I'm finding it a bit difficult to figure out how to implement time in the X Axis of a graph in Android?
This is my code:
for (int i = 0; i < listSize; i++)
{
String[] onlyReading = mData.get(i).getReading().split(" ");
readingList[i] = Double.parseDouble(onlyReading[0]);
String date = mData.get(i).getUnFormatedDate();
String[] temp = date.split(" ");
String[] dateTemp = null;
String[] timeTemp = null;
if(temp.length > 0)
{
dateTemp = temp[0].trim().split("-");
timeTemp = temp[1].trim().split(":");
Date dateObj = new Date();
String year = "0";
if(dateTemp != null)
{
dateObj.setDate(Integer.parseInt(dateTemp[0]));
dateObj.setMonth(Integer.parseInt(dateTemp[1]) - 1);
year = dateTemp[2].trim();
if(dateTemp[2].trim().length() == 4)
{
year = dateTemp[2].substring(2, 4);
}
dateObj.setYear(Integer.parseInt(year)+100);
}
if(timeTemp != null)
{
calendar = new GregorianCalendar(Integer.parseInt(year) + 2000, Integer.parseInt(dateTemp[1]) - 1, Integer.parseInt(dateTemp[0]), Integer.parseInt(timeTemp[0]), Integer.parseInt(timeTemp[1]));
}
dateObj = new Date(calendar.getTimeInMillis());
dateList[i] = dateObj;
}
}
if(dateList.length > 0)
{
//dates.clear();
//values.clear();
//readingData.clear();
//readingDate.clear();
GraphViewData[] data = new GraphViewData[dateList.length];
LineGraphView graphView = new LineGraphView(
getActivity() // context
, "" // heading
);
for (int i = 0; i < listSize; i++)
{
data[i] = new GraphViewData(Double.valueOf(i), readingList[i]);
}
GraphViewSeries exampleSeries = new GraphViewSeries(data);
graphView.addSeries(exampleSeries);
graphView.setDrawBackground(false);
((LineGraphView) graphView).setDrawDataPoints(true);
graphView.getGraphViewStyle().setGridColor(0);
graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.WHITE);
graphView.getGraphViewStyle().setVerticalLabelsColor(Color.WHITE);
graphView.getGraphViewStyle().setNumHorizontalLabels(5);
graphView.getGraphViewStyle().setNumVerticalLabels(5);
graphView.setManualYAxisBounds(400, 0);
mGraphParent.addView(graphView);
}
}
Even though I add the Y axis values, I'm not able to figure out how to add time values to the X-axis?
I know it is an old question, but I solved by using DefaultLabelFormatter().
graphView.getGridLabelRenderer().setLabelFormatter(new DefaultLabelFormatter() {
#Override
public String formatLabel(double value, boolean isValueX) {
if (isValueX) {
Format formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return formatter.format(value);
}
return super.formatLabel(value, isValueX);
}
});
Based on the following video:
https://www.youtube.com/watch?v=xt8gx7Z7yJU
the trick is to just convert the time to seconds or milliseconds (unix time) and you it as X-value.
There's an example on the GraphView-Demos project. Take a look at:
https://github.com/jjoe64/GraphView-Demos/blob/master/src/com/jjoe64/graphviewdemos/CustomLabelFormatterActivity.java#L68
I had the same issue. The easiest method was to convert Time into milliseconds. Using a Gregorian Calendar might be more helpful as the methods in Date are deprecated.
Calendar cal=new GregorianCalendar(2014,6,12,9,30,0);
data[i]=new GraphViewData(cal.getTimeInMillis,VALUE);
Then set the CustomLabelFormatter.
graphView.setCustomLabelFormatter(new CustomLabelFormatter() {
#Override
public String formatLabel(double value, boolean isValueX) {
// TODO Auto-generated method stub
if (isValueX) {
Date d = new Date((long) (value));
return (dateFormat.format(d));
}
return "" + (int) value;
}
});
Time/Date appears in the format specified in dateFormat.

Battery graph in android using GraphView library?

i found i great library to draw graphs. I want to create one that displays in the x axis the time and in y the battery percentage. My goal is create a graph like this:
You can see the percentage on the left and the date/time on bottom. Starting from this example code : https://github.com/jjoe64/GraphView-Demos/blob/master/src/com/jjoe64/graphviewdemos/CustomLabelFormatterActivity.java i want insert the correct data but i never used graphs. This is the activity
public class CustomLabelFormatterActivity extends Activity {
/** Called when the activity is first created. */
#SuppressLint("SimpleDateFormat")
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.graphs);
// init example series data
Random rand = new Random();
int size = 20;
GraphViewData[] data = new GraphViewData[size];
for (int i=0; i<size; i++) {
data[i] = new GraphViewData(i, rand.nextInt(20));
}
GraphViewSeries exampleSeries = new GraphViewSeries(data);
GraphView graphView;
if (getIntent().getStringExtra("type").equals("bar")) {
graphView = new BarGraphView(
this // context
, "GraphViewDemo" // heading
);
} else {
graphView = new LineGraphView(
this // context
, "GraphViewDemo" // heading
);
}
graphView.addSeries(exampleSeries); // data
graphView.setCustomLabelFormatter(new CustomLabelFormatter() {
#Override
public String formatLabel(double value, boolean isValueX) {
if (isValueX) {
if (value < 5) {
return "small";
} else if (value < 15) {
return "middle";
} else {
return "big";
}
}
return null; // let graphview generate Y-axis label for us
}
});
LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
layout.addView(graphView);
/*
* use Date as x axis label
*/
long now = new Date().getTime();
data = new GraphViewData[size];
for (int i=0; i<size; i++) {
data[i] = new GraphViewData(now+(i*60*60*24*1000), rand.nextInt(20)); // next day
}
exampleSeries = new GraphViewSeries(data);
if (getIntent().getStringExtra("type").equals("bar")) {
graphView = new BarGraphView(
this
, "GraphViewDemo"
);
} else {
graphView = new LineGraphView(
this
, "GraphViewDemo"
);
((LineGraphView) graphView).setDrawBackground(true);
}
graphView.addSeries(exampleSeries); // data
/*
* date as label formatter
*/
final SimpleDateFormat dateFormat = new SimpleDateFormat("MMM d h.mm");
graphView.setCustomLabelFormatter(new CustomLabelFormatter() {
#Override
public String formatLabel(double value, boolean isValueX) {
if (isValueX) {
Date d = new Date((long) value);
return dateFormat.format(d);
}
return null; // let graphview generate Y-axis label for us
}
});
layout = (LinearLayout) findViewById(R.id.graph2);
layout.addView(graphView);
}
}
What have i to change?How can i create what i want?Anyone can help me? Thank you.

Categories

Resources