Search in sources :

Example 1 with GraphViewStyle

use of com.jjoe64.graphview.GraphViewStyle in project WordPress-Android by wordpress-mobile.

the class StatsBarGraph method setProperties.

private void setProperties() {
    GraphViewStyle gStyle = getGraphViewStyle();
    gStyle.setHorizontalLabelsIndexDependentColor(new HorizontalLabelsColor());
    gStyle.setHorizontalLabelsColor(getResources().getColor(R.color.grey_darken_30));
    gStyle.setVerticalLabelsColor(getResources().getColor(R.color.grey_darken_10));
    gStyle.setTextSize(getResources().getDimensionPixelSize(R.dimen.text_sz_extra_small));
    gStyle.setGridXColor(Color.TRANSPARENT);
    gStyle.setGridYColor(getResources().getColor(R.color.grey_lighten_30));
    gStyle.setNumVerticalLabels(3);
    setCustomLabelFormatter(new CustomLabelFormatter() {

        private NumberFormat numberFormatter;

        @Override
        public String formatLabel(double value, boolean isValueX) {
            if (isValueX) {
                return null;
            }
            if (numberFormatter == null) {
                numberFormatter = NumberFormat.getNumberInstance();
                numberFormatter.setMaximumFractionDigits(0);
            }
            return numberFormatter.format(value);
        }
    });
}
Also used : GraphViewStyle(com.jjoe64.graphview.GraphViewStyle) CustomLabelFormatter(com.jjoe64.graphview.CustomLabelFormatter) NumberFormat(java.text.NumberFormat)

Example 2 with GraphViewStyle

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

the class GraphViewFragment method getGraphViewStyle.

private GraphViewStyle getGraphViewStyle() {
    GraphViewStyle graphViewStyle = new GraphViewStyle(Color.BLACK, Color.BLACK, Color.GRAY);
    graphViewStyle.setVerticalLabelsAlign(Paint.Align.LEFT);
    graphViewStyle.setVerticalLabelsWidth(80);
    return graphViewStyle;
}
Also used : GraphViewStyle(com.jjoe64.graphview.GraphViewStyle)

Example 3 with GraphViewStyle

use of com.jjoe64.graphview.GraphViewStyle 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)

Aggregations

GraphViewStyle (com.jjoe64.graphview.GraphViewStyle)3 View (android.view.View)1 LinearLayout (android.widget.LinearLayout)1 CustomLabelFormatter (com.jjoe64.graphview.CustomLabelFormatter)1 GraphViewData (com.jjoe64.graphview.GraphView.GraphViewData)1 GraphViewSeries (com.jjoe64.graphview.GraphViewSeries)1 LineGraphView (com.jjoe64.graphview.LineGraphView)1 NumberFormat (java.text.NumberFormat)1