Declined
Last Updated: 23 Oct 2020 13:17 by ADMIN
Christian
Created on: 19 Oct 2020 09:31
Category: Charts
Type: Feature Request
1
What is the reason that chart tooltips have a "Template" sub-property and chart labels do have the formatting syntax and a label field?

Hello support team,

from the donut chart example under https://demos.telerik.com/blazor-ui/chart/donut-chart:

Is there a specific reason why all charts have a Template sub-property for the ChartSeriesTooltip construct but the Template field with the template syntax for the ChartSeriesLabels construct? I would favour a unified syntax for both of the properties, if this is possible somehow...

 

Is this planned for the future to be unified? Especially formatting like shown under https://docs.telerik.com/blazor-ui/knowledge-base/chart-format-percent is not as simple as I would have expected as nobody wants to touch JavaScript code literally :D (Also, localizing data seems quite difficult with that technique).

The best option in my opinion would be to remove those templates completely and just let the user decide what to show there while using a field called e.g. TooltipMappingName and LabelMappingName or something like that. This gives the chart the maximum of configuration possible.

 

Example:

<TelerikChart>
    <ChartTitle Text="What is you favourite sport?"></ChartTitle>
    <ChartLegend Visible="true" Position="ChartLegendPosition.Top"></ChartLegend>

    <ChartSeriesItems>
        <ChartSeries Type="ChartSeriesType.Donut"
                     Data="@Data"
                     Field="@nameof(ModelData.Value)"
                     CategoryField="@nameof(ModelData.Category)">
            <ChartSeriesTooltip Visible="true" Context="item" TooltipMappingName="@nameof(ModelData.Tooltip)"/>
            <ChartSeriesLabels Position="ChartSeriesLabelsPosition.OutsideEnd"
                               Visible="true"
                               Background="transparent"
                               LabelMappingName="@nameof(ModelData.Label)">
            </ChartSeriesLabels>
        </ChartSeries>
    </ChartSeriesItems>

</TelerikChart>

@code {
    public class ModelData
    {
        public string Category { get; set; }
        public int Value { get; set; }
public string Tooltip { get; set; }
        public string Label { get; set; }
    }

    public List<ModelData> Data = new List<ModelData>()
    {
        new ModelData()
        {
            Category = "Football",
            Value = 35,
Tooltip = "35%",
Label = "Football: 35%"
        },
        new ModelData()
        {
            Category = "Basketball",
            Value = 25,
Tooltip = "25%",
Label = "Basketball: 25%"
        },
        new ModelData()
        {
            Category = "Volleyball",
            Value = 20,
Tooltip = "20%",
Label = "Volleyball: 20%"
        },
        new ModelData()
        {
            Category = "Rugby",
            Value = 10,
Tooltip = "10%",
Label = "Rugby: 10%"
        },
        new ModelData()
        {
            Category = "Tennis",
            Value = 10,
Tooltip = "10%",
Label = "Tennis: 10%"
        }
    };
}

 

Best regards,

Christian

1 comment
ADMIN
Svetoslav Dimitrov
Posted on: 23 Oct 2020 13:17

Hello Christian,

For brevity, I will refer to the Template parameter of the ChartSeriesLabels as A and to the <Template> tag as B.

The main reason why we support A and B as a way to provide custom rendering is that we share the chart engine across different Web suites we, as a company, provide. One of the main differences between A and B is their types, the first is a string, whereas the second is a render fragment. The A template comes directly from the chart engine and cannot execute C# code inside it.

Another key difference is that A is rendered inside an SVG tag, whereas B is HTML.

I am marking this as "Declined" because any changes made would be stray away from our code architecture and breaking change to the chart component across all suites.

Regards,
Svetoslav Dimitrov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.