Search in sources :

Example 1 with LineGraphView

use of com.jjoe64.graphview.LineGraphView in project Weather-Station by Kresshy.

the class GraphViewFragment method createViewForWindSpeedGraph.

private void createViewForWindSpeedGraph(LinearLayout container) {
    Timber.d("Creating GraphView For WindSpeed");
    windSpeedGraph = new LineGraphView(getActivity().getApplicationContext(), "Wind Speed");
    windSpeedGraph.setScrollable(true);
    // windSpeedGraph.setScalable(true);
    windSpeedGraph.setViewPort(0, numberOfSamples);
    windSpeedGraph.setGraphViewStyle(getGraphViewStyle());
    windSpeedGraph.setHorizontalLabels(getHorizontalLabelsForGraph(numberOfSamples));
    GraphViewData[] windSpeedData = new GraphViewData[1];
    windSpeedData[0] = new GraphViewData(0, 0);
    windSpeedDataList.add(windSpeedData);
    GraphViewSeries windSpeedSeries = new GraphViewSeries("Wind Speed", new GraphViewSeries.GraphViewSeriesStyle(Color.BLUE, getLineWidthByNode(0)), windSpeedData);
    windSpeedSeriesList.add(windSpeedSeries);
    windSpeedGraph.addSeries(windSpeedSeries);
    Timber.d("Adding GraphView For WindSpeed to LayoutContainer");
    container.addView(windSpeedGraph);
}
Also used : LineGraphView(com.jjoe64.graphview.LineGraphView) GraphViewData(com.jjoe64.graphview.GraphView.GraphViewData) GraphViewSeries(com.jjoe64.graphview.GraphViewSeries)

Example 2 with LineGraphView

use of com.jjoe64.graphview.LineGraphView in project Weather-Station by Kresshy.

the class GraphViewFragment method createViewForTemperatureGraph.

private void createViewForTemperatureGraph(LinearLayout container) {
    Timber.d("Creating GraphView For Temperature");
    temperatureGraph = new LineGraphView(getActivity().getApplicationContext(), "Temperature");
    temperatureGraph.setScrollable(true);
    // temperatureGraph.setScalable(true);
    temperatureGraph.setViewPort(0, numberOfSamples);
    temperatureGraph.setGraphViewStyle(getGraphViewStyle());
    temperatureGraph.setHorizontalLabels(getHorizontalLabelsForGraph(numberOfSamples));
    temperatureGraph.setShowHorizontalLabels(false);
    GraphViewData[] temperatureData = new GraphViewData[1];
    temperatureData[0] = new GraphViewData(0, 0);
    temperatureDataList.add(temperatureData);
    GraphViewSeries temperatureSeries = new GraphViewSeries("Temperature", new GraphViewSeries.GraphViewSeriesStyle(Color.RED, getLineWidthByNode(0)), temperatureData);
    temperatureSeriesList.add(temperatureSeries);
    temperatureGraph.addSeries(temperatureSeries);
    Timber.d("Adding GraphView For Temperature to LayoutContainer");
    container.addView(temperatureGraph);
}
Also used : LineGraphView(com.jjoe64.graphview.LineGraphView) GraphViewData(com.jjoe64.graphview.GraphView.GraphViewData) GraphViewSeries(com.jjoe64.graphview.GraphViewSeries)

Example 3 with LineGraphView

use of com.jjoe64.graphview.LineGraphView in project Weather-Station by Kresshy.

the class DashboardFragment method onCreateView.

@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" };
            Timber.d("Number of samples: 60");
            break;
        case 120:
            horizontalLabels = new String[] { "2min", "1min", "0min" };
            Timber.d("Number of samples: 120");
            break;
        case 300:
            horizontalLabels = new String[] { "5min", "4min", "3min", "2min", "1min", "0min" };
            Timber.d("Number of samples: 300");
            break;
        case 600:
            horizontalLabels = new String[] { "10min", "8min", "6min", "4min", "2min", "0min" };
            Timber.d("Number of samples: 600");
            break;
        case 1200:
            horizontalLabels = new String[] { "20min", "15min", "10min", "5min", "0min" };
            Timber.d("Number of samples: 1200");
            break;
        default:
            horizontalLabels = new String[] { "5min", "4min", "3min", "2min", "1min", "0min" };
            Timber.d("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;
}
Also used : LineGraphView(com.jjoe64.graphview.LineGraphView) GraphViewStyle(com.jjoe64.graphview.GraphViewStyle) LineGraphView(com.jjoe64.graphview.LineGraphView) View(android.view.View) LinearLayout(android.widget.LinearLayout) GraphViewData(com.jjoe64.graphview.GraphView.GraphViewData) GraphViewSeries(com.jjoe64.graphview.GraphViewSeries)

