Java Code Examples for com.github.mikephil.charting.data.LineData#setValueTypeface()
The following examples show how to use
com.github.mikephil.charting.data.LineData#setValueTypeface() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleFragment.java From StockChart-MPAndroidChart with MIT License | 6 votes |
protected LineData generateLineData() { ArrayList<ILineDataSet> sets = new ArrayList<>(); LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(context.getAssets(), "sine.txt"), "Sine function"); LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(context.getAssets(), "cosine.txt"), "Cosine function"); ds1.setLineWidth(2f); ds2.setLineWidth(2f); ds1.setDrawCircles(false); ds2.setDrawCircles(false); ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]); ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]); // load DataSets from files in assets folder sets.add(ds1); sets.add(ds2); LineData d = new LineData(sets); d.setValueTypeface(tf); return d; }
Example 2
Source File: LineChartActivityColored.java From StockChart-MPAndroidChart with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_colored_lines); setTitle("LineChartActivityColored"); charts[0] = findViewById(R.id.chart1); charts[1] = findViewById(R.id.chart2); charts[2] = findViewById(R.id.chart3); charts[3] = findViewById(R.id.chart4); Typeface mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Bold.ttf"); for (int i = 0; i < charts.length; i++) { LineData data = getData(36, 100); data.setValueTypeface(mTf); // add some transparency to the color with "& 0x90FFFFFF" setupChart(charts[i], data, colors[i % colors.length]); } }
Example 3
Source File: LineChartActivityColored.java From Stayfit with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_colored_lines); mCharts[0] = (LineChart) findViewById(R.id.chart1); mCharts[1] = (LineChart) findViewById(R.id.chart2); mCharts[2] = (LineChart) findViewById(R.id.chart3); mCharts[3] = (LineChart) findViewById(R.id.chart4); mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Bold.ttf"); LineData data = getData(36, 100); data.setValueTypeface(mTf); for (int i = 0; i < mCharts.length; i++) // add some transparency to the color with "& 0x90FFFFFF" setupChart(mCharts[i], data, mColors[i % mColors.length]); }
Example 4
Source File: SimpleFragment.java From StockChart-MPAndroidChart with MIT License | 5 votes |
protected LineData getComplexity() { ArrayList<ILineDataSet> sets = new ArrayList<>(); LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(context.getAssets(), "n.txt"), "O(n)"); LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(context.getAssets(), "nlogn.txt"), "O(nlogn)"); LineDataSet ds3 = new LineDataSet(FileUtils.loadEntriesFromAssets(context.getAssets(), "square.txt"), "O(n\u00B2)"); LineDataSet ds4 = new LineDataSet(FileUtils.loadEntriesFromAssets(context.getAssets(), "three.txt"), "O(n\u00B3)"); ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]); ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]); ds3.setColor(ColorTemplate.VORDIPLOM_COLORS[2]); ds4.setColor(ColorTemplate.VORDIPLOM_COLORS[3]); ds1.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]); ds2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[1]); ds3.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[2]); ds4.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[3]); ds1.setLineWidth(2.5f); ds1.setCircleRadius(3f); ds2.setLineWidth(2.5f); ds2.setCircleRadius(3f); ds3.setLineWidth(2.5f); ds3.setCircleRadius(3f); ds4.setLineWidth(2.5f); ds4.setCircleRadius(3f); // load DataSets from files in assets folder sets.add(ds1); sets.add(ds2); sets.add(ds3); sets.add(ds4); LineData d = new LineData(sets); d.setValueTypeface(tf); return d; }
Example 5
Source File: SimpleFragment.java From Stayfit with Apache License 2.0 | 5 votes |
protected LineData generateLineData() { // DataSet ds1 = new DataSet(n, "O(n)"); // DataSet ds2 = new DataSet(nlogn, "O(nlogn)"); // DataSet ds3 = new DataSet(nsquare, "O(n\u00B2)"); // DataSet ds4 = new DataSet(nthree, "O(n\u00B3)"); ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>(); LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "sine.txt"), "Sine function"); LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "cosine.txt"), "Cosine function"); ds1.setLineWidth(2f); ds2.setLineWidth(2f); ds1.setDrawCircles(false); ds2.setDrawCircles(false); ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]); ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]); // load DataSets from textfiles in assets folders sets.add(ds1); sets.add(ds2); // sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "n.txt")); // sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "nlogn.txt")); // sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "square.txt")); // sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "three.txt")); int max = Math.max(sets.get(0).getEntryCount(), sets.get(1).getEntryCount()); LineData d = new LineData(ChartData.generateXVals(0, max), sets); d.setValueTypeface(tf); return d; }
Example 6
Source File: SimpleFragment.java From Stayfit with Apache License 2.0 | 5 votes |
protected LineData getComplexity() { ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>(); LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "n.txt"), "O(n)"); LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "nlogn.txt"), "O(nlogn)"); LineDataSet ds3 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "square.txt"), "O(n\u00B2)"); LineDataSet ds4 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "three.txt"), "O(n\u00B3)"); ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]); ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]); ds3.setColor(ColorTemplate.VORDIPLOM_COLORS[2]); ds4.setColor(ColorTemplate.VORDIPLOM_COLORS[3]); ds1.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]); ds2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[1]); ds3.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[2]); ds4.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[3]); ds1.setLineWidth(2.5f); ds1.setCircleRadius(3f); ds2.setLineWidth(2.5f); ds2.setCircleRadius(3f); ds3.setLineWidth(2.5f); ds3.setCircleRadius(3f); ds4.setLineWidth(2.5f); ds4.setCircleRadius(3f); // load DataSets from textfiles in assets folders sets.add(ds1); sets.add(ds2); sets.add(ds3); sets.add(ds4); LineData d = new LineData(ChartData.generateXVals(0, ds1.getEntryCount()), sets); d.setValueTypeface(tf); return d; }
Example 7
Source File: CubicLineChartActivity.java From Stayfit with Apache License 2.0 | 4 votes |
private void setData(int count, float range) { ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < count; i++) { xVals.add((1990 +i) + ""); } ArrayList<Entry> vals1 = new ArrayList<Entry>(); for (int i = 0; i < count; i++) { float mult = (range + 1); float val = (float) (Math.random() * mult) + 20;// + (float) // ((mult * // 0.1) / 10); vals1.add(new Entry(val, i)); } // create a dataset and give it a type LineDataSet set1 = new LineDataSet(vals1, "DataSet 1"); set1.setDrawCubic(true); set1.setCubicIntensity(0.2f); //set1.setDrawFilled(true); set1.setDrawCircles(false); set1.setLineWidth(1.8f); set1.setCircleRadius(4f); set1.setCircleColor(Color.WHITE); set1.setHighLightColor(Color.rgb(244, 117, 117)); set1.setColor(Color.WHITE); set1.setFillColor(Color.WHITE); set1.setFillAlpha(100); set1.setDrawHorizontalHighlightIndicator(false); set1.setFillFormatter(new FillFormatter() { @Override public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) { return -10; } }); // create a data object with the datasets LineData data = new LineData(xVals, set1); data.setValueTypeface(tf); data.setValueTextSize(9f); data.setDrawValues(false); // set data mChart.setData(data); }