gpt4 book ai didi

Androidplot:创建时间轴

转载 作者:搜寻专家 更新时间:2023-11-01 07:36:28 27 4
gpt4 key购买 nike

小问题:

如何将 Androidplot 的 X 轴设置为日历(日期和时间)元素?

for(int i=1; i<sY.length;i++)
{
Log.d("Watcher","sY:"+sY[i]);
nY[i] = (Number)Double.parseDouble(sY[i]);
}
for(int i=1; i<sX.length;i++)
{
Log.d("Watcher","sX: "+sX[i]);
nX[i] = (Number)Double.parseDouble(sX[i]);
}

XYSeries series = new SimpleXYSeries(
Arrays.asList(nY),
SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,
getTitle);

LineAndPointFormatter seriesFormat = new LineAndPointFormatter(
Color.rgb(0, 200, 0), // line color
Color.rgb(0, 100, 0), // point color
Color.rgb(150, 190, 150)); // fill color (optional)

oneChart.addSeries(series, seriesFormat);

oneChart.disableAllMarkup();

最佳答案

private class MyDateFormat extends Format { 

private static final long serialVersionUID = 1L;
private SimpleDateFormat dateFormat = new SimpleDateFormat("DDD:kk/mm/ss");

@Override
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
long timestamp = ((Number) obj).longValue();
Date date = new Date(timestamp);
return dateFormat.format(date, toAppendTo, pos);
}

@Override
public Object parseObject(String source, ParsePosition pos) {
return null;
}
}

oneChart.setDomainValueFormat(new MyDateFormat());

关于Androidplot:创建时间轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10516081/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com