Jump to content
Software FX Community

Pie chart legend scrollbar


Mick
 Share

Recommended Posts

Is there any way to remove the scrollbar from the legend if there are too many values to display in the space for the legend?

I want to be able to produce both WPF controls and static images from the same chart, and while the scrollbar is an excellent idea for a WPF control, a printed scrollbar does little good.

I don't mind if the data in the image format becomes squished, as my main concern is that every pie slice has a legend entry.

Thank you,

Mick

Link to comment
Share on other sites

  • 2 weeks later...

I can manually set the height of the legend box to the size of the chart to alleviate this problem in some instances, but this is a hack that only works if the number of items in the legend is just right.

Example:

I have a pie chart with 10 items, and I am exporting the chart to an image 336 pixels tall, and a scrollbar shows up in the legend because the legend determines that its height should be somewhat too small to display all 10 items. I am using the built in function:

Chart.Export(FileFormat format, Stream stream)

---

Do I have to edit the entries manually in the legend box or write my own custom legend layout algorithm (or something else entirely) ? Is there a simple way like an Enum or a flag to control the LegendBox's scrollbar behavior when creating a static image?

Please help, I am evaluating 3 different chart controls for purchase and I like 99% of what I see with this one over the others.

Thank you,

Mick

Link to comment
Share on other sites

Sorry for posting again so soon, but my time expired to edit the above post before I realized an omission:

I am using the Style "Spotlight" and the Palette "Mesa" with a Gallery type of GalleryType.Pie. The height of 336 isn't enough to cause a scrollbar to appear on the "Basic" style and palette.

Link to comment
Share on other sites

Another way to remove the need for scrollbar might be to

1) Adjust the font size used by the legend

2) Change the legend box layout to accomodate 2 columns

<cfx:Chart.LegendBox>

  <cfx:LegendBox>

  <cfx:LegendBox.ItemsPanel>

  <ItemsPanelTemplate>

  <UniformGrid Columns="2"/>

  </ItemsPanelTemplate>

  </cfx:LegendBox.ItemsPanel>

  </cfx:LegendBox>

</cfx:Chart.LegendBox> 

Regards,

JuanC 

Link to comment
Share on other sites

  • 1 month later...

The following customization should give you the behavior you are looking for

<cfx:Chart.LegendBox<cfx:LegendBox>   <cfx:LegendBox.ContainerStyle>   <Style TargetType="{x:Type ItemsControl}">   <Style.Setters>   <Setter Property="Template">   <Setter.Value>   <ControlTemplate TargetType="{x:Type ItemsControl}">   <ItemsPresenter /> </ControlTemplate> </Setter.Value> </Setter>   <Setter Property="ItemsPanel">   <Setter.Value>   <ItemsPanelTemplate>   <UniformGrid Columns="1"/> </ItemsPanelTemplate> </Setter.Value> </Setter>   <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> </Style.Setters> </Style> </cfx:LegendBox.ContainerStyle</cfx:LegendBox></cfx:Chart.LegendBox>

Using an uniform grid and setting the VerticalScrollBarVisibility to Disabled will give you the squished behavior when the space is not enought to hold all legends.

It would be great if we could automatically change our behavior when an image is being generated unfortunately the process uses the same visuals. If you do not want to affect the chart behavior on the screen you could use the Clone method to clone your chart (including data), modify the LegendBox.ContainerStyle on the clone and then Export the clone chart.

Regards,

JuanC

PS: We currently have no plans to fix the scrolling behavior internally.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...