Search in sources :

Example 1 with XYMultipleSeriesRenderer

use of org.achartengine.renderer.XYMultipleSeriesRenderer in project AndrOBD by fr3ts0n.

the class ChartActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    // keep main display on?
    if (MainActivity.prefs.getBoolean("keep_screen_on", false)) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
    // prevent activity from falling asleep
    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getString(R.string.app_name));
    wakeLock.acquire();
    // set up action bar
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(true);
    }
    setTitle(R.string.chart);
    /* get PIDs to be shown */
    int[] positions = getIntent().getIntArrayExtra(POSITIONS);
    // set up overall chart properties
    sensorData = new XYMultipleSeriesDataset();
    renderer = new XYMultipleSeriesRenderer(positions.length);
    chartView = ChartFactory.getTimeChartView(this, sensorData, renderer, "H:mm:ss");
    // set up global renderer
    renderer.setXTitle(getString(R.string.time));
    renderer.setXLabels(5);
    renderer.setYLabels(5);
    renderer.setGridColor(Color.DKGRAY);
    renderer.setShowGrid(true);
    renderer.setFitLegend(true);
    renderer.setClickEnabled(false);
    // set up chart data
    setUpChartData(positions);
    // make chart visible
    setContentView(chartView);
    // limit selected PIDs to selection
    MainActivity.setFixedPids(pidNumbers);
    // if auto hiding selected ...
    if (MainActivity.prefs.getBoolean(MainActivity.PREF_AUTOHIDE, false)) {
        // get autohide timeout [s]
        int timeout = Integer.valueOf(MainActivity.prefs.getString(MainActivity.PREF_AUTOHIDE_DELAY, "15"));
        // auto hide toolbar
        toolBarHider = new AutoHider(this, mHandler, MainActivity.MESSAGE_TOOLBAR_VISIBLE, timeout * 1000);
        toolBarHider.start(1000);
        // wake up on touch
        chartView.setOnTouchListener(toolBarHider);
    }
}
Also used : PowerManager(android.os.PowerManager) XYMultipleSeriesRenderer(org.achartengine.renderer.XYMultipleSeriesRenderer) XYMultipleSeriesDataset(org.achartengine.model.XYMultipleSeriesDataset) ActionBar(android.app.ActionBar)

Example 2 with XYMultipleSeriesRenderer

use of org.achartengine.renderer.XYMultipleSeriesRenderer in project netxms by netxms.

the class BarChartElement method buildRenderer.

/**
 * @return
 */
private XYMultipleSeriesRenderer buildRenderer() {
    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
    renderer.setAxisTitleTextSize(16);
    renderer.setChartTitleTextSize(20);
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);
    renderer.setFitLegend(true);
    renderer.setShowLegend(config.isShowLegend());
    renderer.setChartTitle(config.getTitle());
    renderer.setBarSpacing(0.4f);
    renderer.setShowGrid(false);
    renderer.setPanEnabled(false, false);
    renderer.setZoomEnabled(false, false);
    renderer.setAntialiasing(true);
    renderer.setApplyBackgroundColor(true);
    renderer.setMarginsColor(Colors.BACKGROUND_COLOR);
    renderer.setBackgroundColor(Colors.BACKGROUND_COLOR);
    renderer.setAxesColor(Colors.LABEL_COLOR);
    renderer.setGridColor(Colors.GRID_COLOR);
    renderer.setLabelsColor(Colors.LABEL_COLOR);
    renderer.setXLabelsColor(Colors.LABEL_COLOR);
    renderer.setYLabelsColor(0, Colors.LABEL_COLOR);
    ChartDciConfig[] items = config.getDciList();
    for (int i = 0; i < items.length && i < Colors.DEFAULT_ITEM_COLORS.length; i++) {
        XYSeriesRenderer r = new XYSeriesRenderer();
        int color = items[i].getColorAsInt();
        if (color == -1)
            color = Colors.DEFAULT_ITEM_COLORS[i];
        else
            color = swapRGB(color);
        r.setColor(color | 0xFF000000);
        renderer.addSeriesRenderer(r);
    // r.setDisplayChartValues(false);
    }
    renderer.setXAxisMin(0.5);
    renderer.setXAxisMax(items.length + 0.5);
    renderer.setXLabelsColor(Colors.BACKGROUND_COLOR);
    renderer.setYLabelsAlign(Align.RIGHT);
    return renderer;
}
Also used : XYMultipleSeriesRenderer(org.achartengine.renderer.XYMultipleSeriesRenderer) ChartDciConfig(org.netxms.ui.android.main.activities.helpers.ChartDciConfig) XYSeriesRenderer(org.achartengine.renderer.XYSeriesRenderer)

