lecho / hellocharts-android

Charts library for Android compatible with API 8+, several chart types with scaling, scrolling and animations 📊
Apache License 2.0
7.43k stars 1.61k forks source link

i want to map the bandwidth of network using line chart view but realtime doesn't work plz help me #518

Closed shaikhsiddik closed 4 years ago

shaikhsiddik commented 5 years ago

downStreamSpeed = Utils.parseSpeed(downStream, SHOW_SPEED_IN_BITS); RX = (TextView) findViewById(R.id.down_speed); if (downStream < 150000) { RX.setTextColor(Color.RED); RX.setText(downStreamSpeed); } else if (downStream > 150000 && downStream < 220000) { RX.setTextColor(Color.parseColor("#FF8C00")); RX.setText(downStreamSpeed); } else if (downStream > 220000) { RX.setTextColor(Color.GREEN); RX.setText(downStreamSpeed); } // // List values = new ArrayList(); // values.add(new PointValue(0, )); // values.add(new PointValue(1, 4)); // values.add(new PointValue(2, 3)); // values.add(new PointValue(3, 4)); // values.add(new PointValue(4, 2)); // values.add(new PointValue(5, 1)); // values.add(new PointValue(6, 5)); // values.add(new PointValue(7, 9)); // // // //In most cased you can call data model methods in builder-pattern-like manner. // Line line = new Line(values).setColor(Color.BLUE).setCubic(true); // List lines = new ArrayList(); // lines.add(line); // // LineChartData data = new LineChartData(); // data.setLines(lines); // // LineChartView chart = new LineChartView(getApplicationContext()); // chart.setLineChartData(data);

                    for (int i = 0; i < maxNumberOfLines; ++i) {
                        for (int j = 0; j < numberOfPoints; ++j) {
                            randomNumbersTab[i][j] = (float) downStream;
                        }
                    }
                    List<Line> lines = new ArrayList<Line>();
                    for (int i = 0; i < numberOfLines; ++i)
                    {

                        List<PointValue> values = new ArrayList<PointValue>();
                        for (int j = 0; j < numberOfPoints; ++j) {
                            values.add(new PointValue(j, randomNumbersTab[i][j]));
                        }

                        Line line = new Line(values);
                        line.setColor(ChartUtils.COLORS[i]);
                        line.setShape(shape);
                        line.setCubic(false);
                        line.setHasLabels(true);
                        line.setHasLines(false);
                        line.setHasPoints(true);

// line.setHasGradientToTransparent(hasGradientToTransparent); // if (pointsHaveDifferentColor){ // line.setPointColor(ChartUtils.COLORS[(i + 1) % ChartUtils.COLORS.length]); // } lines.add(line); data = new LineChartData(); data.setLines(lines); if (hasAxes) { Axis axisX = new Axis(); Axis axisY = new Axis().setHasLines(true); if (hasAxesNames) { axisX.setName(""); axisY.setName("Bandwidth"); } data.setAxisXBottom(axisX); data.setAxisYLeft(axisY); } else { data.setAxisXBottom(null); data.setAxisYLeft(null); } chart = new LineChartView(getApplicationContext()); chart.setLineChartData(data);