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

Assign Value Axis dynamically

1 Answer 138 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Vinayak
Top achievements
Rank 1
Vinayak asked on 14 Oct 2012, 07:48 PM
Hi ,

I am building a multi-axis chart with data generated from webservice. As a part of the data source, I am grouping data based on a field Category. Here is a sample of the data
Category: Temp, Value: 20
Category:Temp, Value:22
Category:Humidity,Value:45
Category:Humidity:Value:48

I would like to create in the chart two axis one for Temp and other for Humidity. Since the series are created automatically, I would like to know how do I assign Temp Axis to Category 'Temp' and other axis to Category 'Humidity' based on the series name or series array.

Thanks,
Vinayak

1 Answer, 1 is accepted

Sort by
0
Vinayak
Top achievements
Rank 1
answered on 23 Oct 2012, 01:43 AM
Further diving into the assigning the Value Axis dynamically, I have written a function to modify the valueAxis Array as follows

function chtobj() {
        var testch = $("#TmpChart").data("kendoChart");
        
        var VArray = [];

        VArray.push({
            name: "Temp",
            color: "#ec5e0a"
        },
            {
                name: "Humidity",
                color: "#4e4141"
            });
            testch.options.valueAxis = VArray;
        for (i = 0; i < testch.options.series.length; i++) {

            if (testch.options.series[i].name.indexOf("Humidity") != -1) {

                testch.options.series[i].axis = "Humidity";
            }
            else {
                testch.options.series[i].axis = "Temp";
            };
       
        console.log(testch.options);    
                testch.refresh();
    }

Console log shows that the ValueAxis Array contains two items however the chart refresh does not refresh. I am getting a javascript error 'TypeError : J is undefined Kendo.all.min.js(line 8).

Any help in resolving this error would be much appreciated.

Thanks,
Vinayak
Tags
Charts
Asked by
Vinayak
Top achievements
Rank 1
Answers by
Vinayak
Top achievements
Rank 1
Share this question
or