本文整理汇总了Java中com.jjoe64.graphview.helper.StaticLabelsFormatter类的典型用法代码示例。如果您正苦于以下问题:Java StaticLabelsFormatter类的具体用法?Java StaticLabelsFormatter怎么用?Java StaticLabelsFormatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StaticLabelsFormatter类属于com.jjoe64.graphview.helper包,在下文中一共展示了StaticLabelsFormatter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configGraphic
import com.jjoe64.graphview.helper.StaticLabelsFormatter; //导入依赖的package包/类
private void configGraphic() {
series = new LineGraphSeries<>(graphicUtils.getDataPoints(getApplicationContext(), ExpenseDAO.getNoFilter()));
series.setTitle(getString(R.string.total));
series.setColor(Color.RED);
graph.addSeries(series);
graph.setTitle(getString(R.string.title_graphic));
graph.getViewport().setMinY(0);
graph.getViewport().setYAxisBoundsManual(true);
graph.getLegendRenderer().setVisible(true);
graph.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.TOP);
StaticLabelsFormatter labels = new GraphicUtils().getLabels(graph);
graph.getGridLabelRenderer().setLabelFormatter(labels);
}
示例2: getLabels
import com.jjoe64.graphview.helper.StaticLabelsFormatter; //导入依赖的package包/类
public StaticLabelsFormatter getLabels(GraphView graph) {
String[] labels = getStringsLabels(Calendar.getInstance());
StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph);
staticLabelsFormatter.setHorizontalLabels(labels);
return staticLabelsFormatter;
}
示例3: createCompletionGraph
import com.jjoe64.graphview.helper.StaticLabelsFormatter; //导入依赖的package包/类
/**
* Creates the completion metrics graph for the habit
*/
private void createCompletionGraph() {
int startedWeeksAgo = DateUtil.WeekDifference(habit.getStartDate(), DateTime.now());
if (startedWeeksAgo > 3) startedWeeksAgo = 3;
Double runningTotal = 0.00;
Double[] runningAverages = new Double[4];
for (int i = -1 * startedWeeksAgo; i <= 0; i++) {
runningTotal += completionMetrics.get(3+i);
runningAverages[3+i] = runningTotal/(startedWeeksAgo + i + 1);
}
ArrayList<DataPoint> dataPoints = new ArrayList<>();
for (int i = -1 * startedWeeksAgo; i <= 0; i++) {
if(runningAverages[3+i] == null) runningAverages[3+i] = 0.00;
dataPoints.add(new DataPoint(i, runningAverages[3+i]));
}
if(dataPoints.size() == 1) {
dataPoints.add(new DataPoint(-1, 0.0));
Collections.reverse(dataPoints);
}
//habit.setCompletionRate(runningAverages[3]);
//habitRepository.update(habit.getKey(), habit);
GraphView graph = (GraphView) findViewById(R.id.graph);
graph.removeAllSeries();
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(dataPoints.toArray(new DataPoint[dataPoints.size()]));
series.setTitle("Completion Metrics");
series.setColor(Color.RED);
graph.getViewport().setMinX(-3);
graph.getViewport().setMaxX(0);
graph.getViewport().setMinY(0);
graph.getViewport().setMaxY(100);
graph.getViewport().setYAxisBoundsManual(true);
graph.getViewport().setXAxisBoundsManual(true);
String[] xLabels = new String[4];
ArrayList<Week> pastNWeeks = DateUtil.GetNPastWeeks(DateTime.now(), 4);
for (int i = 0; i < 4; i++) {
xLabels[i] = pastNWeeks.get(i).getStartOfWeek().toString("MMM d");
}
// use static labels for horizontal and vertical labels
StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph);
staticLabelsFormatter.setVerticalLabels(new String[] {"0%","20%","40%","60%","80%","100%"});
staticLabelsFormatter.setHorizontalLabels(xLabels);
graph.setTitle("Events completed over last 4 weeks");
int bgColor = (15 & 0xff) << 24 | (0xD3 & 0xff) << 16 | (0x2F & 0xff) << 8 | (0x2F & 0xff);
graph.getViewport().setBackgroundColor(bgColor);
graph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);
graph.getGridLabelRenderer().setHighlightZeroLines(false);
graph.getGridLabelRenderer().setNumHorizontalLabels(4);
graph.getGridLabelRenderer().setNumVerticalLabels(6);
graph.addSeries(series);
}