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

Category Axis Labels Display Error

5 Answers 208 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Dragos
Top achievements
Rank 1
Dragos asked on 21 Mar 2016, 11:38 AM

I have run into a problem while trying to do some on the fly charts.

I provided a dojo with the problem, what happens is that category axis doesn't scale the values so it goes like this 2015 - 2016 - 2015 -2016.

I can't seem to figure out the problem.

http://dojo.telerik.com/eWONO/11

 

Any help is much appreciated,

Thanks.

5 Answers, 1 is accepted

Sort by
0
Dragos
Top achievements
Rank 1
answered on 22 Mar 2016, 08:17 AM

Can anyone help with this ???, i can reproduce this issue with a lot if examples, the x axis just divides like this..

 

0
EZ
Top achievements
Rank 2
answered on 22 Mar 2016, 04:06 PM

I would transform the data into a grouped dataSource like this:

var dataForChart = [];
var grpDataSource;
 
for ( var i = 0; i < data.length; i++) {         
  for ( var j = 0; j < data[i].Values.length; j++){
    var item = {};
    item.series = data[i].name;
    item.date = new Date(data[i].Values[j].data);
    item.value = data[i].Values[j].value;
    dataForChart.push(item);
  }
}
 
grpDataSource = new kendo.data.DataSource({
  data: dataForChart,
  group: {
    field: "series"
  },
  sort: {
    field: "date",
    dir: "asc"
  },
  schema: {
    model: {
      fields: {
        date: {
          type: "date"
        }
      }
    }
  }
});

function createChart() {
    $("#chart").kendoChart({
        title: {
            text: "Site Visitors Stats \n /thousands/"
        },
        legend: {
            visible: false
        },
        dataSource: grpDataSource,
        series: [{
            type: "column",
            field: "value",
            name: "#= group.value #"
        }],              
        categoryAxis: {
            field: "date",
            majorGridLines: {
                visible: false
            },
          justified: true,
            labels: {
            font: "10px sans-serif",
            rotation: 70,
            step: 3,
            template: '#: kendo.toString(kendo.parseDate(value), "MM/dd/yyyy") #'
            },
        },
        tooltip: {
            visible: true,
            template: "#= series.name #: #= value #"
        }
    });
}

Updated DOJO

0
Dimiter Topalov
Telerik team
answered on 23 Mar 2016, 11:37 AM
Hi Erik,

Your approach seems perfectly fine.

Let us know if you have further questions about the Kendo UI widgets.

Regards,
Dimiter Topalov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mike
Top achievements
Rank 1
answered on 25 Mar 2016, 07:47 AM
So , if the chart does not have a datasource you can end up "sometimes" with a bad axis , but only sometimes , this feels like a bug 
0
T. Tsonev
Telerik team
answered on 29 Mar 2016, 07:56 AM
Hello,

The problem here is that the Chart doesn't see the category values as dates. They're only being parsed in the label templates.

Therefore it will plot them in the order that they appear from the data source.
You can use a date axis, but that's somewhat different, as it will plot a continuous time line, not just the set of points you supply.

I hope this makes sense.

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
Dragos
Top achievements
Rank 1
Answers by
Dragos
Top achievements
Rank 1
EZ
Top achievements
Rank 2
Dimiter Topalov
Telerik team
Mike
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or