Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Chart printing to XPS
    primarykey
    data
    text
    <p>Update: I manged to fix this by just creating simple style template for series datapoint. For anyone who is facing similiar issue here is my simple code. This code does not show series LegendItems but i assume it is fixable in similiar fashion.</p> <pre><code>&lt;Style x:Key="MyColumnDataPointStyle" TargetType="charting:ColumnDataPoint"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="charting:ColumnDataPoint"&gt; &lt;Border Background="Plum" BorderBrush="Gray" BorderThickness="1" Opacity="1" x:Name="Root" &gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="True"&gt; &lt;Setter TargetName="Root" Property="Background" Value="Yellow"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>I am using system.windows.controls.datavisualization.toolkit in a WPF/C# project to create Charts. </p> <p>I have no problem creating the chart but when i try to print it to XPS, it does not display series there at all. Printing the chart when the window is loaded works fine but i need to print charts with out displaying it in window.</p> <p>Chart displayed in window:</p> <p><a href="http://www.freeimagehosting.net/4yito" rel="nofollow noreferrer">Normal chart</a></p> <p>Chart in XPS:</p> <p><a href="http://www.freeimagehosting.net/96zdc" rel="nofollow noreferrer">XPS chart</a></p> <p>Here is how i create XPS-file:</p> <pre><code> XpsDocument doc = new XpsDocument(@".\chart.xps", FileAccess.Write); XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc); VisualsToXpsDocument vToXpsD = (VisualsToXpsDocument)writer.CreateVisualsCollator(); foreach (Canvas canvas in reportViewer.Document.Pages) { canvas.Measure(canvas.RenderSize); canvas.Arrange(new Rect(new Point(0, 0), canvas.RenderSize)); vToXpsD.Write(canvas); } vToXpsD.EndBatchWrite(); doc.Close(); </code></pre> <p>Chart code:</p> <pre><code>Chart chart = new Chart(); BarSeries bar = new BarSeries(); Binding valuesBinding = new Binding("Value"); Binding namesBinding = new Binding("Title"); bar.ItemsSource = content.Series[0].Points; bar.IndependentValueBinding = namesBinding; bar.DependentValueBinding = valuesBinding; chart.Series.Add(bar); </code></pre> <p>I have tried this <a href="https://stackoverflow.com/questions/4080486/wpf-chart-print-system-windows-controls-datavisualization-toolkit">solution</a> but i could not get it to work.</p> <p>Any help is much appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload