AnyChart / AnyChart-Android

AnyChart Android Chart is an amazing data visualization library for easily creating interactive charts in Android apps. It runs on API 19+ (Android 4.4) and features dozens of built-in chart types.
2.29k stars 367 forks source link

Create X amount of series dynamically #183

Closed Fdde11 closed 4 years ago

Fdde11 commented 4 years ago

I was using a CustomDataEntry to show 4 series in a char, something like this:

    private class CustomDataEntry extends ValueDataEntry {
        CustomDataEntry(String x, Number value, Number value2, Number value3, Number value4) {
            super(x, value);
            setValue("value2", value2);
            setValue("value3", value3);
            setValue("value4", value4);
        }
    }

but I now require to show a not fixed amount of series, so my char could have 2 or 5 or 'N' amount of series, how can I do this?

Shestac92 commented 4 years ago

@Fdde11 You can create multiple Lists of ValueDataEntry dynamically and apply them to the chart series. It means that you can create one list and map it to multiple series or you can create multiple lists of simple ValueDataEntry.

Fdde11 commented 4 years ago

This is what I did, it worked for me.

private class CustomDataEntry extends ValueDataEntry {
    CustomDataEntry(String x, Number[] value) {
        super(x, value[0]);
        for(int y=1;y<value.length;y++)
        {
          setValue("value"+(y+1), value[y]);
        }
    }
}