Example 3 with XYMultipleSeriesRenderer

use of org.achartengine.renderer.XYMultipleSeriesRenderer in project Anki-Android by Ramblurr.

the class StudyOptionsFragment method updateChart.

private void updateChart(double[][] serieslist) {
    if (mSmallChart != null) {
        Resources res = getResources();
        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
        XYSeriesRenderer r = new XYSeriesRenderer();
        r.setColor(res.getColor(R.color.stats_young));
        renderer.addSeriesRenderer(r);
        r = new XYSeriesRenderer();
        r.setColor(res.getColor(R.color.stats_mature));
        renderer.addSeriesRenderer(r);
        for (int i = 1; i < serieslist.length; i++) {
            XYSeries series = new XYSeries("");
            for (int j = 0; j < serieslist[i].length; j++) {
                series.add(serieslist[0][j], serieslist[i][j]);
            }
            dataset.addSeries(series);
        }
        renderer.setBarSpacing(0.4);
        renderer.setShowLegend(false);
        renderer.setLabelsTextSize(13);
        renderer.setXAxisMin(-0.5);
        renderer.setXAxisMax(7.5);
        renderer.setYAxisMin(0);
        renderer.setGridColor(Color.LTGRAY);
        renderer.setShowGrid(true);
        renderer.setBackgroundColor(Color.WHITE);
        renderer.setMarginsColor(Color.WHITE);
        renderer.setAxesColor(Color.BLACK);
        renderer.setLabelsColor(Color.BLACK);
        renderer.setYLabelsColor(0, Color.BLACK);
        renderer.setYLabelsAngle(-90);
        renderer.setXLabelsColor(Color.BLACK);
        renderer.setXLabelsAlign(Align.CENTER);
        renderer.setYLabelsAlign(Align.CENTER);
        renderer.setZoomEnabled(false, false);
        // mRenderer.setMargins(new int[] { 15, 48, 30, 10 });
        renderer.setAntialiasing(true);
        renderer.setPanEnabled(true, false);
        GraphicalView chartView = ChartFactory.getBarChartView(getActivity(), dataset, renderer, BarChart.Type.STACKED);
        mSmallChart.addView(chartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        if (mDeckChart.getVisibility() == View.INVISIBLE) {
            mDeckChart.setVisibility(View.VISIBLE);
            mDeckChart.setAnimation(ViewAnimation.fade(ViewAnimation.FADE_IN, 500, 0));
        }
    }
}
Also used : XYSeries(org.achartengine.model.XYSeries) XYMultipleSeriesRenderer(org.achartengine.renderer.XYMultipleSeriesRenderer) LayoutParams(android.view.ViewGroup.LayoutParams) GraphicalView(org.achartengine.GraphicalView) XYSeriesRenderer(org.achartengine.renderer.XYSeriesRenderer) Resources(android.content.res.Resources) XYMultipleSeriesDataset(org.achartengine.model.XYMultipleSeriesDataset)

Example 4 with XYMultipleSeriesRenderer

use of org.achartengine.renderer.XYMultipleSeriesRenderer in project netxms by netxms.

the class DrawBarChart method buildRenderer.

/**
 * @return
 */
private XYMultipleSeriesRenderer buildRenderer() {
    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
    renderer.setAxisTitleTextSize(16);
    renderer.setChartTitleTextSize(20);
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);
    renderer.setFitLegend(true);
    renderer.setBarSpacing(0.4f);
    renderer.setShowGrid(true);
    renderer.setPanEnabled(false);
    renderer.setZoomEnabled(false);
    for (int color : colorList) {
        XYSeriesRenderer r = new XYSeriesRenderer();
        r.setColor(color | 0xFF000000);
        renderer.addSeriesRenderer(r);
        r.setDisplayChartValues(false);
    }
    renderer.setXAxisMin(0.5);
    renderer.setXAxisMax(items.length + 0.5);
    renderer.setXLabels(1);
    renderer.setYLabelsAlign(Align.RIGHT);
    renderer.clearXTextLabels();
    for (int i = 0; i < items.length; i++) renderer.addXTextLabel(i + 1, items[i].getDescription());
    return renderer;
}
Also used : XYMultipleSeriesRenderer(org.achartengine.renderer.XYMultipleSeriesRenderer) XYSeriesRenderer(org.achartengine.renderer.XYSeriesRenderer)

Example 5 with XYMultipleSeriesRenderer

use of org.achartengine.renderer.XYMultipleSeriesRenderer in project netxms by netxms.

the class TableBarChartElement method buildRenderer.

/**
 * @return
 */
private XYMultipleSeriesRenderer buildRenderer() {
    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
    renderer.setAxisTitleTextSize(16);
    renderer.setChartTitleTextSize(20);
    renderer.setChartTitle(config.getTitle());
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);
    renderer.setFitLegend(true);
    renderer.setShowLegend(config.isShowLegend());
    renderer.setBarSpacing(0.4f);
    renderer.setShowGrid(false);
    renderer.setPanEnabled(false, false);
    renderer.setZoomEnabled(false, false);
    renderer.setAntialiasing(true);
    renderer.setApplyBackgroundColor(true);
    renderer.setMarginsColor(Colors.BACKGROUND_COLOR);
    renderer.setBackgroundColor(Colors.BACKGROUND_COLOR);
    renderer.setAxesColor(Colors.LABEL_COLOR);
    renderer.setGridColor(Colors.GRID_COLOR);
    renderer.setLabelsColor(Colors.LABEL_COLOR);
    renderer.setXLabelsColor(Colors.LABEL_COLOR);
    renderer.setYLabelsColor(0, Colors.LABEL_COLOR);
    for (int i = 0; i < Colors.DEFAULT_ITEM_COLORS.length; i++) {
        XYSeriesRenderer r = new XYSeriesRenderer();
        r.setColor(Colors.DEFAULT_ITEM_COLORS[i] | 0xFF000000);
        renderer.addSeriesRenderer(r);
        r.setDisplayChartValues(false);
    }
    renderer.setXAxisMin(0.5);
    renderer.setXAxisMax(1.5);
    renderer.setXLabels(1);
    renderer.setYLabelsAlign(Align.RIGHT);
    renderer.clearXTextLabels();
    return renderer;
}
Also used : XYMultipleSeriesRenderer(org.achartengine.renderer.XYMultipleSeriesRenderer) XYSeriesRenderer(org.achartengine.renderer.XYSeriesRenderer)

Aggregations

XYMultipleSeriesRenderer (org.achartengine.renderer.XYMultipleSeriesRenderer)5 XYSeriesRenderer (org.achartengine.renderer.XYSeriesRenderer)4 XYMultipleSeriesDataset (org.achartengine.model.XYMultipleSeriesDataset)2 ActionBar (android.app.ActionBar)1 Resources (android.content.res.Resources)1 PowerManager (android.os.PowerManager)1 LayoutParams (android.view.ViewGroup.LayoutParams)1 GraphicalView (org.achartengine.GraphicalView)1 XYSeries (org.achartengine.model.XYSeries)1 ChartDciConfig (org.netxms.ui.android.main.activities.helpers.ChartDciConfig)1