Legend in slice of Pie chart in silverlight - pie-chart

I have pie chart developped in VS using silverlight.
I have a legend with the colors of each slice.
However, I want to show above each pie slice, the legend and it's value. It's possible to do this?

<chartingToolkit:Chart
x:Name="PieChart"
Margin="50,0,44,0"
Grid.Row="7"
Title="{Binding SelectedGraphOptions, Mode=OneWay}"
VerticalAlignment="Top" Height="478"
Visibility="{Binding PieChartVisibility}">
<chartingToolkit:PieSeries
ItemsSource="{Binding Data}"
IndependentValueBinding="{Binding XAxis}"
DependentValueBinding="{Binding YAxis}" />
</chartingToolkit:Chart>

Related

Set Button half the window size in .NET Maui

I'd like to set the size of a button in .NET Maui to take up half of the window size, or some other fraction. I want to have some big buttons, and I can not lie. If I was doing this in html/css, I would set the width to 50%. In .NET Maui, I would think that I would set the widthrequest to 50%. There doesn't seem to be a way to do that because .WidthRequest only takes a double. So, I thought I would get the width of the current window. I try
var width = DeviceDisplay.Current.MainDisplayInfo.Width;
That only seems to return a zero when I try this in windows in debug mode. Googling doesn't seem to be much help. Is there a way to set a button to a width?
TIA
Maui has proportional sizing for grid row and columns. You don't explain where you want your button but you can use multiples of * proportional.
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/layouts/grid?view=net-maui-7.0
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="2*" />
<RowDefinition Height="*" />
If you put a button in that middle row then it will be half the width of the grid and central.
Similarly, define 3 columns with * widths and you have a central cell half the width and half the height of the grid.
I test the code and it work well:
<Button                
x:Name="btn"                
Text="btn"/>
double width= DeviceDisplay.Current.MainDisplayInfo.Width/4;    
public MainPage()
{        
InitializeComponent();        
btn.WidthRequest=width; 
}

Smallest possible Label inside a Grid with line breaks

I have a Label inside a Grid. I want:
The Grid and the Label to be as small as possible.
The Label should use up to two lines if necessary.
This is what I have:
<VerticalStackLayout Spacing="8">
<Label Text='With HorizontalOptions="Start":' />
<Grid BackgroundColor="#FCC" HorizontalOptions="Start">
<Label
Text="This will not wrap."
MaxLines="2"
/>
</Grid>
<Grid BackgroundColor="#FCC" HorizontalOptions="Start">
<Label
Text="This will not wrap. This will not wrap. This will not wrap. This will not wrap. This will not wrap. This will not wrap. This will not wrap. This will not wrap. "
MaxLines="2"
/>
</Grid>
<Label Text='With HorizontalOptions="Fill":' />
<Grid BackgroundColor="#CFC" HorizontalOptions="Fill">
<Label
Text="This wraps, but fills."
MaxLines="2"
/>
</Grid>
<Grid BackgroundColor="#CFC" HorizontalOptions="Fill">
<Label
Text="This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills."
MaxLines="2"
/>
</Grid>
</VerticalStackLayout>
And this is how it looks:
In conclusion, this is a known issue that be tracked in this thread:https://github.com/dotnet/maui/issues/10494. As #Shaw suggested, we can replace the Grid with an StackLayout to fix the issue. I'll keep an eye on the thread until this is being totally solved.
Thanks for your feedback and patience!

xamarin form: Can the control bind itself?

Let say I have an Image tag inside the xaml and wanted to be in square size.
<Grid HorizontalOptions="Fill">
<Grid.RowDefinitions>
<RowDefinition Height="auto">
</RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Image></Image>
<Image></Image>
<Image></Image>
<Image></Image>
</Grid>
A demo code here have 4 image putting them horizontally within the Grid. The width will be equally defined. So I want the height to be the same as the width. Can I bind themselves like this
<Image x:Name="img" BindingContext="{x:Reference img}" WidthRequest="{Binding HeightRequest}" Grid.Column="1" Grid.Row="0">
Unless you specifically set it somewhere else in code, your WidthRequest will be -1, indicating the control does not explicitly state what width it would like to have, but instead relies on the layout system to workout the correct dimensions.
So this binding, while technically correct, will be useless.
You can try binding to the Width property, which is the readonly property which gets updated with the actual dimensions once the control is laid out.
You can also override the appropriate event and assign the required height there.
Keep in mind that a grid row with height="Auto" will cause A LOT of layout calculation to be done. Especially when changing control sizes after they are already in the visual tree.
Your layout runs **will be* slow.
I suggest you work out a better solution. Such as applying a fixed height to the grid row once the layout engine works out what the cell width for that device is.

avoid inertia scrollviewer for negative offset Windows 8 App

i would like to know how can i remove the inertia effect of the scrollviewer content when the offset is negative.
In reality the offset is 0.0, but the content moves in negative like a spring.
This is a video that show the effect that i'd like to remove:
http://www.youtube.com/watch?v=3kXce-VK--4&feature=youtu.be
The code is very simple:
<ScrollViewer x:Name="CalendarScrollViewer"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
Grid.Column="2" Grid.Row="1"
ZoomMode="Disabled"
HorizontalAlignment="Right"
LayoutUpdated="CalendarScrollViewer_LayoutUpdated" >
<Grid>
...
</Grid>
</ScrollViewer>
Thanks.
Have you tried to set ScrollViewer.IsScrollInertiaEnabled="False" ?

How to change the background color of JasperReports chart

The default background color of JasperReports chart is sky blue.
I want to change that background color.
How to change it?
If you are using iReport select the charts properties and change the background property to the colour you desire.
If not in the XML for the chart there should be an xml tag called <itemLabel>.
Within this you can set the foreground and the background of the chart as seen bellow.
<itemLabel color="#000000" backgroundColor="#FFFFFF"/>
I had this problem. Contrary to even some of the official documentation, the itemLabel tag has no effect on the chart appearance.
Instead, to set the background colour of the entire chart area, create or change the backcolor attribute in the reportElement tag for your chart. E.g:
<barChart>
<chart>
<reportElement mode="Opaque" backcolor="#CCCCCC" x="0" y="0" width="400" height="400"/>
...
Note that the mode attribute must be set to "Opaque" for the colour to be rendered.
If you are using iReport, you can of course change the colour by using the properties tab.
If you want to set the background colour for only the actual chart (area within the axes where the data is displayed), set the backcolor attribute within the plot element of your chart. E.g:
<barChart>
...
<barPlot>
<plot backcolor="#CCCCCC"/>
...
This does not feature on the properties tab, so you will need to edit the xml directly.