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

Strange legend text while chart is rendering

6 Answers 142 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 07 Mar 2017, 04:00 PM

I have a chart that uses grouping and creates a legend at the top of the chart.  While the chart is rendering, the legend that appears at the top of the chart contains 'd NaN/NaN/0NaN' as seen in the attached screenshot.  The legends should contain dates in the format of 'ddd dd/MM/yyyy', so I'm assuming the dates are not yet known, so the legend is displaying in this way.

Is there a way of hiding this until the legend actually has data, because having 'd NaN/NaN/0NaN' show up in the chart does not look good.

Regards,

Shawn

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 09 Mar 2017, 07:34 AM
Hello Shawn,

Assuming that you are using a template to format the date, you could could check if there is value before applying the format in order to avoid this - example.

Regards,
Daniel
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Shawn
Top achievements
Rank 1
answered on 09 Mar 2017, 11:15 AM

Daniel,

Thank you for the reply.  I am using a template for the legend formatting and I added in your suggestion of checking the value with a ternary expression, but the legend still appears with that text as the chart is rendering.  Here is my chart code:

@{
    var styleChart = "height: " + Request.Cookies["DefChartHeight"].Value + "px;";
}
<
div id="HourlySales7Days" class="panel panel-default">
    <div class="demo-section k-content wide">
        @(Html.Kendo().Chart<CBECloudBO2.ViewModels.ChartHourlySales7Day>()
            .Name("chartHourlySales7Days")
            .Title("Hourly Sales 7-day Comparitive")
            .Theme("silver")
            .DataSource(datasource => datasource
                    .Read(read => read.Action("Chart_HourlySales7Day", "Home"))
                    .Group(group => group.Add(model => model.SaleDate))
                    .Sort(sort => sort.Add(model => model.Hour).Ascending())
                    )
            .HtmlAttributes(new { style = @styleChart })
            .Events(events => events.Render("onChartRender"))
            .Legend(legend => legend
                .Visible(true)
                .Position(ChartLegendPosition.Top)
                .Labels(label => label.Template("#= text ? kendo.toString(new Date(text), 'ddd dd/MM/yyyy') : ''#"))
                )
            .ChartArea(chartArea => chartArea.Background("transparent"))
            .Series(series =>
            {
                series.Column(model => model.Value).Name("#= group.value #").CategoryField("Hour");
            })
            .CategoryAxis(axis => axis
                .Name("series-axis")
                .Title("Store Hour")
                .Categories(p => p.Hour)
            )
            .ValueAxis(axis => axis
                .Numeric()
                .Title("Sale Totals")
                .AxisCrossingValue(0, int.MinValue)
            )
            .Tooltip(tooltip => tooltip
                .Visible(true)
                .Format("{0}%")
                .Template("#= kendo.toString(new Date(series.name), 'ddd dd/MM/yyyy') #: #= value #")
            )
        )
    </div>
    <div class="chart-loading"></div>
</div>

 

The 'onChartRender' function for the Onrender event is simply cancelling the kendo.ui.progress graphic element that is displayed while the chart is rendering.

Anything else I can try?

Regards,

Shawn

0
Daniel
Telerik team
answered on 10 Mar 2017, 08:16 AM
Hi,

Could you try removing the series.name option?

Regards,
Daniel
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Shawn
Top achievements
Rank 1
answered on 10 Mar 2017, 09:41 AM

Daniel,

I removed the .Name("#= group.value #") from the Series and now the legend only displays that NaN text even after fully rendering. See attached screenshot.

Regards,

Shawn

0
Shawn
Top achievements
Rank 1
answered on 10 Mar 2017, 09:46 AM

Daniel,

The version of the Kendo.Mvc we are using is:  2016.3.1028.545

Regards,

Shawn

0
Daniel
Telerik team
answered on 14 Mar 2017, 08:00 AM
Hello Shawn,

In that case could you provide a runnable sample that demonstrates the issue? I am unable to replicate it using the provided configuration and specified version.

Regards,
Daniel
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Chart
Asked by
Shawn
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Shawn
Top achievements
Rank 1
Share this question
or