本文整理匯總了Java中com.jjoe64.graphview.GraphView.GraphViewData方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphView.GraphViewData方法的具體用法?Java GraphView.GraphViewData怎麽用?Java GraphView.GraphViewData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jjoe64.graphview.GraphView
的用法示例。
在下文中一共展示了GraphView.GraphViewData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSampleCode
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
private void getSampleCode() {
GraphViewSeries exampleSeries = new GraphViewSeries(new GraphView.GraphViewData[] {
new GraphView.GraphViewData(1, 2.0d)
, new GraphView.GraphViewData(2, 1.5d)
, new GraphView.GraphViewData(3, 2.5d)
, new GraphView.GraphViewData(4, 1.0d)
});
GraphView graphView = new LineGraphView(this, "GraphViewDemo");
graphView.addSeries(exampleSeries);
GraphView barGraphView = new BarGraphView(this, "BarGraphView");
barGraphView.addSeries(exampleSeries);
LinearLayout layout = (LinearLayout) findViewById(R.id.linear_layout);
layout.addView(barGraphView);
}
示例2: updateTrafficOnDate
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
private ArrayList<GraphView.GraphViewData> updateTrafficOnDate(String date,
int type) {
// initialize database
Log.e(TAG, "date=" + date + " type:" + type);
this.transformationDB = new LocalTransformationDBMS(getActivity()
.getApplicationContext());
transformationDB.open();
ArrayList<TrafficData> list = transformationDB.getAllTrafficFromDate(
date, type);
ArrayList<GraphView.GraphViewData> data = new ArrayList<GraphView.GraphViewData>();
for (TrafficData t : list) {
GraphViewData x = new GraphViewData(t.getxValue(), t.getyValue());
data.add(x);
}
transformationDB.close();
return data;
}
示例3: updateTrafficOnDate
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
private ArrayList<GraphView.GraphViewData> updateTrafficOnDate(String date,
int type) {
// initialize database
Log.e(TAG, "date=" + date + " type:" + type);
this.transformationDB = new LocalTransformationDBMS(
this.getApplicationContext());
transformationDB.open();
ArrayList<TrafficData> list = transformationDB.getAllTrafficFromDate(
date, type);
ArrayList<GraphView.GraphViewData> data = new ArrayList<GraphView.GraphViewData>();
for (TrafficData t : list) {
GraphViewData x = new GraphViewData(t.getxValue(), t.getyValue());
data.add(x);
}
transformationDB.close();
return data;
}
示例4: clearChart
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
private void clearChart(String title) {
GraphViewData[] dataList = new GraphViewData[1];
dataList[0] = new GraphViewData(0.0, 0.0);
GraphViewSeries gvs_series = new GraphViewSeries(dataList);
if (title.equals(firstGrpTitle)) {
createGraph(firstGrpTitle, gvs_series, R.id.light_graph, isFirstBar, 0);
data_line = new ArrayList<GraphView.GraphViewData>();
}
if (title.equals(secondGrpTitle)) {
createGraph(secondGrpTitle, gvs_series, R.id.motion_graph, isSecondBar, 0);
data_bar = new ArrayList<GraphView.GraphViewData>();
}
}
示例5: getDurationGraphViewData
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
public GraphViewDataInterface[] getDurationGraphViewData() {
synchronized (lock) {
int size = size();
final GraphViewDataInterface[] data = new GraphViewDataInterface[size];
for (int i = 0; i < size; ++i) {
Surge surge = get((size - i) - 1);
long time = surge.getStart().getTime();
double duration = surge.getDurationSeconds();
data[i] = new GraphView.GraphViewData(time, duration);
}
return data;
}
}
示例6: getFrequencyGraphViewData
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
public GraphViewDataInterface[] getFrequencyGraphViewData() {
synchronized (lock) {
int size = size();
final GraphViewDataInterface[] data = new GraphViewDataInterface[size];
for (int i = 0; i < size; ++i) {
Surge surge = get((size - i) - 1);
long time = surge.getStart().getTime();
double frequency = -surge.getSecondsSincePrevious();
data[i] = new GraphView.GraphViewData(time, frequency);
}
return data;
}
}
示例7: drawGraph
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
private void drawGraph(final Journey journey) {
final LineGraphView graph = new LineGraphView(getActivity(), "");
List<GraphView.GraphViewData> data = new ArrayList<>();
for (Elevation elevation : journey.elevation().profile())
data.add(new GraphView.GraphViewData(elevation.distance(), elevation.elevation()));
GraphViewSeries graphSeries = new GraphViewSeries(data.toArray(new GraphView.GraphViewData[]{}));
graph.addSeries(graphSeries);
graph.setDrawBackground(true);
graph.getGraphViewStyle().setGridStyle(GraphViewStyle.GridStyle.HORIZONTAL);
graph.getGraphViewStyle().setNumHorizontalLabels(5);
graph.getGraphViewStyle().setNumVerticalLabels(4);
final ElevationFormatter formatter = ElevationFormatter.formatter(CycleStreetsPreferences.units());
graph.setCustomLabelFormatter(new CustomLabelFormatter() {
@Override
public String formatLabel(double value, boolean isValueX) {
if (isValueX)
return (value != 0) ? formatter.distance((int)value) : "";
return formatter.height((int) value);
}
});
graphHolder_.removeAllViews();
graphHolder_.addView(graph);
}
示例8: GameStatus
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
public GameStatus(String title) {
mTitle = title;
mGraphViewSeries = new GraphViewSeries(new
GraphView.GraphViewData[] {
new GraphView.GraphViewData(mValueX++, 1.0f)
});
}
示例9: clearChart
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
private void clearChart(String title) {
GraphViewData[] dataList = new GraphViewData[1];
dataList[0] = new GraphViewData(0.0, 0.0);
GraphViewSeries gvs_series = new GraphViewSeries(dataList);
if (title.equals(firstGrpTitle)) {
createGraph(firstGrpTitle, gvs_series, R.id.light_graph, isFirstBar);
data_line = new ArrayList<GraphView.GraphViewData>();
}
if (title.equals(secondGrpTitle)) {
createGraph(secondGrpTitle, gvs_series, R.id.motion_graph, isSecondBar);
data_bar = new ArrayList<GraphView.GraphViewData>();
}
}
示例10: updateGraphView
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
public void updateGraphView() {
short[] audioData = new short[mMinBufferSize];
while (isRecording) {
int read = mAudioRecord.read(audioData, 0, mMinBufferSize);
if (read != AudioRecord.ERROR_INVALID_OPERATION && read != AudioRecord.ERROR_BAD_VALUE) {
int num = audioData.length;
final GraphView.GraphViewData[] data = new GraphView.GraphViewData[num];
if (isBarGraph) {
// apply Fast Fourier Transform here
transformer = new RealDoubleFFT(num);
double[] toTransform = new double[num];
for (int i = 0; i < num; i++) {
toTransform[i] = (double) audioData[i] / Short.MAX_VALUE;
}
transformer.ft(toTransform);
for (int i = 0; i < num; i++) {
data[i] = new GraphView.GraphViewData(i, toTransform[i]);
}
} else {
for (int i = 0; i < num; i++) {
data[i] = new GraphView.GraphViewData(i, audioData[i]);
}
}
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
mGraphSeries.resetData(data);
}
});
}
}
}
示例11: updateUI
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
private void updateUI() {
final VisitModel[] dataToShowOnGraph = getDataToShowOnGraph();
if (dataToShowOnGraph == null || dataToShowOnGraph.length == 0) {
setupEmptyUI(false);
return;
}
final String[] horLabels = new String[dataToShowOnGraph.length];
String[] mStatsDate = new String[dataToShowOnGraph.length];
GraphView.GraphViewData[] views = new GraphView.GraphViewData[dataToShowOnGraph.length];
for (int i = 0; i < dataToShowOnGraph.length; i++) {
int currentItemValue = dataToShowOnGraph[i].getViews();
views[i] = new GraphView.GraphViewData(i, currentItemValue);
String currentItemStatsDate = dataToShowOnGraph[i].getPeriod();
horLabels[i] = StatsUtils.parseDate(
currentItemStatsDate,
StatsConstants.STATS_INPUT_DATE_FORMAT,
StatsConstants.STATS_OUTPUT_DATE_MONTH_SHORT_DAY_SHORT_FORMAT
);
mStatsDate[i] = currentItemStatsDate;
}
GraphViewSeries mCurrentSeriesOnScreen = new GraphViewSeries(views);
mCurrentSeriesOnScreen.getStyle().color = getResources().getColor(R.color.stats_bar_graph_main_series);
mCurrentSeriesOnScreen.getStyle().highlightColor = getResources().getColor(R.color.stats_bar_graph_main_series_highlight);
mCurrentSeriesOnScreen.getStyle().outerhighlightColor = getResources().getColor(R.color.stats_bar_graph_outer_highlight);
mCurrentSeriesOnScreen.getStyle().padding = DisplayUtils.dpToPx(this, 5);
StatsBarGraph mGraphView;
if (mGraphContainer.getChildCount() >= 1 && mGraphContainer.getChildAt(0) instanceof GraphView) {
mGraphView = (StatsBarGraph) mGraphContainer.getChildAt(0);
} else {
mGraphContainer.removeAllViews();
mGraphView = new StatsBarGraph(this);
mGraphContainer.addView(mGraphView);
}
mGraphView.removeAllSeries();
mGraphView.addSeries(mCurrentSeriesOnScreen);
//mGraphView.getGraphViewStyle().setNumHorizontalLabels(getNumOfHorizontalLabels(dataToShowOnGraph.length));
mGraphView.getGraphViewStyle().setNumHorizontalLabels(dataToShowOnGraph.length);
mGraphView.getGraphViewStyle().setMaxColumnWidth(
DisplayUtils.dpToPx(this, StatsConstants.STATS_GRAPH_BAR_MAX_COLUMN_WIDTH_DP)
);
mGraphView.setHorizontalLabels(horLabels);
mGraphView.setGestureListener(this);
mSelectedBarGraphIndex = (mSelectedBarGraphIndex != -1) ? mSelectedBarGraphIndex : dataToShowOnGraph.length - 1;
mGraphView.highlightBar(mSelectedBarGraphIndex);
setMainViewsLabel(
StatsUtils.parseDate(
mStatsDate[mSelectedBarGraphIndex],
StatsConstants.STATS_INPUT_DATE_FORMAT,
StatsConstants.STATS_OUTPUT_DATE_MONTH_LONG_DAY_SHORT_FORMAT
),
dataToShowOnGraph[mSelectedBarGraphIndex].getViews()
);
showHideEmptyModulesIndicator(false);
mMonthsAndYearsList.setVisibility(View.VISIBLE);
List<PostViewsModel.Year> years = mRestResponseParsed.getYears();
MonthsAndYearsListAdapter monthsAndYearsListAdapter = new MonthsAndYearsListAdapter(this, years, mRestResponseParsed.getHighestMonth());
StatsUIHelper.reloadGroupViews(this, monthsAndYearsListAdapter, mYearsIdToExpandedMap, mMonthsAndYearsList);
mAveragesList.setVisibility(View.VISIBLE);
List<PostViewsModel.Year> averages = mRestResponseParsed.getAverages();
MonthsAndYearsListAdapter averagesListAdapter = new MonthsAndYearsListAdapter(this, averages, mRestResponseParsed.getHighestDayAverage());
StatsUIHelper.reloadGroupViews(this, averagesListAdapter, mAveragesIdToExpandedMap, mAveragesList);
mRecentWeeksList.setVisibility(View.VISIBLE);
List<PostViewsModel.Week> recentWeeks = mRestResponseParsed.getWeeks();
RecentWeeksListAdapter recentWeeksListAdapter = new RecentWeeksListAdapter(this, recentWeeks, mRestResponseParsed.getHighestWeekAverage());
StatsUIHelper.reloadGroupViews(this, recentWeeksListAdapter, mRecentWeeksIdToExpandedMap, mRecentWeeksList);
}
示例12: createGraph
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
private GraphView createGraph(BenchmarkWrapper wrapper) {
Resources res = getResources();
int lineThicknessPx = (int) Math.ceil(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, res.getDisplayMetrics()));
GraphView.GraphViewData[] data = new GraphView.GraphViewData[wrapper.getStatInfo().getBenchmarkData().size()];
for (int j = 0; j < wrapper.getStatInfo().getBenchmarkData().size(); j++) {
data[j] = new GraphView.GraphViewData(j, wrapper.getStatInfo().getBenchmarkData().get(j));
}
LineGraphView graphView = new LineGraphView(getActivity(), "");
GraphViewSeries.GraphViewSeriesStyle seriesStyle = new GraphViewSeries.GraphViewSeriesStyle(res.getColor(R.color.graphBgGreen), lineThicknessPx);
if (wrapper.getStatInfo().getAsAvg().getMin() <= IBlur.MS_THRESHOLD_FOR_SMOOTH) {
graphView.addSeries(GraphUtil.getStraightLine(IBlur.MS_THRESHOLD_FOR_SMOOTH, wrapper.getStatInfo().getBenchmarkData().size() - 1, "16ms", new GraphViewSeries.GraphViewSeriesStyle(res.getColor(R.color.graphBgRed), lineThicknessPx)));
}
graphView.addSeries(GraphUtil.getStraightLine((int) wrapper.getStatInfo().getAsAvg().getAvg(), wrapper.getStatInfo().getBenchmarkData().size() - 1, "Avg", new GraphViewSeries.GraphViewSeriesStyle(res.getColor(R.color.graphBlue), lineThicknessPx)));
graphView.addSeries(new GraphViewSeries("Blur", seriesStyle, data));
graphView.setScrollable(true);
graphView.setScalable(true);
graphView.setManualYAxis(true);
graphView.getGraphViewStyle().setGridColor(res.getColor(R.color.transparent));
graphView.setCustomLabelFormatter(new CustomLabelFormatter() {
@Override
public String formatLabel(double value, boolean isValueX) {
if (!isValueX) {
return Math.round(value) + "ms";
} else {
return null;
}
}
});
graphView.setManualYAxisBounds(wrapper.getStatInfo().getAsAvg().getMax(), Math.max(0, wrapper.getStatInfo().getAsAvg().getMin() - 3l));
graphView.setDrawBackground(false);
graphView.setShowLegend(true);
graphView.getGraphViewStyle().setHorizontalLabelsColor(res.getColor(R.color.transparent));
graphView.getGraphViewStyle().setNumHorizontalLabels(0);
graphView.getGraphViewStyle().setVerticalLabelsColor(res.getColor(R.color.optionsTextColorDark));
graphView.getGraphViewStyle().setNumVerticalLabels(4);
graphView.getGraphViewStyle().setVerticalLabelsAlign(Paint.Align.CENTER);
graphView.getGraphViewStyle().setVerticalLabelsWidth((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, res.getDisplayMetrics()));
graphView.getGraphViewStyle().setTextSize((int) Math.ceil(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, res.getDisplayMetrics())));
return graphView;
}
示例13: getStraightLine
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
public static GraphViewSeries getStraightLine(int heightY, int maxX, String name, GraphViewSeries.GraphViewSeriesStyle seriesStyle) {
GraphView.GraphViewData[] data = new GraphView.GraphViewData[2];
data[0] = new GraphView.GraphViewData(0, heightY);
data[1] = new GraphView.GraphViewData(maxX, heightY);
return new GraphViewSeries(name, seriesStyle, data);
}
示例14: sampleMultipleSeries
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
private void sampleMultipleSeries() {
String[] months = {
"JAN", "FEB", "MAR", "APR", "MAY", "JUN",
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
};
int[] index = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int[] incomeA = {4000, 5500, 2300, 2100, 2500, 2900, 3200, 2400, 1800, 2100, 3500, 5900};
int[] incomeB = {3600, 4500, 3200, 3600, 2800, 1800, 2100, 2900, 2200, 2500, 4000, 3500};
int[] incomeC = {4300, 4000, 3000, 3200, 2400, 2500, 2600, 3400, 3900, 4500, 5000, 4500};
int num = 100;
GraphView.GraphViewData[] data = new GraphView.GraphViewData[index.length];
for (int i = 0; i < index.length; i++) {
data[i] = new GraphView.GraphViewData(i, incomeA[i]);
}
GraphViewSeries seriesA = new GraphViewSeries("Googla",
new GraphViewSeries.GraphViewSeriesStyle(Color.RED, 5), data);
data = new GraphView.GraphViewData[index.length];
for (int i = 0; i < index.length; i++) {
data[i] = new GraphView.GraphViewData(i, incomeB[i]);
}
GraphViewSeries seriesB = new GraphViewSeries("Microsa",
new GraphViewSeries.GraphViewSeriesStyle(Color.BLUE, 5), data);
data = new GraphView.GraphViewData[index.length];
for (int i = 0; i < index.length; i++) {
data[i] = new GraphView.GraphViewData(i, incomeC[i]);
}
GraphViewSeries seriesC = new GraphViewSeries("Appla",
new GraphViewSeries.GraphViewSeriesStyle(Color.GREEN, 5), data);
GraphView graphView = new LineGraphView(this, "Multiple Series");
graphView.addSeries(seriesA);
graphView.addSeries(seriesB);
graphView.addSeries(seriesC);
graphView.setShowLegend(true);
graphView.getGraphViewStyle().setLegendWidth(200);
LinearLayout layout = (LinearLayout) findViewById(R.id.linear_layout);
layout.addView(graphView);
graphView.setBackgroundColor(Color.WHITE);
}
示例15: getGraphViewSeries
import com.jjoe64.graphview.GraphView; //導入方法依賴的package包/類
private GraphViewSeries getGraphViewSeries() {
List<AnalyticsData> dataList = db.getAllAnalyticsData();
long[] monthlyAverages = new long[]{(long) 0, (long)0,(long)0,(long)0,(long)0};
int[] monthCount = new int[]{0,0,0,0,0};
for (AnalyticsData d : dataList) {
// Get monthly averages for last 5 months
if (Integer.valueOf(d.getDataType()) == AnalyticsData.WATER) {
// Get average values per month
System.out.println("substring is: "+d.getDate().substring(4, 7));
if (d.getDate().substring(4, 7).equals("Jan")) {
// add to sum
monthlyAverages[0] += Long.valueOf(d.getDuration());
// Increment month count
monthCount[0] += 1;
}
if (d.getDate().substring(4, 7).equals("Feb")) {
System.out.println("Inside Feb");
// add to sum
monthlyAverages[1] += Long.valueOf(d.getDuration());
// Increment month count
monthCount[1] += 1;
System.out.println("avg is: "+monthlyAverages[1]+" count is: "+monthCount[1]);
}
if (d.getDate().substring(4, 7).equals("Mar")) {
// add to sum
monthlyAverages[2] += Long.valueOf(d.getDuration());
// Increment month count
monthCount[2] += 1;
}
if (d.getDate().substring(4, 7).equals("Apr")) {
// add to sum
monthlyAverages[3] += Long.valueOf(d.getDuration());
// Increment month count
monthCount[3] += 1;
}
if (d.getDate().substring(4, 7).equals("May")) {
// add to sum
monthlyAverages[4] += Long.valueOf(d.getDuration());
// Increment month count
monthCount[4] += 1;
}
}
}
for (int i = 0; i < 5; i++) {
Long curSum = monthlyAverages[i]/1000;
int curCount = monthCount[i];
Long curAvg = (long)0;
if (curCount != 0) {
curAvg = curSum / curCount;
}
monthlyAverages[i] = curAvg;
if (curAvg < curMin) {
curMin = curAvg;
}
if (curAvg > curMax) {
if (i != 4) {
curMax = curAvg;
}
}
System.out.println("monthly Average is: "+i+" "+curAvg+" curCount: "+curCount+" curSum "+curSum);
}
// init example series data
GraphViewSeries exampleSeries = new GraphViewSeries(new GraphView.GraphViewData[] {
new GraphView.GraphViewData(1, monthlyAverages[0])
, new GraphView.GraphViewData(2, monthlyAverages[1])
, new GraphView.GraphViewData(3, monthlyAverages[2])
, new GraphView.GraphViewData(4, monthlyAverages[3])
, new GraphView.GraphViewData(5, (monthlyAverages[1]+monthlyAverages[2])/2)
});
return exampleSeries;
}