how export my control to image with method save after load data, i export empty
the objetive is load data and to show and export to image finally
attached image one export empty and show screen
List <Data> data = new List<Data>();
var AdditionalSell = Double.Parse(MatrixStatic.AdittionalSell);
var AlreadySold = Double.Parse(MatrixStatic.AlreadySold);
var production = Double.Parse(MatrixStatic.Production);
var unsold = production - AdditionalSell - AlreadySold;
var valor1 = Math.Round((AlreadySold * 100) / production, 0);
var valor2 = Math.Round((AdditionalSell * 100) / production, 0);
var valor3 = Math.Round((unsold * 100) / production);
var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
data.Add(new Data() { Value = valor1, Label = resourceLoader.GetString("P2LabelTorta2") });
data.Add(new Data() { Value = valor2, Label = resourceLoader.GetString("P2LabelTorta3") });
data.Add(new Data() { Value = valor3, Label = resourceLoader.GetString("P2LabelTorta1") });
ChartColorModel colorModel = new ChartColorModel();
colorModel.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 255, 60, 0)));
colorModel.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 25, 152, 139)));
colorModel.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 67, 67, 67)));
PieSeries series = new PieSeries()
{
ItemsSource = data,
XBindingPath = "Label",
YBindingPath = "Value",
Label = "Label",
Palette = ChartColorPalette.Custom,
ColorModel = colorModel,
ShowTooltip = true
};
series.AdornmentsInfo = new ChartAdornmentInfo()
{
ShowLabel = true,
SegmentLabelContent = LabelContent.Percentage
};
this.grafico.Series.Clear();
this.grafico.Series.Add(series);
this.grafico.Legend = new ChartLegend();
nombreArchivo = DateTime.Now.ToString("yyyyMMddhhmmss") + ".png";
this.grafico.Save(nombreArchivo, ApplicationData.Current.LocalFolder);
Attachment: LocalState_da32ced1.zip
SIGN IN To post a reply.
1 Reply
MK
Muneesh Kumar G
Syncfusion Team
April 26, 2018 10:00 AM UTC
Hi DIEGO,
Thanks for using Syncfusion products.
We have analyzed your query and we found that you have exported the chart below of chart creation. We would like to inform you that we have scheduled the chart rendering in our source. It will take some time to rendering, so we recommend you to export the chart using below solutions.
Solution 1 : We can export the chart using button click action as below.
Code snippet [XAML]:
|
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" >
<Button Margin="10" Content="Save" Click="Button_Click" HorizontalAlignment="Center"/>
<chart:SfChart x:Name="grafico" Background="White" >
</chart:SfChart>
</StackPanel> |
Code snippet [C#]:
|
private void Button_Click(object sender, RoutedEventArgs e)
{
this.grafico.Save("Sample.png", ApplicationData.Current.LocalFolder);
} |
Solution 2 : We can export the chart using LayoutUpdated event in chart as below.
Code snippet [C#]:
|
public MainPage()
{
this.InitializeComponent();
..
grafico.LayoutUpdated += Grafico_LayoutUpdated;
}
IAsyncAction action;
private void Grafico_LayoutUpdated(object sender, object e)
{
if (action == null)
{
action = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, SaveChart);
}
}
void SaveChart()
{
if (action != null)
{
this.grafico.Save("Sample.png", ApplicationData.Current.LocalFolder);
action = null;
}
} |
We have prepared a sample based on this, please find the sample from the following location.
Please refer the below user documentation for more details.
Please let us know if you have any queries.
Thanks,
Muneesh Kumar G.
Muneesh Kumar G.
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
DS DIEGO SEBASTIAN
- Apr 25, 2018 07:47 PM UTC
- Apr 26, 2018 10:00 AM UTC