Bug Report B133700
Visible to All Users

FieldValueDisplayText does not work when binding to a chart

created 16 years ago

When binding a pivot grid to a chart, the chart does not display the DisplayText that is assigned in the FieldValueDisplayText event.
If the pivot field references a lookup field of the underlying data, I use the FieldValueDisplayText event to lookup the value in the referenced lookup data and display an appropriate display text instead of the ID value. This works for the pivot grid, but does not work in the chart that is bound to the grid.
Steps to Reproduce:
Add the following event to the pivot - chart demo (Chart.cs) that is installed with DevExpress pivot grid:
      private void pivotGridControl1_FieldValueDisplayText(object sender, PivotFieldDisplayTextEventArgs e)
        {
            if (e.IsColumn)
                e.DisplayText = "Month: " + e.Value.ToString();
        }
Run the project.
The pivot grid displays: "Month: 1", "Month: 2", etc.
The chart still displays: "January", "February", etc.
(Ok, this is only an example and does not make much sense, but i.e. if the value is an ID, it is important to use the DisplayText that is assigned within the FieldValueDisplayText event.)
Actual Results:
The displayed text in the pivot grid and the chart differ.
Expected Results:
The pivot grid and the chart should display the same DisplayText.

Show previous comments (3)
DevExpress Support Team 16 years ago

    Hi Joern,
    I've found a solution for your task. You can change the labels displayed in chart's axis by populating the Axis.CustomLabels collection. Simply fill it with values and labels from your lookup table. Please also refer to issue Changing Default X Axis labels.
    I'm looking forward to hearing from you.
    Thanks,
    Michael.

      Hi Michael,
      thank you for your suggestion!
      I tried to implement your solution but did not get it to work…
      My problems:
      - I do not know which specific IDs and DisplayText from my lookup table to provide to Axis.CustomLabels collection. The user can filter the data and I do not know which data is displayed in the pivot grid or which data is selected if the chart is only based on the selected data. So my solution was to provide all available lookup data to the CustomLabels collection even if it is not used. So far, so good.
      - But then the user can add multiple fields to the pivot grid and the grid generates chart labels in the form of "field1 | field2". For example look at the sample "Customer Reports" from the XtraPivotGrid Main Demo. The left hand side produces labels in the form of "Customer | Product Name" or if the fields were lookup fields the labels would be "Customer ID | Product ID" i.e. "1 | 3", "1 | 4", "2 | 4" etc.
      - If I apply the same solution as before - adding all lookup data - I need to add all possible combinations of lookup IDs from the two fields. In the above example I would need to add all possible combinations of Customer IDs and Product IDs. That is not efficient - especially if we add a third field.
      - And now where the solution really failed: If one of the combined fields includes a date group i.e. a month field, the generated labels include localized strings. Imagine the same sample report as above but instead of the "Product Name" field use a "Order Month" field. That would generate labels in the form of "Customer ID | Month Name", like "1 | January", "1 | February" etc. but in German it generates "1 | Januar", "1 | Februar" etc.
      - So with the localized text I have no idea what to add to the Axis.CustomLabels collection because it could be anything depending on the operating system of the user and the installed resource satellite assemblies.
      If you know how to solve this, can you provide me a sample that covers the above mentioned problems?
      I still believe it would be way easier to use the same DisplayText event of the pivot grid to generate the chart labels properly.
      Thanks for your help!
      Joern

      DevExpress Support Team 16 years ago

        Hi Joern,
        I researched this scenario further, and found that the FieldValueDisplayText fires only in some weird conditions (this depends on the field area and area index). This appears to be a bug in our controls. We'll try to resolve it as soon as possible.
        Thanks,
        Michael.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.