MPAndroidChart-Realm icon indicating copy to clipboard operation
MPAndroidChart-Realm copied to clipboard

Can XValue be a non-float?

Open marcoxsurf opened this issue 7 years ago • 6 comments

public class MisuraRealm extends RealmObject{
    @PrimaryKey
    private int idMisura;

    private double lat;
    private double lon;

    //epoch time in msec
    private long time;
    private double value;
    //UoM
    @SerializedName("uom")
    private String symbol;

    private String  sensorName;
    private String  packageName;
    private int     idSessione;

   //getters and setters
}

I want time field on the X-Axis and value on the Y-Axis. Is that possible? I got error on x-value that has to be float, mine is long.

marcoxsurf avatar Mar 16 '17 23:03 marcoxsurf

I have this same exact issue.

Schrobie avatar Mar 19 '17 01:03 Schrobie

Same issue.

mruijzendaal avatar May 06 '17 22:05 mruijzendaal

Same issue. Is this library alive ?

DanChaltiel avatar Jul 10 '17 07:07 DanChaltiel

Same issue, I want to use the date on one axis, Has any of you succeeded?

2mbili avatar Sep 05 '17 13:09 2mbili

Perhaps this IAxisValueFormatter can be of any help?

public class DateAxisValueFormatter implements IAxisValueFormatter {
	// Minimum seperation for showing a new date
	public static final float GRANULARITY = 24*60*60*1000; // 24 hours / 1 day

	private static final float SHOW_YEAR_THRESHOLD = 6*30*24*60*60*1000f; // 6 Months
	private static final float SHOW_MONTH_THRESHOLD = 0f;

	private BarLineChartBase<?> chart;
	private DateFormatHelper dateFormatHelper;

	public DateAxisValueFormatter(Context context, BarLineChartBase<?> chart) {
		this.chart = chart;
		dateFormatHelper = new DateFormatHelper(context);
	}

	@Override
	public String getFormattedValue(float value, AxisBase axis) {
		float visibleXrange = chart.getVisibleXRange();
		CharSequence dateString;
		if (visibleXrange > SHOW_YEAR_THRESHOLD){
			dateString = dateFormatHelper.yearMonthDayLong((long) value);
		}else if (visibleXrange > SHOW_MONTH_THRESHOLD){
			dateString = dateFormatHelper.monthDayShort((long) value);
		}else{
			dateString = dateFormatHelper.monthDayShort((long) value);
		}
		return dateString.toString();
	}
}

mruijzendaal avatar Sep 05 '17 14:09 mruijzendaal

Yes it is, Thank you.

2mbili avatar Sep 26 '17 12:09 2mbili