Assign Value Axis dynamically

2 posts, 0 answers
  1. Vinayak
    Vinayak avatar
    3 posts
    Member since:
    Jun 2012

    Posted 14 Oct 2012 Link to this post

    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
  2. Vinayak
    Vinayak avatar
    3 posts
    Member since:
    Jun 2012

    Posted 22 Oct 2012 Link to this post

    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
Back to Top