本文整理汇总了Java中com.github.mikephil.charting.data.BarDataSet.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java BarDataSet.setColor方法的具体用法?Java BarDataSet.setColor怎么用?Java BarDataSet.setColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.BarDataSet
的用法示例。
在下文中一共展示了BarDataSet.setColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* 柱形图数据
*/
private BarData generateBarData() {
BarData barData = new BarData();
ArrayList<BarEntry> entries1 = new ArrayList<>();
for (int index = 0; index < items.size(); index++) {
entries1.add(new BarEntry(index + 1f, (float) items.get(index).main_data.getData()));
}
BarDataSet barDataSet = new BarDataSet(entries1, "当前数据");
barDataSet.setValues(entries1);
barDataSet.setDrawValues(false);//是否在线上显示值
barDataSet.setColor(Color.rgb(230, 230, 230));
barDataSet.setHighLightColor(Color.parseColor(items.get(dateSelected).state.getColor()));
barDataSet.setValueTextColor(Color.rgb(60, 220, 78));
barDataSet.setValueTextSize(10f);
barDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
float barWidth = 0.45f;
barData.addDataSet(barDataSet);
barData.setBarWidth(barWidth);
return barData;
}
示例2: generateOrderBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData generateOrderBarData(List<MarketHistory> historyEntries) {
SimpleDateFormat format = new SimpleDateFormat("MMM dd", Locale.getDefault());
int size = historyEntries.size();
List<BarEntry> entries = new ArrayList<>(size);
List<String> xAxis = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
MarketHistory history = historyEntries.get(i);
Date recordDate = new Date(history.getRecordDate());
xAxis.add(format.format(recordDate));
entries.add(new BarEntry((float) history.getOrderCount(), i));
}
BarDataSet set = new BarDataSet(entries, "Order Count");
set.setColor(Color.parseColor("#99FF99"));
// set.setValueTextSize(0f);
set.setDrawValues(false);
set.setAxisDependency(YAxis.AxisDependency.RIGHT);
return new BarData(xAxis, set);
}
示例3: getDataSet
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private ArrayList<BarDataSet> getDataSet() {
ArrayList<BarDataSet> dataSets = null;
ArrayList<BarEntry> valueSet1 = new ArrayList<>();
BarEntry v1e1 = new BarEntry(110.000f, 0); // Jan
valueSet1.add(v1e1);
BarEntry v1e2 = new BarEntry(40.000f, 1); // Feb
valueSet1.add(v1e2);
BarEntry v1e3 = new BarEntry(60.000f, 2); // Mar
valueSet1.add(v1e3);
BarEntry v1e4 = new BarEntry(30.000f, 3); // Apr
valueSet1.add(v1e4);
BarEntry v1e5 = new BarEntry(90.000f, 4); // May
valueSet1.add(v1e5);
BarEntry v1e6 = new BarEntry(100.000f, 5); // Jun
valueSet1.add(v1e6);
BarDataSet barDataSet1 = new BarDataSet(valueSet1, "Reading Status");
barDataSet1.setColor(Color.rgb(255, 127, 80));
dataSets = new ArrayList<>();
dataSets.add(barDataSet1);
return dataSets;
}
示例4: initChart
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void initChart() {
ArrayList<BarDataSet> dataSets = new ArrayList<>();
// note that we show save first because that's how we initialize the DB
for (String frameworkName : chartEntrySets.keySet()) {
ArrayList<BarEntry> entrySet = chartEntrySets.get(frameworkName);
BarDataSet dataSet = new BarDataSet(entrySet, frameworkName);
dataSet.setColor(getFrameworkColor(frameworkName));
dataSets.add(dataSet);
}
// load data and animate it
ArrayList<String> xAxisLabels = new ArrayList<>();
xAxisLabels.add("Save (msec)");
xAxisLabels.add("Load (msec)");
BarData data = new BarData(xAxisLabels, dataSets);
chartView.setData(data);
chartView.setDescription(null); // this takes up too much space, so clear it
chartView.animateXY(2000, 2000);
chartView.invalidate();
}
示例5: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setData(double val) {
ArrayList<String> xVals = new ArrayList<String>();
xVals.add("");
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
yVals1.add(new BarEntry((float)val, 0));
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
//set1.setBarSpacePercent(35f);
//set1.setColor(Color.rgb(0, 153, 204));
int nc=getNEcatColors(val); // Choose the color category in function of the sound level
set1.setColor(NE_COLORS[nc]);
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
mChart.setData(data);
mChart.invalidate(); // refresh
}
示例6: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData generateBarData() {
ArrayList<BarEntry> entries1 = new ArrayList<BarEntry>();
ArrayList<BarEntry> entries2 = new ArrayList<BarEntry>();
for (int index = 0; index < itemcount; index++) {
entries1.add(new BarEntry(0, getRandom(25, 25)));
// stacked
entries2.add(new BarEntry(0, new float[]{getRandom(13, 12), getRandom(13, 12)}));
}
BarDataSet set1 = new BarDataSet(entries1, "Bar 1");
set1.setColor(Color.rgb(60, 220, 78));
set1.setValueTextColor(Color.rgb(60, 220, 78));
set1.setValueTextSize(10f);
set1.setAxisDependency(YAxis.AxisDependency.LEFT);
BarDataSet set2 = new BarDataSet(entries2, "");
set2.setStackLabels(new String[]{"Stack 1", "Stack 2"});
set2.setColors(new int[]{Color.rgb(61, 165, 255), Color.rgb(23, 197, 255)});
set2.setValueTextColor(Color.rgb(61, 165, 255));
set2.setValueTextSize(10f);
set2.setAxisDependency(YAxis.AxisDependency.LEFT);
float groupSpace = 0.06f;
float barSpace = 0.02f; // x2 dataset
float barWidth = 0.45f; // x2 dataset
// (0.45 + 0.02) * 2 + 0.06 = 1.00 -> interval per "group"
BarData d = new BarData(set1, set2);
d.setBarWidth(barWidth);
// make this BarData object grouped
d.groupBars(0, groupSpace, barSpace); // start at x = 0
return d;
}
示例7: onCreateView
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_historique_graph, container, false);
// Gestion de l'affichage graphique
rlGraphHistorique = (RelativeLayout) view.findViewById(R.id.rlGraphHistorique);
graphiqueHistorique = new BarChart(getContext());
final RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
rlGraphHistorique.addView(graphiqueHistorique,lp);
List<BarEntry> entries = getEntries(pointMesures);
BarDataSet dataSet = new BarDataSet(entries, "Graphique Historique");
//TODO : ne fonctionne pas avec le fichier de ressource colors
dataSet.setColor(R.color.barColorGraph);
dataSet.setValueTextColor(R.color.textColorGraph);
BarData lineData = new BarData(dataSet);
graphiqueHistorique.setData(lineData);
graphiqueHistorique.getLegend().setEnabled(false);
graphiqueHistorique.getDescription().setEnabled(false);
graphiqueHistorique.invalidate(); // refresh
return view;
}
示例8: TestCaseRunner
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
TestCaseRunner(int iterations, BarChart chart, String title, int color, IValueFormatter valueFormatter) {
mIterations = iterations;
mChart = chart;
mEntries = new LinkedList<>();
mDataSet = new BarDataSet(mEntries, title);
mDataSet.setValueFormatter(valueFormatter);
mDataSet.setColor(color);
}
示例9: showBarChart
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* 展示柱状图(多条)
*
* @param xAxisValues
* @param yAxisValues
* @param labels
* @param colours
*/
public void showBarChart(List<Float> xAxisValues, List<List<Float>> yAxisValues, List<String> labels, List<Integer> colours) {
initLineChart();
BarData data = new BarData();
for (int i = 0; i < yAxisValues.size(); i++) {
ArrayList<BarEntry> entries = new ArrayList<>();
for (int j = 0; j < yAxisValues.get(i).size(); j++) {
entries.add(new BarEntry(xAxisValues.get(j), yAxisValues.get(i).get(j)));
}
BarDataSet barDataSet = new BarDataSet(entries, labels.get(i));
barDataSet.setColor(colours.get(i));
barDataSet.setValueTextColor(colours.get(i));
barDataSet.setValueTextSize(10f);
barDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
data.addDataSet(barDataSet);
}
int amount = yAxisValues.size();
float groupSpace = 0.12f; //柱状图组之间的间距
float barSpace = (float) ((1 - 0.12) / amount / 10); // x4 DataSet
float barWidth = (float) ((1 - 0.12) / amount / 10 * 9); // x4 DataSet
// (0.2 + 0.02) * 4 + 0.08 = 1.00 -> interval per "group"
xAxis.setLabelCount(xAxisValues.size() - 1, false);
data.setBarWidth(barWidth);
data.groupBars(0, groupSpace, barSpace);
mBarChart.setData(data);
}
示例10: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setData(List<Integer> valueList, String format) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
String legend = "reception rate per second";
if (!format.equals("%"))
legend = "packet count per second";
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(format);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}
示例11: createBarChartData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
public BarData createBarChartData()
{
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(2);
mDashboardHelper = new DashboardHelper(getActivity());
HashMap<String, ArrayList> holder = mDashboardHelper.generateTimesPerDayMap();
ArrayList<String> xVals = holder.get("dayOfThisMonth");
ArrayList<BarEntry> yVals1 = holder.get("episodesPerDay");
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setColor(0xFF2196f3);
set1.setBarSpacePercent(40f);
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10);
data.setValueTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD));
data.setValueTextColor(Color.WHITE);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> numberFormat.format(
value));
return data;
}
示例12: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setData(int count) {
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < count; i++) {
xVals.add(i+"");
entries.add(mSinusData.get(i));
}
BarDataSet set = new BarDataSet(entries, "Sinus Function");
set.setBarSpacePercent(40f);
set.setColor(Color.rgb(240, 120, 124));
BarData data = new BarData(xVals, set);
data.setValueTextSize(10f);
data.setValueTypeface(mTf);
data.setDrawValues(false);
mChart.setData(data);
}
示例13: createBarChart
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* Creates the bar chart showing counters visually.
*/
private void createBarChart(BarChart barChart) {
if (game != null) {
ArrayList<BarEntry> entries = new ArrayList<>();
ArrayList<BarEntry> entries2 = new ArrayList<>();
// create simple bar chart
// fill single rolls, 1..6
int[] counts = sr.getCounts();
for (int i = 0; i < counts.length; i++) {
entries.add(new BarEntry(counts[i], i));
}
// fill double roll sums, 2..12
counts = dr.getSumCount();
for (int i = 0; i < counts.length; i++) {
entries2.add(new BarEntry(counts[i], i + 1));
}
BarDataSet dataset = new BarDataSet(entries, "# of single rolls: " + sr.getTotal());
BarDataSet dataset2 = new BarDataSet(entries2, "# of double rolls: " + dr.getTotal());
ArrayList<String> labels = new ArrayList<>();
// fill label for dice roll sums, 1..12
for (int i = 0; i < 12; i++) {
labels.add(Integer.toString(i + 1));
}
// explicit color resolving with util, see AboutActivity#demoBarChart
List<Integer> colors = ColorTemplate.createColors(getResources(), new int[]{R.color.colorSingleRoll, R.color.colorDoubleRoll});
//dataset.setColors(ColorTemplate.COLORFUL_COLORS);
dataset.setColor(colors.get(0));
dataset2.setColor(colors.get(1));
BarData data = new BarData(labels, dataset);
data.addDataSet(dataset2);
barChart.setData(data);
}
}
示例14: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setData(List<Integer> valueList, String format) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
if (valueList != null) {
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
}
String legend = getResources().getString(R.string.caption_receptin_rate);
if (!format.equals("%"))
legend = getResources().getString(R.string.caption_packet_count);
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(format);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}
示例15: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* update data for visualization chart
*
* @param valueList list of values for the chart
* @param unit data unit
*/
private void setData(List<Integer> valueList, String unit) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
String legend = getResources().getString(R.string.caption_receptin_rate);
if (!unit.equals("%"))
legend = getResources().getString(R.string.caption_packet_count);
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(unit);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}