private void generateColumnData() { int numSubcolumns = 1; int numColumns = months.length; List<AxisValue> axisValues = new ArrayList<AxisValue>(); List<Column> columns = new ArrayList<Column>(); List<SubcolumnValue> values; for (int i = 0; i < numColumns; ++i) { values = new ArrayList<SubcolumnValue>(); for (int j = 0; j < numSubcolumns; ++j) { values.add(new SubcolumnValue((float) Math.random() * 50f + 5, ChartUtils.pickColor())); } axisValues.add(new AxisValue(i).setLabel(months[i])); columns.add(new Column(values).setHasLabelsOnlyForSelected(true)); } columnData = new ColumnChartData(columns); columnData.setAxisXBottom(new Axis(axisValues).setHasLines(true)); columnData.setAxisYLeft(new Axis().setHasLines(true).setMaxLabelChars(2)); chartBottom.setColumnChartData(columnData); // Set value touch listener that will trigger changes for chartTop. chartBottom.setOnValueTouchListener(new ValueTouchListener()); // Set selection mode to keep selected month column highlighted. chartBottom.setValueSelectionEnabled(true); chartBottom.setZoomType(ZoomType.HORIZONTAL); // chartBottom.setOnClickListener(new View.OnClickListener() { // // @Override // public void onClick(View v) { // SelectedValue sv = chartBottom.getSelectedValue(); // if (!sv.isSet()) { // generateInitialLineData(); // } // // } // }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.chart_waterfall); chart = (ColumnChartView) findViewById(R.id.chart); chart.setOnValueTouchListener(new ValueTouchListener()); generateStackedData(70, 95); MyTopBar topBar = (MyTopBar) findViewById(R.id.topbar_chartwater); topBar.setOnTopBarClickListener( new MyTopBar.TopBarClickListener() { @Override public void leftclick() { Chart_waterfall.this.finish(); } @Override public void rightclick() {} }); }