We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Changing/customizing the text displayed in labels/legends?

Thread ID:

Created:

Updated:

Platform:

Replies:

118641 Mar 26,2015 07:36 PM UTC Apr 1,2015 03:39 PM UTC ASP.NET MVC 3
loading
Tags: PivotChart
Matthew Fekete
Asked On March 26, 2015 07:36 PM UTC

We're using the OLAP Chart control for ASP.NET MVC5 in a financial analysis application. I would like to know if there's a way to change how the text for labels and legends is generated.

For example, we'd like to be able to display a chart of all sales data for a particular vendor. We might add that constraint in the report builder like this:
DimensionElement newDimension = new DimensionElement();
newDimension.Name = "Vendors";
newDimension.AddLevel("ID", "ID");
newDimension.Hierarchy.LevelElements["ID"].Add("1");
newDimension.Hierarchy.LevelElements["ID"].IncludeAvailableMembers = true;
olapReport.CategoricalElements.Add(newDimension);
However, since the key we are using to fetch the vendor is an ID number, the label and legend text will display something along the lines of: "1~ProductA, 1~ProductB, etc..." With more dimensions, this becomes even more unintelligible.

Is it possible to change how the label/legend text is generated from within the OLAP chart service? Can we change an element's display title without affecting its value? Or is there a setting to prevent particular elements from being included in this text?

Thanks,
Matt, CodeASite

Narendhran M [Syncfusion]
Replied On March 30, 2015 06:30 AM UTC

Hi Matthew,

Thanks for using Syncfusion Products.

For customizing the Legend labels, kindly use the event “LegendItemRendering”, in which the names of all the legends could be customized individually. Similarly for customizing the Axis labels, the event “AxesLabelRendering” lets to rename the legends as per our requirement.

Please find the code snippet below for achieving both the scenarios mentioned above.

Code Snippet (~.cshtml)

<script>

function OnAxisLabelRendering(args) {

if (args.data.label.Text == "YourLabel")

args.data.label.Text = "CustomLabelText";

}

function OnLegendItemRendering(args) {

if (args.data.legendItem.Text == "YourLegend")

args.data.legendItem.Text = "CustomLegendText";

}

</script>

<div>

@Html.EJ().Olap().OlapChart("OlapChart1").Url(Url.Content("~/wcf/OlapChartService.svc")).ClientSideEvents( oEve => { oEve.AxesLabelRendering("OnAxisLabelRendering").LegendItemRendering("OnLegendItemRendering"); })

</div>

Please let us know if you require any further assistance.

Regards,

Narendhran M.


Matthew Fekete
Replied On March 31, 2015 06:49 PM UTC

So, just to be clear, there is no way to alter the text displayed in a legend or label before it is rendered? i.e. the only way to change the text is to identify the generated string client-side?

Regards,
Matt

Narendhran M [Syncfusion]
Replied On April 1, 2015 03:39 PM UTC

Hi Matthew,
As per the architecture, the rendering of our OlapChart control is completely carried out in the script side. Hence the best way to customize the legend and axis labels would be the usage of the events mentioned in the previous update.

Please let us know if you have any concern.
Regards,
Narendhran M.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;