This is a migrated thread and some comments may be shown as answers.

color not same when grouping

3 Answers 128 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Amr
Top achievements
Rank 1
Amr asked on 04 Jun 2020, 07:09 AM

Hello,

when i user colorField and user group in DataSource the color result is different  like image i attached

you can see here

https://dojo.telerik.com/aBOWINak

    group: {
                field: "symbol"
            },


            sort: {
                field: "date",
                dir: "asc"
            },

            schema: {
                model: {
                    fields: {
                        date: {
                            type: "date"
                        }
                    }
                }
            }
        });

        function createChart() {
            $("#chart").kendoChart({
                title: { text: "Stock Prices" },
                dataSource: stocksDataSource,
                series: [{
                    type: "column",
                    field: "close",
                    categoryField: "date",
                    name: "#= group.value # (close)",
                    colorField:"color"
                }],
                legend: {
                    position: "bottom"
                },

 

3 Answers, 1 is accepted

Sort by
0
Amr
Top achievements
Rank 1
answered on 04 Jun 2020, 07:12 AM

sorry 

when i use colorField and use group in DataSource the color result is different  like image i attached

0
Accepted
Silviya Stoyanova
Telerik team
answered on 08 Jun 2020, 06:26 PM

Hello Amr,

Thank you for the provided image and Dojo example!

In order to achieve uniformity between the colors in series and legend, you will need to set them manually. Subscribe to DataBound event of the Chart and set the color via the options:

$("#chart").kendoChart({
//...
dataBound: onDataBound
//...
});

function onDataBound(){
  var chart = $("#chart").data("kendoChart");
  chart.options.series[0].color = chart.options.series[0].data[0].color;
  chart.options.series[1].color = chart.options.series[1].data[0].color;
  chart.options.series[2].color = chart.options.series[2].data[0].color;
}
You will find the modified Dojo here: https://dojo.telerik.com/@Silvia/EgEwoGuT

Let me know if you need further assistance.

Kind Regards,
Silviya Stoyanova
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Amr
Top achievements
Rank 1
answered on 08 Jun 2020, 07:00 PM

Hello Silviya ,

Thank you very much

Tags
Chart
Asked by
Amr
Top achievements
Rank 1
Answers by
Amr
Top achievements
Rank 1
Silviya Stoyanova
Telerik team
Share this question
or