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

Duplicate but different Cat Axis items

4 Answers 291 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 28 May 2015, 06:30 PM
I have a column chart where the data coming from the DB has some valid data that confuses Kendo. The data for the Category Axis is a list of merchants. There happens to be a few merchants with the exact same name, but different merchant IDs. How can I show "duplicate" merchant names in the category axis? Is there a way to identify uniqueness by the merchant id and not the merchant name, where merchant name is displayed on the category axis?
Thanks,
--Ed

4 Answers, 1 is accepted

Sort by
0
EZ
Top achievements
Rank 2
answered on 29 May 2015, 03:35 PM

If your data looks something like this:

 

[ {
               "merchant": "Acme",
               "id": "1",
               "value": 3,
               "userColor": "#ffd600"
           }, {
               "merchant": "Acme",
               "id": "2",
               "value": 7,
               "userColor": "#ffd600"
           }, {
               "merchant": "merch 2",
               "id": "3",
               "value": 12,
               "userColor": "#ffd600"
           }, {
               "merchant": "merch 3",
               "id": "4",
               "value": 15,
               "userColor": "#ffd600"
           }, ...

 

Then the chart will show similarly named categories with no problems:

 

Dojo DEMO

0
T. Tsonev
Telerik team
answered on 01 Jun 2015, 11:36 AM

Hello,

Using a categoryAxis.field will deal with duplicate category names, as shown by Erik. In this mode categories and series points will be listed in order.

If series.categoryField is in use then duplicate categories will be merged. Series points will be aggregated accordingly. This is mostly useful when the series are bound from different data sets that have categories in common.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ed
Top achievements
Rank 1
answered on 01 Jun 2015, 04:43 PM

Hello,

Yes, you are correct that series.categoryField is in use and this is why the duplicate categories are merged based on category name. How can I specify unique categories based on a field other than what is displayed on the chart? I want to merge duplicate categories based on one field (let's say it is CategoryId) and display the categories on the chart using a second field (let's call it CategoryName).

Thanks,

--Ed

0
Accepted
T. Tsonev
Telerik team
answered on 03 Jun 2015, 10:57 AM

Hello Ed,

You can specify any field for the category binding. What appears on screen can be customized via templates:

categoryAxis: {
  labels: {
    tempate: "#= dataItem.myRealCategory #"
  }
}

I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Charts
Asked by
Ed
Top achievements
Rank 1
Answers by
EZ
Top achievements
Rank 2
T. Tsonev
Telerik team
Ed
Top achievements
Rank 1
Share this question
or