Skip to content

Instantly share code, notes, and snippets.

@lecho
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lecho/886bedb8c813e20e72e0 to your computer and use it in GitHub Desktop.
Save lecho/886bedb8c813e20e72e0 to your computer and use it in GitHub Desktop.
Column value pre-selection
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_line_column_dependency, container, false);
// *** TOP LINE CHART ***
chartTop = (LineChartView) rootView.findViewById(R.id.chart_top);
// Generate and set data for line chart
generateInitialLineData();
// *** BOTTOM COLUMN CHART ***
chartBottom = (ColumnChartView) rootView.findViewById(R.id.chart_bottom);
generateColumnData();
//When everything is prepared select value, when you try to select value when there is no data or you set invalid index probably IndexOutOfBoundsException will be thrown
//First index = column index starting from 0 so 2 means you are selecting 3th column
//Second index = sub column index, in sample project every column has only one sub-column so always pass 0
//Third parameter = used mostly for ComboCharts, for safty pass SelectedValueType.COLUMN for ColumChart or SelectedValueType.LINE for LineChart
//You can also call chart.selectValue() from other methods when app is running(i.e. some click listener etc.)
chartBottom.selectValue(new SelectedValue(2, 0, SelectedValue.SelectedValueType.COLUMN));
return rootView;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment