本文整理汇总了Java中lecho.lib.hellocharts.model.ColumnChartData类的典型用法代码示例。如果您正苦于以下问题:Java ColumnChartData类的具体用法?Java ColumnChartData怎么用?Java ColumnChartData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColumnChartData类属于lecho.lib.hellocharts.model包,在下文中一共展示了ColumnChartData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateMaxViewportForStacked
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
private void calculateMaxViewportForStacked(ColumnChartData data) {
for (Column column : data.getColumns()) {
float sumPositive = baseValue;
float sumNegative = baseValue;
for (SubcolumnValue columnValue : column.getValues()) {
if (columnValue.getValue() >= baseValue) {
sumPositive += columnValue.getValue();
} else {
sumNegative += columnValue.getValue();
}
}
if (sumPositive > tempMaximumViewport.top) {
tempMaximumViewport.top = sumPositive;
}
if (sumNegative < tempMaximumViewport.bottom) {
tempMaximumViewport.bottom = sumNegative;
}
}
}
示例2: generateDefaultData
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的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);
}
}
}
示例3: generateColumnChartData
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
private ColumnChartData generateColumnChartData() {
int numSubcolumns = 1;
int numColumns = 12;
// Column can have many subcolumns, here by default I use 1 subcolumn in each of 8 columns.
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));
}
ColumnChartData data = new ColumnChartData(columns);
data.setAxisXBottom(new Axis().setName("Axis X"));
data.setAxisYLeft(new Axis().setName("Axis Y").setHasLines(true));
return data;
}
示例4: generateColumnData
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
private ColumnChartData generateColumnData() {
int numSubcolumns = 1;
int numColumns = 12;
// Column can have many subcolumns, here by default I use 1 subcolumn in each of 8 columns.
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() * 50 + 5, ChartUtils.COLOR_GREEN));
}
columns.add(new Column(values));
}
ColumnChartData columnChartData = new ColumnChartData(columns);
return columnChartData;
}
示例5: removeMargins
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
public void removeMargins() {
Rect contentRect = this.computator.getContentRectMinusAllMargins();
if (contentRect.height() != 0 && contentRect.width() != 0) {
float pxX = this.computator.computeRawDistanceX(this.maxRadius * this.bubbleScaleX);
float pxY = this.computator.computeRawDistanceY(this.maxRadius * this.bubbleScaleY);
float scaleX = this.computator.getMaximumViewport().width() / ((float) contentRect.width());
float scaleY = this.computator.getMaximumViewport().height() / ((float) contentRect.height());
float dx = 0.0f;
float dy = 0.0f;
if (this.isBubbleScaledByX) {
dy = ((pxY - pxX) * scaleY) * ColumnChartData.DEFAULT_FILL_RATIO;
} else {
dx = ((pxX - pxY) * scaleX) * ColumnChartData.DEFAULT_FILL_RATIO;
}
Viewport maxViewport = this.computator.getMaximumViewport();
maxViewport.inset(dx, dy);
Viewport currentViewport = this.computator.getCurrentViewport();
currentViewport.inset(dx, dy);
this.computator.setMaxViewport(maxViewport);
this.computator.setCurrentViewport(currentViewport);
}
}
示例6: calculateMaxViewportForStacked
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
private void calculateMaxViewportForStacked(ColumnChartData data) {
for (Column column : data.getColumns()) {
float sumPositive = this.baseValue;
float sumNegative = this.baseValue;
for (SubcolumnValue columnValue : column.getValues()) {
if (columnValue.getValue() >= this.baseValue) {
sumPositive += columnValue.getValue();
} else {
sumNegative += columnValue.getValue();
}
}
if (sumPositive > this.tempMaximumViewport.top) {
this.tempMaximumViewport.top = sumPositive;
}
if (sumNegative < this.tempMaximumViewport.bottom) {
this.tempMaximumViewport.bottom = sumNegative;
}
}
}
示例7: setupChart
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
private static void setupChart(Context context, ColumnChartView chart, List<AxisValue> xAxisValues, String yAxisLabel, List<Column> columns) {
Axis xAxis = new Axis(xAxisValues);
ChartUtils.setupXAxis(context, xAxis);
Axis yAxis = new Axis();
ChartUtils.setupYAxis(context, yAxisLabel, yAxis);
ColumnChartData data = new ColumnChartData();
data.setAxisXBottom(xAxis);
data.setAxisYLeft(yAxis);
data.setColumns(columns);
data.setStacked(true);
chart.setInteractive(true);
chart.setColumnChartData(data);
chart.setValueSelectionEnabled(true);
chart.setZoomEnabled(true);
chart.setZoomType(ZoomType.HORIZONTAL);
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics displayMetrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(displayMetrics);
float numberVisibleColumns = displayMetrics.widthPixels / context.getResources().getDimension(R.dimen.column_chart_column_width);
float zoomLevel = columns.size() / numberVisibleColumns;
if (zoomLevel > 0) {
chart.setZoomLevel(chart.getMaximumViewport().right - 1, 0.0f, zoomLevel);
}
}
示例8: setColumnChartData
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
@Override
public void setColumnChartData(ColumnChartData data) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "Setting data for ColumnChartView");
}
if (null == data) {
this.data = ColumnChartData.generateDummyData();
} else {
this.data = data;
}
super.onChartDataChange();
}
示例9: PreviewColumnChartView
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
public PreviewColumnChartView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
chartComputator = new PreviewChartComputator();
previewChartRenderer = new PreviewColumnChartRenderer(context, this, this);
touchHandler = new PreviewChartTouchHandler(context, this);
setChartRenderer(previewChartRenderer);
setColumnChartData(ColumnChartData.generateDummyData());
}
示例10: onChartDataChanged
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
@Override
public void onChartDataChanged() {
super.onChartDataChanged();
ColumnChartData data = dataProvider.getColumnChartData();
fillRatio = data.getFillRatio();
baseValue = data.getBaseValue();
onChartViewportChanged();
}
示例11: draw
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
public void draw(Canvas canvas) {
final ColumnChartData data = dataProvider.getColumnChartData();
if (data.isStacked()) {
drawColumnForStacked(canvas);
if (isTouched()) {
highlightColumnForStacked(canvas);
}
} else {
drawColumnsForSubcolumns(canvas);
if (isTouched()) {
highlightColumnsForSubcolumns(canvas);
}
}
}
示例12: checkTouch
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
public boolean checkTouch(float touchX, float touchY) {
selectedValue.clear();
final ColumnChartData data = dataProvider.getColumnChartData();
if (data.isStacked()) {
checkTouchForStacked(touchX, touchY);
} else {
checkTouchForSubcolumns(touchX, touchY);
}
return isTouched();
}
示例13: calculateMaxViewport
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
private void calculateMaxViewport() {
final ColumnChartData data = dataProvider.getColumnChartData();
// Column chart always has X values from 0 to numColumns-1, to add some margin on the left and right I added
// extra 0.5 to the each side, that margins will be negative scaled according to number of columns, so for more
// columns there will be less margin.
tempMaximumViewport.set(-0.5f, baseValue, data.getColumns().size() - 0.5f, baseValue);
if (data.isStacked()) {
calculateMaxViewportForStacked(data);
} else {
calculateMaxViewportForSubcolumns(data);
}
}
示例14: calculateMaxViewportForSubcolumns
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
private void calculateMaxViewportForSubcolumns(ColumnChartData data) {
for (Column column : data.getColumns()) {
for (SubcolumnValue columnValue : column.getValues()) {
if (columnValue.getValue() >= baseValue && columnValue.getValue() > tempMaximumViewport.top) {
tempMaximumViewport.top = columnValue.getValue();
}
if (columnValue.getValue() < baseValue && columnValue.getValue() < tempMaximumViewport.bottom) {
tempMaximumViewport.bottom = columnValue.getValue();
}
}
}
}
示例15: drawColumnsForSubcolumns
import lecho.lib.hellocharts.model.ColumnChartData; //导入依赖的package包/类
private void drawColumnsForSubcolumns(Canvas canvas) {
final ColumnChartData data = dataProvider.getColumnChartData();
final float columnWidth = calculateColumnWidth();
int columnIndex = 0;
for (Column column : data.getColumns()) {
processColumnForSubcolumns(canvas, column, columnWidth, columnIndex, MODE_DRAW);
++columnIndex;
}
}