Skip to Content
author's profile photo Former Member
Former Member

How to change display names of values in legend of viz chart

Hi,

I work with an OData service, which offers cryptic names for values and the legend automatically takes these to fill itself. How can I change the names shown in the legend, and when we are it, when I click on a date in the chart?

Here a screen of my graph:

I want to change "Erdat" to "Date" and "SumMm" to "Documents", as well as "RateMmPosted" to "Rate".

This code, that I took from an explored app example, does not work as I thought it would.

vizFrame.setVizProperties({ title: { visible: true, text: title }, legend: {

visible: true

},

plotArea: {

dataPointStyle: {

"rules": [{

"dataContext": ["RateMmPosted"],

"displayName": "Rate"

},

{

"dataContext": ["SumMm"],

"displayName": "Documents"

},

{

"dataContext": ["Erdat"],

"displayName": "Date"

}]

}

},

valueAxis: { title: { text: this.bundle.getText("yAxisLabel"), } }, categoryAxis: { title: { text: this.bundle.getText("Date") } } });

And is it possible to move the legend somewhere else?

Kind regards,

Michael

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jul 28, 2015 at 04:59 AM

    Hi Michael,

    You can change the legend names. Since, you have been referring to UI5 explored sample, I have done few changes to the code.


    Check this -


    JS Bin - Collaborative JavaScript Debugging


    Now as per the above example, the model has Revenue, Item Category and City. While displaying it on UI, the names have been changed to


    Revenue --> Profit

    Item Category --> Category Item

    City --> Place.


    You have ability to change legend positions as well, just inject the following code to change the position to bottom in your vizProperties --> legendGroup


    Different positions are available - JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.viz.ui5.types.Legend_layout_position


    legendGroup :new sap.viz.ui5.types.Legend({layout:new sap.viz.ui5.types.Legend_layout({position :sap.viz.ui5.types.legend.Common_position.bottom}) })
    

    Regards,

    Sai Vellanki.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Logging the vizFrame object helped to find all possible vizProperties that exist.

      Here the settings to show the legend at the bottom and remove the automatically created title:

      vizFrame.setVizProperties({

      title: {

      visible: true,

      text: title

      },

      legend: {

      visible: true,

      title: {

      visible: false

      }

      },

      legendGroup: {

      layout: {

      position: "bottom"

      }

      },

  • author's profile photo Former Member
    Former Member
    Posted on Jul 27, 2015 at 09:34 AM

    Pushing my question again. Any ideas?

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 19, 2015 at 03:10 PM

    Hi Michael,

    I have the same problem and want to use different display names in the legend.

    But I somehow cannot access the JsBin example.

    Can you give me any help please?

    Best regards,

    Stefan.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Rohit, what you just have to do is something like this:

      var elem = [];
      <loop over your KPIs> {
      var measure = new sap.viz.ui5.data.MeasureDefinition();
      var n = <original name>;
      var displayName = <new name>;
      elem.push(displayName);
      measure.setName(displayName);
      measure.bindProperty("value", n);
      oDataset.addMeasure(measure);
      }
      //set feeds
      var feedPrimaryValues = new sap.viz.ui5.controls.common.feeds.FeedItem({
      'uid' : "primaryValues",
      'type' : "Measure",
      'values' : elem }

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.