Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Morris Donut not supporting colors option? #105

Open
woodmicha opened this issue Feb 27, 2017 · 0 comments
Open

Morris Donut not supporting colors option? #105

woodmicha opened this issue Feb 27, 2017 · 0 comments

Comments

@woodmicha
Copy link

woodmicha commented Feb 27, 2017

I'm trying to get the donut to respond to colors via the code below without success:

class ThresholdFactorsView(BaseAthleteView):
template_name = 'factors.html'

def get_context_data(self, **kwargs):
    context = super(ThresholdFactorsView, self).get_context_data(**kwargs)
    factors_list = self.client.get_threshold_factors()
    chart_data, chart_colors = self.build_feature_data(factors_list)
    threshold_data_source = SimpleDataSource(data=chart_data)
    threshold_factors_chart = DonutChart(data_source=threshold_data_source, options={'colors': chart_colors})
    context['factors_chart'] = threshold_factors_chart
    context['slug'] = 'factors'
    return context

def build_feature_data(self, factors_list):
    colors = []
    rval = [['label','value']]
    for row in factors_list:
        feature = row['feature']
        coef = row['coef']
        color = "#008000"
        if coef < 0:
            color = "#FF0000"
        rval.append([feature, abs(coef)])
        colors.append(color)
    return rval, colors

I have a fix for it if you'd like me to send it along...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant