lecho/hellocharts-android

"setHasGradientToTransparent" Are Missing on LineChart with Kotlin

nicolasmanurung opened this issue · 3 comments

I have been implementing LineChart on Kotlin. But I cant go to setHasGradientToTransparent function

val line = Line(values)
            line.color = ChartUtils.COLORS[i]
            line.shape = shape
            line.isCubic = isCubic
            line.isFilled = isFilled
            line.hasLabels()
            line.hasLabelsOnlyForSelected()
            line.hasLines()
            line.hasPoints()
            
            line.setHasGradientToTransparent(hasGradientToTransparent) //Here is a red line

Hi,How do you solve this problem?

Hi,How do you solve this problem?

No, I'm stuck on there...

i did it.the first,you can copy the classes LineChartView.java and LineChartRenderer.java to your project from demo.then change the code

linePaint.setShader(line.getGradientToTransparent() ?
new LinearGradient(0, 0, 0, canvas.getHeight(), line.getColor(),
line.getColor() & 0x00ffffff, Shader.TileMode.MIRROR) :
null);

to
linePaint.setShader(new LinearGradient(0, 0, 0, canvas.getHeight(), line.getColor());

in LineChartRenderer.java
.and then ,you need import class :your local path.LineChartView.class in your local path.LineChartView.java.
and last,you need use class:your local path.LineChartView in your layout xml,
like:
<com.test.customView.LineChartView

    android:id="@+id/chart"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</com.test.customView.LineChartView>

. it's over,good luck.