Example 4 with LineGraphView

use of com.jjoe64.graphview.LineGraphView in project netxms by netxms.

the class DrawGraph method onCreateStep2.

/* (non-Javadoc)
	 * @see org.netxms.ui.android.main.activities.AbstractClientActivity#onCreateStep2(android.os.Bundle)
	 */
@Override
protected void onCreateStep2(Bundle savedInstanceState) {
    sp = PreferenceManager.getDefaultSharedPreferences(this);
    dialog = new ProgressDialog(this);
    setContentView(R.layout.graphics);
    // boolean showLegend = getIntent().getBooleanExtra("showLegend", true);
    numGraphs = getIntent().getIntExtra("numGraphs", 0);
    if (numGraphs > 0) {
        items = new GraphItem[numGraphs];
        itemStyles = new GraphItemStyle[numGraphs];
        ArrayList<Integer> nodeIdList = getIntent().getIntegerArrayListExtra("nodeIdList");
        ArrayList<Integer> dciIdList = getIntent().getIntegerArrayListExtra("dciIdList");
        ArrayList<Integer> colorList = getIntent().getIntegerArrayListExtra("colorList");
        ArrayList<Integer> lineWidthList = getIntent().getIntegerArrayListExtra("lineWidthList");
        ArrayList<String> nameList = getIntent().getStringArrayListExtra("nameList");
        for (int i = 0; i < numGraphs; i++) {
            items[i] = new GraphItem();
            items[i].setNodeId(nodeIdList.get(i));
            items[i].setDciId(dciIdList.get(i));
            items[i].setDescription(nameList.get(i));
            itemStyles[i] = new GraphItemStyle();
            itemStyles[i].setColor(colorList.get(i) | 0xFF000000);
            itemStyles[i].setLineWidth(lineWidthList.get(i));
        }
        timeFrom = getIntent().getLongExtra("timeFrom", 0);
        timeTo = getIntent().getLongExtra("timeTo", 0);
        graphTitle = getIntent().getStringExtra("graphTitle");
    }
    graphView = new LineGraphView(this, "");
    graphView.getGraphViewStyle().setVerticalLabelsColor(Color.WHITE);
    graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.WHITE);
    graphView.getGraphViewStyle().setTextSize(Integer.parseInt(sp.getString("global.graph.textsize", "10")));
    graphView.getGraphViewStyle().setLegendWidth(240);
    graphView.setCustomLabelFormatter(new CustomLabel(Integer.parseInt(sp.getString("global.multipliers", "1")), (timeTo - timeFrom) > 86400 * 1000));
    // TOOD: 2014May25 Find a best way to handle this setting
    // graphView.setShowLegend(showLegend);
    graphView.setShowLegend(sp.getBoolean("global.graph.legend", true));
    graphView.setLegendAlign(LegendAlign.TOP);
    graphView.setScalable(true);
    graphView.setScrollable(true);
    TextView title = (TextView) findViewById(R.id.ScreenTitlePrimary);
    title.setText(R.string.graph_title);
}
Also used : LineGraphView(com.jjoe64.graphview.LineGraphView) CustomLabel(org.netxms.ui.android.helpers.CustomLabel) GraphItem(org.netxms.client.datacollection.GraphItem) GraphItemStyle(org.netxms.client.datacollection.GraphItemStyle) TextView(android.widget.TextView) ProgressDialog(android.app.ProgressDialog)

Aggregations

LineGraphView (com.jjoe64.graphview.LineGraphView)4 GraphViewData (com.jjoe64.graphview.GraphView.GraphViewData)3 GraphViewSeries (com.jjoe64.graphview.GraphViewSeries)3 ProgressDialog (android.app.ProgressDialog)1 View (android.view.View)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 GraphViewStyle (com.jjoe64.graphview.GraphViewStyle)1 GraphItem (org.netxms.client.datacollection.GraphItem)1 GraphItemStyle (org.netxms.client.datacollection.GraphItemStyle)1 CustomLabel (org.netxms.ui.android.helpers.CustomLabel)1