Kendo Ui drilldown charts example is not working

1 Answer 92 Views
Charts
Sujith
Top achievements
Rank 1
Sujith asked on 03 Oct 2023, 02:44 AM

https://www.telerik.com/kendo-angular-ui/components/charts/drill-down/

 

Error: src/app/dashboard/dashboard.component.html:20:23 - error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ "Company A": { product: string; sales: number; }[]; "Company B": { product: string; sales: number; }[]; }'.

20               [data]="productData[company]"
                         ~~~~~~~~~~~~~~~~~~~~
 

1 Answer, 1 is accepted

Sort by
0
Martin Bechev
Telerik team
answered on 05 Oct 2023, 07:48 AM

Hi Sujith,

Thank you for the provided feedback.

The error is thrown because of the strict template of the TypeScipt and that the productData doesn't have a type but we are trying to access inner fields on the HTML template. 

To fix the error try providing a type to productData like:

  interface ProductData {
    [key: string]: any[];
  }

 public productData: ProductData = {
        'Company A': [{
            product: 'Product 1',
            sales: 80
        }, {
            product: 'Product 2',
            sales: 20
        }],
        'Company B': [{
            product: 'Product 1',
            sales: 40
        }, {
            product: 'Product 2',
            sales: 160
        }]
    };

I hope this helps.

Regards,
Martin
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
Charts
Asked by
Sujith
Top achievements
Rank 1
Answers by
Martin Bechev
Telerik team
Share this question
or