I am making one app in which i need to display visible spectrum (400nm to 780nm). I am using MPAndroidchart
. I converted wavelength
to color
and rendered the spectrum. Below is the screenshot of the app. I can display the rendered spectrum on the background grid but how can i display in the lineDataset
. LineDataSet
only have one function SetFillColor(int)
. I want to fill the lineDataset
with this Paint
. This is my code.
Paint paint = new Paint();// = chart.setPaint();
int[] colors =new int[7];
float[] pos = {0.0f, 0.15f, 0.275f, 0.325f, 0.5f,0.6625f,1};
final float[] bands = { 380, 440, 490, 510, 580, 645, 780};
for(int i =0;i<bands.length;i++) {
colors[i]=Wavelength.wvColor(bands[i], gamma);
//Wavelength.wvColor is the function which returns the `int`.
}
paint.setShader(new LinearGradient(0, 0, chart.getWidht(), 0, colors, pos, Shader.TileMode.CLAMP));
In chart
, i can easily display it with the below code
chart.setPaint(paint, Chart.PAINT_GRID_BACKGROUND);
Question: How can i fill my LineDataset
with the linearGradient or fill with array of colors?