本文整理汇总了Java中lecho.lib.hellocharts.model.LineChartData类的典型用法代码示例。如果您正苦于以下问题:Java LineChartData类的具体用法?Java LineChartData怎么用?Java LineChartData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LineChartData类属于lecho.lib.hellocharts.model包,在下文中一共展示了LineChartData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateLineData
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
private LineChartData generateLineData() {
List<Line> lines = new ArrayList<Line>();
for (int i = 0; i < numberOfLines; ++i) {
List<PointValue> values = new ArrayList<PointValue>();
for (int j = 0; j < numberOfPoints; ++j) {
values.add(new PointValue(j, randomNumbersTab[i][j]));
}
Line line = new Line(values);
line.setColor(ChartUtils.COLORS[i]);
line.setCubic(isCubic);
line.setHasLabels(hasLabels);
line.setHasLines(hasLines);
line.setHasPoints(hasPoints);
lines.add(line);
}
LineChartData lineChartData = new LineChartData(lines);
return lineChartData;
}
示例2: checkTouch
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
@Override
public boolean checkTouch(float touchX, float touchY) {
selectedValue.clear();
final LineChartData data = dataProvider.getLineChartData();
int lineIndex = 0;
for (Line line : data.getLines()) {
if (checkIfShouldDrawPoints(line)) {
int pointRadius = ChartUtils.dp2px(density, line.getPointRadius());
int valueIndex = 0;
for (PointValue pointValue : line.getValues()) {
final float rawValueX = computator.computeRawX(pointValue.getX());
final float rawValueY = computator.computeRawY(pointValue.getY());
if (isInArea(rawValueX, rawValueY, touchX, touchY, pointRadius + touchToleranceMargin)) {
selectedValue.set(lineIndex, valueIndex, SelectedValueType.LINE);
}
++valueIndex;
}
}
++lineIndex;
}
return isTouched();
}
示例3: calculateMaxViewport
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
private void calculateMaxViewport() {
tempMaximumViewport.set(Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MAX_VALUE);
LineChartData data = dataProvider.getLineChartData();
for (Line line : data.getLines()) {
// Calculate max and min for viewport.
for (PointValue pointValue : line.getValues()) {
if (pointValue.getX() < tempMaximumViewport.left) {
tempMaximumViewport.left = pointValue.getX();
}
if (pointValue.getX() > tempMaximumViewport.right) {
tempMaximumViewport.right = pointValue.getX();
}
if (pointValue.getY() < tempMaximumViewport.bottom) {
tempMaximumViewport.bottom = pointValue.getY();
}
if (pointValue.getY() > tempMaximumViewport.top) {
tempMaximumViewport.top = pointValue.getY();
}
}
}
}
示例4: generateLineChartData
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
private LineChartData generateLineChartData() {
int numValues = 20;
List<PointValue> values = new ArrayList<PointValue>();
for (int i = 0; i < numValues; ++i) {
values.add(new PointValue(i, (float) Math.random() * 100f));
}
Line line = new Line(values);
line.setColor(ChartUtils.COLOR_GREEN);
List<Line> lines = new ArrayList<Line>();
lines.add(line);
LineChartData data = new LineChartData(lines);
data.setAxisXBottom(new Axis().setName("Axis X"));
data.setAxisYLeft(new Axis().setName("Axis Y").setHasLines(true));
return data;
}
示例5: generatePreviewLineChartData
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
private LineChartData generatePreviewLineChartData() {
int numValues = 50;
List<PointValue> values = new ArrayList<PointValue>();
for (int i = 0; i < numValues; ++i) {
values.add(new PointValue(i, (float) Math.random() * 100f));
}
Line line = new Line(values);
line.setColor(ChartUtils.DEFAULT_DARKEN_COLOR);
line.setHasPoints(false);// too many values so don't draw points.
List<Line> lines = new ArrayList<Line>();
lines.add(line);
LineChartData data = new LineChartData(lines);
data.setAxisXBottom(new Axis());
data.setAxisYLeft(new Axis().setHasLines(true));
return data;
}
示例6: generateDefaultData
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
private void generateDefaultData() {
int numValues = 50;
List<PointValue> values = new ArrayList<PointValue>();
for (int i = 0; i < numValues; ++i) {
values.add(new PointValue(i, (float) Math.random() * 100f));
}
Line line = new Line(values);
line.setColor(ChartUtils.COLOR_GREEN);
line.setHasPoints(false);// too many values so don't draw points.
List<Line> lines = new ArrayList<Line>();
lines.add(line);
data = new LineChartData(lines);
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 LineChartData(data);
previewData.getLines().get(0).setColor(ChartUtils.DEFAULT_DARKEN_COLOR);
}
示例7: loadInBackground
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
/**
* This is where the bulk of our work is done. This function is
* called in a background thread and should generate a new set of
* data to be published by the loader.
*/
@Override
public Map<String, Object> loadInBackground() {
List<FillUp> fillUps = fillUpService.findFillUpsOfVehicleWithComputedConsumption(vehicleId, getContext());
if (fillUps.isEmpty()) {
return null;
}
Map<String, Object> result = new HashMap<>(3);
LineChartData lineChartData = generateLineChartData(fillUps);
LineChartData previewChartData = generatePreviewChartData(lineChartData);
result.put(FILL_UPS, fillUps);
result.put(CHART_DATA, lineChartData);
result.put(PREVIEW_DATA, previewChartData);
return result;
}
示例8: loadInBackground
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
/**
* This is where the bulk of our work is done. This function is
* called in a background thread and should generate a new set of
* data to be published by the loader.
*/
@Override
public Map<String, Object> loadInBackground() {
List<FillUp> fillUps = FillUpService.findFillUpsOfVehicle(vehicleId, getContext());
if (fillUps.isEmpty()) {
return null;
}
Map<String, Object> result = new HashMap<>(2);
LineChartData lineChartData = generateLineChartData(fillUps);
LineChartData previewChartData = generatePreviewChartData(lineChartData);
result.put(FILL_UPS, fillUps);
result.put(CHART_DATA, lineChartData);
result.put(PREVIEW_DATA, previewChartData);
return result;
}
示例9: setUpChartLine
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
private void setUpChartLine() {
List<PointValue> chartPoints = getChartPoints();
List<AxisValue> chartAxisPoints = getChartAxisPoints();
Line chartLine = new Line(chartPoints)
.setColor(getResources().getColor(R.color.background_primary_dark))
.setCubic(true)
.setHasPoints(false);
LineChartData chartData = new LineChartData()
.setLines(Collections.singletonList(chartLine));
chartData.setAxisXBottom(new Axis()
.setValues(chartAxisPoints));
chartData.setAxisYLeft(new Axis()
.setHasLines(true));
chart.setLineChartData(chartData);
}
示例10: setUpChartLine
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
private void setUpChartLine() {
List<PointValue> chartPoints = getChartPoints();
List<AxisValue> chartAxisPoints = getChartAxisPoints();
Line chartLine = new Line(chartPoints)
.setColor(getResources().getColor(R.color.background_primary_dark))
.setCubic(true)
.setHasPoints(false);
LineChartData chartData = new LineChartData()
.setLines(Collections.singletonList(chartLine));
chartData.setAxisXBottom(new Axis()
.setValues(chartAxisPoints));
chartData.setAxisYLeft(new Axis()
.setHasLines(true));
chart.setLineChartData(chartData);
}
示例11: onPostExecute
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
@Override
protected void onPostExecute(ArrayList<LineChartData> result) {
//Write some code you want to execute on UI after doInBackground() completes
bgChartLoading.setVisibility(View.GONE);
//bgChart.setVisibility(View.VISIBLE);
bgChart.setLineChartData(result.get(0));
bgPreviewChart.setLineChartData(result.get(1));
updateStuff = true;
//refreshes data and sets viewpoint
bgChart.setZoomType(ZoomType.HORIZONTAL);
bgPreviewChart.setZoomType(ZoomType.HORIZONTAL);
bgPreviewChart.setViewportCalculationEnabled(true);
bgChart.setViewportCalculationEnabled(true);
bgPreviewChart.setViewportChangeListener(new ViewportListener());
bgChart.setViewportChangeListener(new ChartViewPortListener());
setViewport();
Log.d(TAG, "bgGraph Updated");
}
示例12: populateMeetingDurationChart
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
public static void populateMeetingDurationChart(Context context, LineChartView chart, @NonNull Cursor cursor) {
List<PointValue> points = new ArrayList<>();
List<AxisValue> xAxisValues = new ArrayList<>();
MeetingCursorWrapper cursorWrapper = new MeetingCursorWrapper(cursor);
while (cursorWrapper.moveToNext()) {
Meeting meeting = Meeting.read(context, cursorWrapper);
points.add(getMeetingDurationPointValue(meeting));
xAxisValues.add(getMeetingDurationXAxisValue(context, meeting));
}
cursor.moveToPosition(-1);
int lineColor = ResourcesCompat.getColor(context.getResources(), R.color.scrum_chatter_primary_color, null);
Line line = new Line(points);
line.setColor(lineColor);
List<Line> lines = new ArrayList<>();
lines.add(line);
LineChartData lineChartData = new LineChartData();
lineChartData.setLines(lines);
setupChart(context,
chart,
xAxisValues,
context.getString(R.string.chart_duration),
lines);
}
示例13: setLineChartData
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
@Override
public void setLineChartData(LineChartData data) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "Setting data for LineChartView");
}
if (null == data) {
this.data = LineChartData.generateDummyData();
} else {
this.data = data;
}
super.onChartDataChange();
}
示例14: PreviewLineChartView
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
public PreviewLineChartView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
chartComputator = new PreviewChartComputator();
previewChartRenderer = new PreviewLineChartRenderer(context, this, this);
touchHandler = new PreviewChartTouchHandler(context, this);
setChartRenderer(previewChartRenderer);
setLineChartData(LineChartData.generateDummyData());
}
示例15: drawUnclipped
import lecho.lib.hellocharts.model.LineChartData; //导入依赖的package包/类
@Override
public void drawUnclipped(Canvas canvas) {
final LineChartData data = dataProvider.getLineChartData();
int lineIndex = 0;
for (Line line : data.getLines()) {
if (checkIfShouldDrawPoints(line)) {
drawPoints(canvas, line, lineIndex, MODE_DRAW);
}
++lineIndex;
}
if (isTouched()) {
// Redraw touched point to bring it to the front
highlightPoints(canvas);
}
}