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

Set categories and culture in kendo charts doesn't work

4 Answers 264 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Philippe
Top achievements
Rank 1
Philippe asked on 30 Sep 2016, 03:58 PM
I try to set fix categories in my kendo chart for all day of week, also when didn't have value and I just want the 5 days of european weeks like monday to friday. Second problem, I can't set culture to have the name of day in french.

        @(Html.Kendo().Calendar()
            .Name("calendar")
            .Value(DateTime.Now)
            .Format("dd/MM/yyyy")
            .Events(e => e.Change("refreshGrid"))
        )
    </div>
    @(Html.Kendo().Chart<RapportTache>()
            .Name("chart")
            .Title("Rapport de la semaine")
            .Legend(legend => legend
                .Position(ChartLegendPosition.Top)
            )
            .DataSource(ds => ds
                        .Read(read => read.Action("Chart_Read", "Saisie").Data("getDateTime"))
                        .Group(group => group.Add(model => model.TacheLibelle))
                        .Sort(sort => sort.Add(model => model.RapportTacheJourDate).Ascending())
                        )
            .Series(series =>
            {
                series.Column(model => model.RapportTacheJourDuree, categoryExpression: model => model.RapportTacheJourDate).Stack(true);
            })
            .CategoryAxis(axis => axis
                .Labels(labels => labels
                    .Culture("fr-FR")
                    .DateFormats(formats => formats
                        .Days("dddd dd")
                    )
            )
            .MajorGridLines(lines => lines.Visible(false))
        )
        .SeriesColors(
            "#cd1533", "#d43851", "#dc5c71", "#e47f8f", "#eba1ad",
            "#009bd7", "#26aadd", "#4db9e3", "#73c8e9", "#99d7ef"
        )
        .ChartArea(h => h.Height(300))
        .ValueAxis(axis => axis.Numeric()
            .Labels(labels => labels.Format("{0:N0}"))
            .MajorUnit(10)
            .Line(line => line.Visible(false))
        )
        .Tooltip(tooltip => tooltip
            .Visible(true)
            .Template("#= dataItem.RapportTacheJourDuree # (heures) : #= dataItem.TacheLibelle #")
        )
    )

And this is the actual result : 

[![enter image description here][1]][1]


  [1]: http://i.stack.imgur.com/xa3pP.png



In the actual situtation, I just have the monday on null value. If anyone have an idea, thank's for help ! :)

4 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 05 Oct 2016, 12:10 PM
Hello Philippe,

To localize the chart you should initially load the corresponding culture .js file and then set the culture to the kendo object. More details on the matter are available here - http://docs.telerik.com/kendo-ui/framework/globalization/overview

Regarding excluding weekends that is not possible for a date axis. You can, however, use categories where you can manually pass the week day names as strings.

Regards,
Danail Vasilev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Philippe
Top achievements
Rank 1
answered on 05 Oct 2016, 01:25 PM

Hello Danail and thank's for you're answers. Regarding this chart with week day, I look this with you're ticket support. 

Maybe you can help me for another chart where I use a dynamic view model with categories in a list of string.

The problem with this chart is that the categories is not define like I want, is look like this : 

http://image.noelshack.com/fichiers/2016/40/1475673508-tel2.png

If you look good, you can see I have one categories with my List<string> categories separate with coma... And I want all of my categories in the chart even I have no value. 

This the view :

@(Html.Kendo().Chart()
                .Name("ChartEquipe")
                .Legend(legend => legend
                    .Visible(false)
                )
                .Series(series =>
                {
                    foreach (var def in Model.RapportsEquipe)
                    {
                        series.Column(def.RapportSemaine).ToField(def.EmployeeNom).Name(def.ClientNom + " " + def.EmployeeNom).Stack(def.EmployeeNom);
                    }
                })
                .CategoryAxis(axis => axis
                     .Categories(Model.InitialesEquipe)
                     .MajorGridLines(lines => lines.Visible(true))
                  )
                .SeriesColors(
                    "#5DA39B", "#39635E", "#81E3D7", "#89F0E3", "#73C9BF"
                )
                .Tooltip(tooltip => tooltip
                    .Visible(true)
                    .Template("#= value # (heures) : #= series.name #")
                    )
                )

 

My ViewModel : 

    public class SaisieViewModel
    {
        public List<string> InitialesEquipe { get; set; }
 
        public List<RapportTacheEquipe> RapportsEquipe { get; set; }
    }
}

And my Model for chart : 

public class RapportTacheEquipe
    {
        public string EmployeeNom { get; set; }
 
        public DateTime RapportTacheJourDate { get; set; }
        
        public float RapportTacheJourTotal { get; set; }
 
        public string ClientNom { get; set; }
 
        public List<float> RapportSemaine
        {
            get
            {
                return new List<float> { RapportTacheJourTotal };
            }
        }
 
        public string RapportJour
        {
            get
            {
                return Enum.GetName(typeof(eJourSemaine), (int)RapportTacheJourDate.DayOfWeek);
            }
        }
    }

 

Any idea ? Thank you.

0
Danail Vasilev
Telerik team
answered on 10 Oct 2016, 08:18 AM
Hi Philippe,

Generally, items from series are aligned over each category from the x-axis. That being said the desired appearance of the chart is not achievable with categories. To workaround that, however, you can simply use x-axis Title instead of categories.

I would also suggest that you open separate tickets/forum posts when you have different questions. Thus we can keep the threads concise and easy to track if needed. Also the corresponding support officer can answer you better.

Regards,
Danail Vasilev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Philippe
Top achievements
Rank 1
answered on 10 Oct 2016, 01:23 PM

Ok thank's for help, I will start a new forum post.

 

Tags
Chart
Asked by
Philippe
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Philippe
Top achievements
Rank 1
Share this question
or