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

Problems with remote binding a datasource to a stacked bar chart

2 Answers 41 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Dominik
Top achievements
Rank 1
Dominik asked on 26 Mar 2020, 09:31 AM

Hello,

I have a problem when I'm trying to bind my data to a datasource with remote. If I bind it inline everything is fine and my chart looks like the first attached file. But with remote I get something like the second attached file.

The data I'm using for inline binding is this: var data = [{"Draft": 100, "Published": 200,"Deactivated": 50,"ChangeByVendor": 20}];

And the Data I receive from my endpoint with remote binding is following: "{\"Draft\": 100, \"Published\": 200,\"Deactivated\": 50,\"ChangeByVendor\": 20}"

The series field in my chart looks like this:

series: [{
                name: "@T("Pim.Product.Enum.Published")",
                field: "Published",
                color: "#48b159",
                labels: {
                    visible: true,
                    background: "",
                    position: "center",
                    template: '#if (value > 0) {# #=kendo.format("{0:p}", percentage)# #}#'
                }
            }, {
                name: "@T("Pim.Product.Enum.Draft")",
                field: "Draft",
                color: "#f4a623",
                labels: {
                    visible: true,
                    background: "",
                    position: "center",
                    template: '#if (value > 0) {# #=kendo.format("{0:p}", percentage)# #}#'
                }
            }, {
                name: "@T("Pim.Product.Enum.Deactivated")",
                field: "Deactivated",
                color: "#f42323",
                labels: {
                    visible: true,
                    background: "",
                    position: "center",
                        template: '#if (value > 0) {# #=kendo.format("{0:p}", percentage)# #}#'
                }
                }, {
                name: "@T("Pim.Product.Enum.ChangeByVendor")",
                field: "ChangeByVendor",
                color: "#f42323",
                labels: {
                    visible: true,
                    background: "",
                    position: "center",
                    template: '#if (value > 0) {# #=kendo.format("{0:p}", percentage)# #}#'
                    }
            }],

 

For me, I don't understand why i get two so different result with inline and remote. What am I missing here? I would love to get the chart to look like the inline result but with a remote binding. I hope you can help me with that.

Best regards,

Dominik

2 Answers, 1 is accepted

Sort by
0
Dominik
Top achievements
Rank 1
answered on 26 Mar 2020, 11:19 AM
Okey, I found my mistake. The problem was in my testdata from my endpoint. I used a simple string to create the json response. After I changed it to an array with an anonymous object in it my problem was solved. 
0
Nikolay
Telerik team
answered on 30 Mar 2020, 07:07 AM

Hello Dominik,

I am happy to hear you managed to resolve the situation and thank you for sharing it with us. I believe this will be helpful to others facing the same problem.

Let us know in case anything further arises.

Regards,
Nikolay
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.
Tags
Charts
Asked by
Dominik
Top achievements
Rank 1
Answers by
Dominik
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or