diogobernardino / williamchart

Android Library to rapidly develop attractive and insightful charts in android applications.
5.1k stars 800 forks source link

Grid not fitting the points (squeezed) #306

Open kkuez opened 3 years ago

kkuez commented 3 years ago

The Grid Im using does not fit the datapoints, meaning it does not start by x=0 and x=EndOfX but is squeezed. https://ibb.co/zXdQJy6

final AxisGrid grid = new AxisGrid();
                    grid.setStrokeWidth(1);
                    grid.setGridType(GridType.VERTICAL);
                    grid.setGridEffect(GridEffect.DOTTED);
                    linearChartView.setGrid(grid);

Edit: Graphs are not matching, too: https://ibb.co/72S0kCJ

ConstraintLayout.LayoutParams layoutParamsConstraint =
                    new ConstraintLayout.LayoutParams(50 * lists.get(0).size(),
                            countChecksChartView.getHeight());

            countReportsChartView.setLayoutParams(layoutParamsConstraint);
            countReportsChartView.setScale(new Scale(0, highestValueY));
            countReportsChartView.show(lists.get(0));

            final Function1<Float, String> floatToIntStringFun =
                    val -> val.toString().substring(0, val.toString().indexOf("."));
            countReportsChartView.setLabelsFormatter(floatToIntStringFun);
<HorizontalScrollView
                    android:layout_width="wrap_content"
                    android:layout_gravity="left"
                    android:id="@+id/chartHorizontalScrollView"
                    android:layout_height="300dp">

                <androidx.constraintlayout.widget.ConstraintLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:id="@+id/chartConstraintLayout"
                >

                    <com.db.williamchart.view.LineChartView
                            android:layout_width="match_parent"
                            app:chart_lineColor="#458B74"
                            app:chart_lineThickness="2dp"
                            app:chart_smoothLine="false"
                            app:chart_labelsSize="18sp"
                            android:layout_height="match_parent"
                            android:id="@+id/countReportsChartView"
                            app:layout_constraintLeft_toLeftOf="@id/chartConstraintLayout"
                            app:layout_constraintBottom_toBottomOf="parent"/>
                    <com.db.williamchart.view.LineChartView
                            android:layout_width="match_parent"
                            app:chart_lineColor="#8b2323"
                            app:chart_lineThickness="2dp"
                            app:chart_smoothLine="false"
                            app:chart_labelsSize="18sp"
                            android:layout_height="match_parent"
                            android:id="@+id/countChecksChartView"
                            app:layout_constraintLeft_toLeftOf="@id/chartConstraintLayout"
                            app:layout_constraintBottom_toBottomOf="parent"/>
                </androidx.constraintlayout.widget.ConstraintLayout>
            </HorizontalScrollView>
        </LinearLayout>
    </ScrollView>