chart exports in pdf only the first page

I'm using blazor server 19.3.0.43 and I need to export a charts in pdf (see attachment) which has two series as below, but regardless the number of bars, only one page is exported in pdf

How can I export all the pages of the complete chart ? 

And how can I remove the margins of the pdf to use the whole A4 page space ?


                <SfChart @ref="@chartInstance" Title="@Title" Width="650px">

                    <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category" Title="Prodotti" />

                    <ChartTooltipSettings Enable="true"></ChartTooltipSettings>

                    <ChartSeriesCollection>

                        <ChartSeries DataSource="@DatiProdotti" XName="Descrizione" YName="Qta" Name="Quantità" ColumnWidth="1" Type="ChartSeriesType.Bar">

                            <ChartMarker>

                                <ChartDataLabel Visible="true" Position="Syncfusion.Blazor.Charts.LabelPosition.Outer">

                                    <ChartDataLabelFont FontWeight="600" Color="#E73571"></ChartDataLabelFont>

                                </ChartDataLabel>

                            </ChartMarker>

                        </ChartSeries>

                        <ChartSeries DataSource="@DatiProdotti" XName="Descrizione" YName="ValorePesato" Name="Peso" ColumnWidth="1" Type="ChartSeriesType.Bar">

                            <ChartMarker>

                                <ChartDataLabel Visible="true" Position="Syncfusion.Blazor.Charts.LabelPosition.Outer">

                                    <ChartDataLabelFont FontWeight="600" Color="#E73571"></ChartDataLabelFont>

                                </ChartDataLabel>

                            </ChartMarker>

                        </ChartSeries>

                    </ChartSeriesCollection>

                </SfChart>

 


Attachment: Grafico_prodotti_(1)_336d1a4d.zip

12 Replies

DG Durga Gopalakrishnan Syncfusion Team October 12, 2021 02:40 PM UTC

Hi Walter, 

Thanks for using Syncfusion products.  

We have analyzed your queries with provided snippet. We request you to specify the Height and Width for chart to export in required size. We have prepared sample based on your requirement. Please check with below snippet and sample. 

<SfChart @ref="@chartInstance" Title="@Title" Width="680px" Height="1000px"></SfChart> 

Exported PDF  

 


Please let us know if you have any concerns. 

Regards, 
Durga G 



WM Walter Martin October 13, 2021 09:01 AM UTC

Thanks for the answer

Using your width and height the export in pdf is now correct as you can see in the attachment, but the chart is resized to stay in only one page so it's almost unreadable

For this reason I tried to change the height value to have the increase the bar's height but in this way the chart is truncated.

Is there any option to split the chart in more than one pdf's page ?


Attachment: Grafico_prodotti_(7)_645d1c1c.zip


DG Durga Gopalakrishnan Syncfusion Team October 14, 2021 03:26 PM UTC

Hi Walter, 

We have validated your required scenario. As of now we don’t have an option to split the chart into multiple pages. You can split the datasource and provide it for two separate charts to view the bar width as high when assigning large data. 

Kindly revert us if you have any concerns. 

Regards,  
Durga G


WM Walter Martin October 20, 2021 09:10 PM UTC

Do you have any sample on how can I create a sfchart totally from code behind ?

If I have to split the data in several charts I need to create them from code behind and then export them in several pdf

I tried to create a sfchart unsuccessfully because I think it's necessary to specify the ChartPrimaryXAxis  but I don't find the syntax to add it to the sfchart



DG Durga Gopalakrishnan Syncfusion Team October 21, 2021 04:22 PM UTC

Hi Walter, 

As of now, we don’t have support to create the chart totally from code behind. Please let us know if you have any concerns. 

Regards, 
Durga G 



WM Walter Martin October 22, 2021 12:03 PM UTC

I have about 160 items in my datasource so to have a "visible" chart, I have to keep about 15 items every page so this lead to export 160/15 = 11 pdf files 

To do that, I tried to use a for loop to load in one only sfchart 15 items at a time and then export it 

Something like... 

DatiProdottiParziali = DatiProdotti;

int enloop = DatiProdotti.Count / 15;

for (int i = 0; i < enloop; i++)

{

DatiProdotti = DatiProdottiParziali.Skip(i * 15).Take(15).ToList();

chartInstance.Export(ExportType.PDF, "Grafico prodotti");

}

but this approach doesn't work because all the pdf pages exported have the first 15 items

It seems to be that the datasource of the  chartInstance doesn't change before exporting it ... is there a way to force  a refresh of chartInstance ?

chartInstance.Refresh() does nothing






DG Durga Gopalakrishnan Syncfusion Team October 25, 2021 12:56 PM UTC

Hi Walter, 
  
We are analyzing your reported scenario. We will update the status within one business day(26th October, 2021). We appreciate your patience until then. 
  
Regards, 
Durga G 



DG Durga Gopalakrishnan Syncfusion Team October 25, 2021 02:43 PM UTC

Hi Walter, 

We have analyzed your query with provided snippet. We request you to call StateHasChanged method after changing the chart series datasource and Task.Delay for 1 second before exporting the chart with new changes. We have prepared sample based on your requirement. Please check with below and sample. 

public int Length = 5; 
    protected override void OnInitialized() 
    { 
        Data = ChartPoints.Take(Length).ToList(); 
    } 
public async void ExportChart(Microsoft.AspNetCore.Components.Web.MouseEventArgs args) 
    { 
        var count = ChartPoints.Count / Length; 
        for (int i = 0; i < count; i++) 
        { 
            Data = ChartPoints.Skip(i * Length).Take(Length).ToList(); 
            this.StateHasChanged(); 
            await Task.Delay(1000); 
            await chartInstance.ExportAsync(ExportType.PDF, "Chart"); 
        } 
    } 


Kindly revert us if you have any concerns. 

Regards,  
Durga G


WM Walter Martin October 25, 2021 10:25 PM UTC

Thanks, it worls in this way

I hope the option to split the data in several pages but in one only pdf will be available one day




DG Durga Gopalakrishnan Syncfusion Team October 26, 2021 02:45 PM UTC

Hi Walter, 

We are not clear about your exact query. If you split datasource in odd count, for example among 11 datapoints, need to display first 5 datapoints in 1st pdf and next 5 datapoints in 2nd pdf, then remaining 1 datapoint will be displayed in 3rd pdf. Whether you are mentioning this case? Please share more details about your requirement so that it will be helpful for further analayis. 

Regards,  
Durga G


WM Walter Martin October 26, 2021 03:31 PM UTC

I have in my datasource 148 records to show in a chart

If I simply export them they are exported  in one page of one pdf file and they're truncated  so the bars are  almost unreadable

Using your suggestion, I changed the chart height and I get only 15 records at a time to show them in a more readable way as in my attachment but of course I exported  in this way 10 pdf files made up of one page only

I'd like to export instead the 148 records in 10 pages of one only pdf file

If I've well understood, this is not possible up to now.



Attachment: Grafico_prodotti_(10)_1476f8f7.zip


DG Durga Gopalakrishnan Syncfusion Team October 27, 2021 04:15 PM UTC

Hi Walter, 
  
Sorry for the inconvenience. Currently, we don’t have support to export the chart into multiple pages. Please let us know if you have any concerns. 
  
Regards,  
Durga G 


Loader.
Up arrow icon