Custom Color Legend

1 Answer 7 Views
Heatmap
Ryan
Top achievements
Rank 1
Ryan asked on 13 Jun 2024, 03:37 AM

Hi,

I created a heatmap with custom color combination like the code below. My question is, how can I translate it as legend? Thank you.

function createChart() {
            $("#heatmap").kendoChart({
                dataSource: {
                    data: data
                },
                series: [{
                    name: 'Heatmap of IHR scores across regions',
                    type: 'heatmap',
                    xField: 'CapacityNo',
                    yField: 'Region',
                    field: 'AvgScore',
                    tooltip: {
                        visible: true,
                        template: "<b>#=dataItem.Region# - C#=dataItem.CapacityNo# : #=dataItem.AvgScore#</b>"
                    },
                    color: function(rec){
                        if (rec.dataItem.AvgScore > 80) {
                            return "#619621";
                        }
                        if (rec.dataItem.AvgScore > 60) {
                            return "#7cac2b";
                        }
                        if (rec.dataItem.AvgScore > 40) {
                            return "#f9c000";
                        }
                        if (rec.dataItem.AvgScore > 20) {
                            return "#fab000";
                        }
                        return "#de3a2c";
                    }
                }],
                legend: {
                    position: "bottom"
                },
                xAxis: {
                    labels: {
                        rotation: 'auto'
                    }
                }
            });
        }

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 17 Jun 2024, 12:00 PM

Hi Ryan,

You can modify colors for the different legend items with the following properties:

Dojo demo: https://dojo.telerik.com/IRaQesit

All Heatmap API properties you can find at the below link:

https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart

Regards,
Nikolay
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
Heatmap
Asked by
Ryan
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or