每个类别的不同颜色线ChartDjango 1.6

2024-05-15 15:52:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在创建一个图表循环,我想为每个类别保留指定的颜色,这样在每个图表中相同的类别总是用相同的颜色表示,但我完全迷失了方向。有什么帮助吗,谢谢

            cht = Chart(
                        datasource = ventasdata, 
                        series_options = 
                            [{'options':{'type': 'line','stacking': False, 'colors': ['#00cc00', '#ff5050','#00cc00']}, # Para area cambiar a 'type': 'area'
                                'terms':{
                                    'mes': [
                                        # 'cantidad_total_mes_2015',
                                        'cantidad_acumulado_2015'],
                                    'mes_2014': [
                                        # 'cantidad_total_mes_2014',
                                        'cantidad_acumulado_2014'],
                                    'mes_2016': [
                                        # 'cantidad_total_mes_2016',
                                        'cantidad_acumulado_2016']
                                        }}],
                        chart_options = 
                            # {'colors': ['#00cc00','#ff5050','#3333ff'], 'title': {
                            {'mes': {
                                'color': '#00cc00'},
                            'cantidad_acumulado_2014': {
                                'color': ['#ff5050']},
                            'cantidad_acumulado_2016': {
                                'color': ['#3333ff']},
                            'terms':{
                                # 'colors': ['#00cc00','#ff5050','#3333ff']},
                                'colors': [['#00cc00'],'#ff5050','#3333ff']},
                            'title': {
                            # {'title': {
                                'text': titulo},
                                'xAxis': {
                                    'title': {'text': 'MES'}}},
                        x_sortf_mapf_mts = (None, monthname, False))
                    return cht

Tags: falsetitle颜色type图表类别coloroptions