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

categoryAxis doesn't show all labels

3 Answers 376 Views
Charts
This is a migrated thread and some comments may be shown as answers.
MV ČR
Top achievements
Rank 1
MV ČR asked on 20 Feb 2020, 01:39 PM

 

 

 

3 Answers, 1 is accepted

Sort by
0
MV ČR
Top achievements
Rank 1
answered on 20 Feb 2020, 01:42 PM

    Hello,
I ran into a problem with column chart  not showing all labels.

01.<div id="example">
02.    <div class="demo-section k-content">
03.        <div id="chart" style="background: center no-repeat url('../content/shared/styles/world-map.png');"></div>
04.    </div>
05.    <script>
06.        function createChart() {
07.            $("#chart").kendoChart({ 
08.   "theme":"flat",
09.   "dataSource":{ 
10.      "data":[ 
11.        
12.            "BolgeBilgileriBolge":"2",
13.            "HayvanBilgileriGrup":"Su Ürünleri",
14.            "HayvanBilgileriGrup_Value":"Su Ürünleri",
15.            "ToplamHayvanSayisi":221
16.         }, { 
17.            "BolgeBilgileriBolge":"2",
18.            "HayvanBilgileriGrup":"Su Ürünleri",
19.            "HayvanBilgileriGrup_Value":"Su Ürünleri",
20.            "ToplamHayvanSayisi":221
21.         }, { 
22.            "BolgeBilgileriBolge":"2",
23.            "HayvanBilgileriGrup":"Su Ürünleri",
24.            "HayvanBilgileriGrup_Value":"Su Ürünleri",
25.            "ToplamHayvanSayisi":221
26.         },
27.         
28.            "BolgeBilgileriBolge":"1",
29.            "HayvanBilgileriGrup":"Kümes Hayvanı",
30.            "HayvanBilgileriGrup_Value":"Kümes Hayvanı",
31.            "ToplamHayvanSayisi":304
32.         },
33.         
34.            "BolgeBilgileriBolge":"2",
35.            "HayvanBilgileriGrup":"Su Ürünleri",
36.            "HayvanBilgileriGrup_Value":"Su Ürünleri",
37.            "ToplamHayvanSayisi":221
38.         },
39.         
40.            "BolgeBilgileriBolge":"1",
41.            "HayvanBilgileriGrup":"Domuz Yetiştiriciliği",
42.            "HayvanBilgileriGrup_Value":"Domuz Yetiştiriciliği",
43.            "ToplamHayvanSayisi":100
44.         }
45.      ],
46.      "group":{ 
47.         "field":"HayvanBilgileriGrup"
48.      },
49.      "sort":[ 
50.         
51.            "field":"ToplamHayvanSayisi",
52.            "dir":"asc"
53.         },
54.         
55.         
56.            "field":"HayvanBilgileriGrup",
57.            "dir":"asc"
58.         }
59.      ]
60.   },
61.   "title":{ 
62.      "text":" "
63.   },
64.   "legend":{ 
65.      "visible":true,
66.      "position":"bottom"
67.   },
68.   "seriesDefaults":{ 
69.      "type":"column",
70.      
71.   },
72.   "series":[ 
73.      
74.        
75.         "field":"ToplamHayvanSayisi"
76.      }
77.   ],
78.   "categoryAxis":{ 
79.      "field":"BolgeBilgileriBolge",
80.      "majorGridLines":{ 
81.         "visible":true
82.      }
83.   },
84.   "tooltip":{ 
85.      "visible":true,
86.      "template":"#:data.series.name# #:parseFloat(value).toLocaleString('tr-TR')# Adet"
87.   }
88.});
89.        }
90. 
91.        $(document).ready(createChart);
92.        $(document).bind("kendo:skinChange", createChart);
93.    </script>
94.</div>
0
MV ČR
Top achievements
Rank 1
answered on 20 Feb 2020, 01:49 PM
There is just only category named 1 but cat. 2 is not there. Someone with an idea?
0
Alex Hajigeorgieva
Telerik team
answered on 24 Feb 2020, 09:47 AM

Hello,

Thank you for the provided data.

The behaviour that you are experiencing is due to uneven data as explained in this forum thread:

https://www.telerik.com/forums/kendo-chart-with-grouped-data-and-some-missing-categoryaxis-labels-#O4Jgmod0hE68NdEmZBwB7g

You may utilize the series.categoryField or even out the data:

series":[ { 
  categoryField: "BolgeBilgileriBolge",

Here is a runnable example with series.categoryField in action:

https://dojo.telerik.com/@bubblemaster/amOPUmiC

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Charts
Asked by
MV ČR
Top achievements
Rank 1
Answers by
MV ČR
Top achievements
Rank 1
Alex Hajigeorgieva
Telerik team
Share this question
or