本文整理汇总了Java中lecho.lib.hellocharts.model.SubcolumnValue.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java SubcolumnValue.setColor方法的具体用法?Java SubcolumnValue.setColor怎么用?Java SubcolumnValue.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lecho.lib.hellocharts.model.SubcolumnValue
的用法示例。
在下文中一共展示了SubcolumnValue.setColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateDefaultData
import lecho.lib.hellocharts.model.SubcolumnValue; //导入方法依赖的package包/类
private void generateDefaultData() {
int numSubcolumns = 1;
int numColumns = 50;
List<Column> columns = new ArrayList<Column>();
List<SubcolumnValue> values;
for (int i = 0; i < numColumns; ++i) {
values = new ArrayList<SubcolumnValue>();
for (int j = 0; j < numSubcolumns; ++j) {
values.add(new SubcolumnValue((float) Math.random() * 50f + 5, ChartUtils.pickColor()));
}
columns.add(new Column(values));
}
data = new ColumnChartData(columns);
data.setAxisXBottom(new Axis());
data.setAxisYLeft(new Axis().setHasLines(true));
// prepare preview data, is better to use separate deep copy for preview chart.
// set color to grey to make preview area more visible.
previewData = new ColumnChartData(data);
for (Column column : previewData.getColumns()) {
for (SubcolumnValue value : column.getValues()) {
value.setColor(ChartUtils.DEFAULT_DARKEN_COLOR);
}
}
}
示例2: populateMeeting
import lecho.lib.hellocharts.model.SubcolumnValue; //导入方法依赖的package包/类
public static void populateMeeting(Context context, ColumnChartView chart, @NonNull Cursor cursor) {
List<AxisValue> xAxisValues = new ArrayList<>();
List<Column> columns = new ArrayList<>();
MeetingMemberCursorWrapper cursorWrapper = new MeetingMemberCursorWrapper(cursor);
int maxLabelLength = 0;
while (cursorWrapper.moveToNext()) {
List<SubcolumnValue> subcolumnValues = new ArrayList<>();
Column column = new Column(subcolumnValues);
Long memberId = cursorWrapper.getMemberId();
String memberName = cursorWrapper.getMemberName();
float durationInMinutes = (float) cursorWrapper.getDuration() / 60;
String durationLabel = DateUtils.formatElapsedTime(cursorWrapper.getDuration());
SubcolumnValue subcolumnValue = new SubcolumnValue();
subcolumnValue.setValue(durationInMinutes);
subcolumnValue.setLabel(durationLabel);
int color = ChartUtils.getMemberColor(context, memberId);
subcolumnValue.setColor(color);
subcolumnValues.add(subcolumnValue);
column.setHasLabels(true);
column.setValues(subcolumnValues);
columns.add(column);
AxisValue xAxisValue = new AxisValue(xAxisValues.size());
xAxisValue.setLabel(memberName);
xAxisValues.add(xAxisValue);
if (memberName.length() > maxLabelLength) maxLabelLength = memberName.length();
}
cursor.moveToPosition(-1);
Axis xAxis = new Axis(xAxisValues);
xAxis.setAutoGenerated(false);
//xAxis.setMaxLabelChars(maxLabelLength);
xAxis.setTextColor(ResourcesCompat.getColor(context.getResources(), R.color.chart_text, null));
xAxis.setHasTiltedLabels(true);
ColumnChartData data = new ColumnChartData();
data.setAxisXBottom(xAxis);
data.setColumns(columns);
chart.setInteractive(true);
chart.setColumnChartData(data);
chart.setZoomEnabled(true);
chart.setZoomType(ZoomType.HORIZONTAL);
}