本文整理汇总了Java中com.jjoe64.graphview.LineGraphView类的典型用法代码示例。如果您正苦于以下问题:Java LineGraphView类的具体用法?Java LineGraphView怎么用?Java LineGraphView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LineGraphView类属于com.jjoe64.graphview包,在下文中一共展示了LineGraphView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSampleCode
import com.jjoe64.graphview.LineGraphView; //导入依赖的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: SensorAdapter
import com.jjoe64.graphview.LineGraphView; //导入依赖的package包/类
public SensorAdapter(final Context context, final View view) {
mContext = context.getApplicationContext();
mLoadingView = view;
final Resources res = context.getResources();
final int bgColor = ContextCompat.getColor(mContext, R.color.primary_graph);
mGraph = new LineGraphView(context, "");
mGraph.setDrawBackground(true);
mGraph.setBackgroundColor(bgColor);
mGraph.setCustomLabelFormatter(new CustomLabelFormatter() {
@Override
public String formatLabel(final double value, final boolean isValueX) {
if (isValueX) {
return DateUtils.formatDateTime(mContext,
(long) value, AppConstants.DATE_FORMAT_FLAGS_GRAPH);
}
return String.format(Locale.getDefault(), "%.1f", value);
}
});
mGraph.getGraphViewStyle().setTextSize(res.getDimension(R.dimen.graph_text_size));
}
示例3: initGraph
import com.jjoe64.graphview.LineGraphView; //导入依赖的package包/类
@AfterViews
void initGraph() {
if (mScoreResponse != null) {
final TreeMap<Long, Double> scoreArray = mScoreResponse.getScoreArray();
final double width = scoreArray.lastKey() - scoreArray.firstKey();
final GraphView graphView = new LineGraphView(getActivity(), getString(R.string.chart_title));
GraphViewData[] data = new GraphViewData[scoreArray.size()];
int i = 0;
for (Map.Entry<Long, Double> entry : scoreArray.entrySet()) {
data[i] = new GraphViewData(entry.getKey(), entry.getValue());
i++;
}
final GraphViewSeriesStyle graphViewSeriesStyle = new GraphViewSeriesStyle(Color.WHITE, 4);
graphView.addSeries(new GraphViewSeries("Score", graphViewSeriesStyle, data));
graphView.setViewPort(0, width);
graphView.setScalable(true);
graphView.setScrollable(true);
graphContainer.addView(graphView);
}
}
示例4: onActivityCreated
import com.jjoe64.graphview.LineGraphView; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
displaymetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay()
.getMetrics(displaymetrics);
height = displaymetrics.heightPixels;
width = displaymetrics.widthPixels;
exampleSeries = new GraphViewSeries(
new GraphViewData[] { new GraphViewData(.0d, .0d) });
graphView = new LineGraphView(getActivity(), getString(R.string.empty));
graphView.addSeries(exampleSeries);
graphView.setLimit(limitDecibels);
graphView.setViewPort(0, 150);
graphView.setManualYAxisBounds(150, 0);
graphView.setScalable(true);
graphView.getGraphViewStyle().setHorizontalLabelsColor(
getResources().getColor(R.color.blue_bar));
graphView.getGraphViewStyle().setHorizontalLabelsColor(
getResources().getColor(android.R.color.transparent));
graphView.getGraphViewStyle().setVerticalLabelsColor(Color.BLACK);
graphLayout.addView(graphView);
isListen = false;
buttonClicked();
super.onActivityCreated(savedInstanceState);
}
示例5: loadGraphView
import com.jjoe64.graphview.LineGraphView; //导入依赖的package包/类
private void loadGraphView() {
this.getGraphContainer().setVisibility(View.GONE);
this.graphView = new LineGraphView(this, "");
this.graphView.setCustomLabelFormatter(GraphHelper.getLabelFormatter(GRAPH_DAYS));
this.graphView.setShowLegend(true);
if (GRAPH_DAYS <= 5) {
this.graphView.getGraphViewStyle().setNumHorizontalLabels(GRAPH_DAYS);
}
ViewGroup graph = (ViewGroup) this.getGraphContainer().findViewById(R.id.viewGroupHeaderGraph);
graph.addView(graphView);
}
示例6: Plot
import com.jjoe64.graphview.LineGraphView; //导入依赖的package包/类
/**
* Constructor. Initialize the variables.
* @param graph_type Is the type of graph to represent
* @param name Is the name given to the graph
*/
public Plot(GraphType graph_type, Context myContext, String name) {
super();
if (graph_type == GraphType.BAR)
this.myGraphView = new BarGraphView(myContext, name);
else
this.myGraphView = new LineGraphView(myContext, name);
hashSeries = new Hashtable<String, GraphViewSeries>();
hashCont = new Hashtable<String, Integer>();
numMax = 0;
}
示例7: drawGraph
import com.jjoe64.graphview.LineGraphView; //导入依赖的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: setupInnerViewElements
import com.jjoe64.graphview.LineGraphView; //导入依赖的package包/类
@Override
public void setupInnerViewElements(ViewGroup parent, View view) {
mGraphView = new LineGraphView(getContext(), mTitle);
mGraphView.addSeries(mStatus.getGraphViewSeries());
mGraphView.setManualYAxisBounds(1.0f, 0.0f);
mGraphView.setViewPort(0.0f, 200.0f);
mGraphView.setScrollable(true);
mGraphView.setDisableTouch(true);
mGraphView.getGraphViewStyle().setNumHorizontalLabels(1);
LinearLayout graphLayout = (LinearLayout) view.findViewById(
R.id.card_status_graph);
if (graphLayout != null) {
graphLayout.addView(mGraphView);
}
}
示例9: initGraphView
import com.jjoe64.graphview.LineGraphView; //导入依赖的package包/类
private void initGraphView() {
graphView = new LineGraphView(activity, "");
graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.BLACK);
graphView.getGraphViewStyle().setVerticalLabelsColor(Color.BLACK);
graphView.getGraphViewStyle().setGridColor(Color.GRAY);
graphView.getGraphViewStyle().setTextSize(textSize);
graphView.getGraphViewStyle().setNumHorizontalLabels(
Constants.HORIZONTAL_LABELS_COUNT);
graphView.getGraphViewStyle().setNumVerticalLabels(
Constants.VERTICAL_LABELS_COUNT);
graphView.getGraphViewStyle().setVerticalLabelsWidth(
verticalLabelsWidth);
}
示例10: initUi
import com.jjoe64.graphview.LineGraphView; //导入依赖的package包/类
/**
* Init UI contols
*/
private void initUi(final View view) {
tvCellDescription = (TextView) view.findViewById(R.id.stats_cell_description);
tvCellStrength = (TextView) view.findViewById(R.id.stats_cell_strength);
tvWifiDescription = (TextView) view.findViewById(R.id.stats_wifi_description);
tvWifiStrength = (TextView) view.findViewById(R.id.stats_wifi_strength);
tvIgnored = (TextView) view.findViewById(R.id.stats_blacklisted);
tvFree = (TextView) view.findViewById(R.id.stats_free);
ivFree = (ImageView) view.findViewById(R.id.stats_icon_free);
ivAlert = (ImageView) view.findViewById(R.id.stats_icon_alert);
tbNa = (ToggleButton) view.findViewById(R.id.tbN_a);
tbGsm = (ToggleButton) view.findViewById(R.id.tbGsm);
tbEdge = (ToggleButton) view.findViewById(R.id.tbEdge);
tbUmts = (ToggleButton) view.findViewById(R.id.tbUmts);
tbCdma = (ToggleButton) view.findViewById(R.id.tbCdma);
tbEvdo0 = (ToggleButton) view.findViewById(R.id.tbEvdo0);
tbEvdoA = (ToggleButton) view.findViewById(R.id.tbEvdoA);
tbEvdoB = (ToggleButton) view.findViewById(R.id.tbEvdoB);
tbOneXRtt = (ToggleButton) view.findViewById(R.id.tbOneXRtt);
tbHsdpa = (ToggleButton) view.findViewById(R.id.tbHsdpa);
tbHsupa = (ToggleButton) view.findViewById(R.id.tbHsupa);
tbHspa = (ToggleButton) view.findViewById(R.id.tbHspa);
tbIden = (ToggleButton) view.findViewById(R.id.tbIden);
tbLte = (ToggleButton) view.findViewById(R.id.tbLte);
tbEhrpd = (ToggleButton) view.findViewById(R.id.tbEhrpd);
tbHspa_p = (ToggleButton) view.findViewById(R.id.tbHspa_p);
graphView = new LineGraphView(this.getActivity().getBaseContext() // context
, "Cell strength (dBm)");
graphView.setManualYAxisBounds(-50, -100);
graphView.getGraphViewStyle().setNumVerticalLabels(3);
graphView.setHorizontalLabels(new String[] {""});
graphView.setViewPort(2, 60000);
graphView.setScrollable(true);
final LinearLayout layout = (LinearLayout) view.findViewById(R.id.graph2);
layout.addView(graphView);
}
示例11: createGraph
import com.jjoe64.graphview.LineGraphView; //导入依赖的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;
}
示例12: sampleMultipleSeries
import com.jjoe64.graphview.LineGraphView; //导入依赖的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);
}
示例13: HeaderViewHolder
import com.jjoe64.graphview.LineGraphView; //导入依赖的package包/类
public HeaderViewHolder(final View v, final LineGraphView lgv) {
super(v);
final FrameLayout frameLayout = v.findViewById(R.id.graph_placeholder);
frameLayout.addView(lgv);
}
示例14: onCreateView
import com.jjoe64.graphview.LineGraphView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_dashboard, container, false);
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
NUM_SAMPLES = Integer.parseInt(sharedPreferences.getString(SettingsFragment.KEY_PREF_INTERVAL, "300"));
String[] horizontalLabels;
switch (NUM_SAMPLES) {
case 60:
horizontalLabels = new String[]{"1min", "45sec", "30sec", "15sec", "0min"};
Log.i(TAG, "Number of samples: 60");
break;
case 120:
horizontalLabels = new String[]{"2min", "1min", "0min"};
Log.i(TAG, "Number of samples: 120");
break;
case 300:
horizontalLabels = new String[]{"5min", "4min", "3min", "2min", "1min", "0min"};
Log.i(TAG, "Number of samples: 300");
break;
case 600:
horizontalLabels = new String[]{"10min", "8min", "6min", "4min", "2min", "0min"};
Log.i(TAG, "Number of samples: 600");
break;
case 1200:
horizontalLabels = new String[]{"20min", "15min", "10min", "5min", "0min"};
Log.i(TAG, "Number of samples: 1200");
break;
default:
horizontalLabels = new String[]{"5min", "4min", "3min", "2min", "1min", "0min"};
Log.i(TAG, "Number of samples: 300");
}
LinearLayout windSpeedContainer = (LinearLayout) view.findViewById(R.id.windSpeedContainer);
LinearLayout temperatureContainer = (LinearLayout) view.findViewById(R.id.temperatureContainer);
graphViewStyle = new GraphViewStyle(Color.BLACK, Color.BLACK, Color.GRAY);
graphViewStyle.setVerticalLabelsAlign(Paint.Align.LEFT);
graphViewStyle.setVerticalLabelsWidth(80);
windSpeedGraph = new LineGraphView(getActivity().getApplicationContext(), "Wind Speed");
windSpeedGraph.setScrollable(true);
// windSpeedGraph.setScalable(true);
windSpeedGraph.setViewPort(0, NUM_SAMPLES);
windSpeedGraph.setGraphViewStyle(graphViewStyle);
windSpeedGraph.setHorizontalLabels(horizontalLabels);
temperatureGraph = new LineGraphView(getActivity().getApplicationContext(), "Temperature");
temperatureGraph.setScrollable(true);
// temperatureGraph.setScalable(true);
temperatureGraph.setViewPort(0, NUM_SAMPLES);
temperatureGraph.setGraphViewStyle(graphViewStyle);
temperatureGraph.setHorizontalLabels(horizontalLabels);
temperatureGraph.setShowHorizontalLabels(false);
windSpeedData = new GraphViewData[1];
temperatureData = new GraphViewData[1];
windSpeedData[0] = new GraphViewData(0, 0);
temperatureData[0] = new GraphViewData(0, 0);
windSpeedSeries = new GraphViewSeries("Wind Speed", new GraphViewSeries.GraphViewSeriesStyle(Color.BLUE, 7), windSpeedData);
temperatureSeries = new GraphViewSeries("Temperature", new GraphViewSeries.GraphViewSeriesStyle(Color.RED, 7), temperatureData);
windSpeedGraph.addSeries(windSpeedSeries);
temperatureGraph.addSeries(temperatureSeries);
windSpeedContainer.addView(windSpeedGraph);
temperatureContainer.addView(temperatureGraph);
return view;
}
示例15: onCreateView
import com.jjoe64.graphview.LineGraphView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.game_sensor, container, false);
mOrientXValue = (TextView) rootView.findViewById(R.id.orient_x_value);
mOrientYValue = (TextView) rootView.findViewById(R.id.orient_y_value);
mOrientZValue = (TextView) rootView.findViewById(R.id.orient_z_value);
mLayoutGraph1 = (LinearLayout) rootView.findViewById(R.id.graph1);
mLayoutGraph2 = (LinearLayout) rootView.findViewById(R.id.graph2);
mGraphViewSeries1 = new GraphViewSeries(new
GraphViewData[] {
new GraphViewData(mValueX, 1.0f)
});
mGraphViewSeries2 = new GraphViewSeries(new
GraphViewData[] {
new GraphViewData(mValueX, 1.0f)
});
mGraph1 = new LineGraphView(getActivity(), "");
mGraph1.addSeries(mGraphViewSeries1);
mGraph1.setManualYAxisBounds(1.0f, 0.0f);
mGraph1.setViewPort(0.0f, 200.0f);
mGraph1.setScrollable(true);
mGraph1.setDisableTouch(true);
mGraph1.getGraphViewStyle().setNumHorizontalLabels(1);
mLayoutGraph1.addView(mGraph1);
mGraph2 = new LineGraphView(getActivity(), "");
mGraph2.addSeries(mGraphViewSeries2);
mGraph2.setManualYAxisBounds(1.0f, 0.0f);
mGraph2.setViewPort(0.0f, 200.0f);
mGraph2.setScrollable(true);
mGraph2.setDisableTouch(true);
mGraph2.getGraphViewStyle().setNumHorizontalLabels(1);
mLayoutGraph2.addView(mGraph2);
return rootView;
}