镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Can XValue be a non-float? #8

Open

Description

@marcoxsurf
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.

Activity

  1. Schrobie commented on Mar 19, 2017

    @Schrobie

    I have this same exact issue.

  2. mruijzendaal commented on May 6, 2017

    @mruijzendaal

    Same issue.

  3. DanChaltiel commented on Jul 10, 2017

    @DanChaltiel

    Same issue. Is this library alive ?

  4. 2mbili commented on Sep 5, 2017

    @2mbili

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

  5. mruijzendaal commented on Sep 5, 2017

    @mruijzendaal

    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();
    	}
    }
    
  6. 2mbili commented on Sep 26, 2017

    @2mbili

    Yes it is, Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions