robinhood / spark

A simple Android sparkline chart view.
Apache License 2.0
1.28k stars 157 forks source link

Setting cornerRadius to non-zero results in fill closing path also using radius #66

Open cammace opened 6 years ago

cammace commented 6 years ago

When we set cornerRadius to a non-zero value, CornerPathEffect is applied which works great until you apply a fill to the graph which results in:

I think rather than closing the path, if a fill is applied, on line 274 we should manually enclose the path first by hitting the bottom right corner of the view, then bottom left, and finally back to the starting position. I'm also wondering if we could make this paticuliar closing path "invisible" rather than showing the sparkline path closing the graph.

danh32 commented 6 years ago

Oh wow, haha! What cornerRadius did you set?

I have:

    <com.robinhood.spark.SparkView
        android:id="@+id/sparkview"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        app:spark_lineColor="@color/colorAccent"
        app:spark_fillColor="@color/colorAccentTransparent"
        app:spark_fillType="down"
        app:spark_cornerRadius="15dp"
        app:spark_scrubEnabled="true"/>

and am seeing:

screen shot 2018-05-01 at 9 20 14 am

Interestingly, we're already manually enclosing the path by going to the bottom right then bottom left. The close() call only closes from the bottom left back to the first point in the spark. I don't have any immediate ideas on how to fix this, but mostly because I think the solution will be different for different applications.