Microchart in datagrid header?

Micro Charts for WPF Forum

Posted 13 years ago by Jonathan Reis
Version: 12.1.0560
Avatar

I've started using Microcharts in a datagrid/dashboard and they work great. I was thinking of putting a chart into the datagridtemplatecolumn header (as an aggregate summary of each individual row) and I wasn't able to get the data to display. It appears the datacontext is ok, as I'm able to bind a control to the DeferrableObservable<> count property. I've confirmed this isn't a visibility issue. Any ideas?

Thanks.

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jonathan,

If it's getting the data ok, I'd think it would work.  Perhaps try explicitly giving it some data to see if it shows up, like with this code for a series:

<microcharts:MicroLineSeries ItemsSource="4;-5;3;6;9;-9;1;5" MarkerVisibility="All" MarkerStyleKinds="All" />

That should tell us if the problem is the data isn't binding properly.


Actipro Software Support

Posted 13 years ago by Jonathan Reis
Avatar

That works. Please see the attached xaml, which displays the two textblocks correctly, but nothing for chart. No binding errors in the output window.

 

<DataGridTemplateColumn.Header>
                                                    <StackPanel>
                                                        <TextBlock Text="{Binding ServerVm.ProcessedPoints.Count}" />
                                                        <TextBlock Text="{Binding ServerVm.StringifyProcessedPoints}" />
                                                        <microcharts:MicroXYChart Height="28"
                                                                                  Margin="-1,2,-1,-1"
                                                                                  VerticalAlignment="Bottom"
                                                                                  HorizontalAlignment="Stretch">
                                                            <microcharts:MicroAreaSeries ItemsSource="{Binding ServerVm.ProcessedPoints}">
                                                                <microcharts:MicroAreaSeries.AreaStyle>
                                                                    <Style TargetType="Shape">
                                                                        <Setter Property="Fill" Value="DarkGray" />
                                                                    </Style>
                                                                </microcharts:MicroAreaSeries.AreaStyle>
                                                            </microcharts:MicroAreaSeries>
                                                        </microcharts:MicroXYChart>
                                                    </StackPanel>
                                                </DataGridTemplateColumn.Header>
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jonathan,

I tried this in our Silverlight version since we use a DataGrid in the Region Report demo there.  I used this code for one column:

<sdk:DataGridTemplateColumn>
	<sdk:DataGridTemplateColumn.HeaderStyle>
		<Style TargetType="sdk:DataGridColumnHeader">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate>
						<StackPanel>
							<TextBlock Text="{Binding RegionDataSet[0].Sales.Count}" />
							<microcharts:MicroXYChart Height="28"
								Margin="-1,2,-1,-1"
								VerticalAlignment="Bottom"
								HorizontalAlignment="Stretch">
								<microcharts:MicroLineSeries ItemsSource="{Binding RegionDataSet[0].Sales}" YPath="Amount" MarkerVisibility="All" MarkerStyleKinds="All" />
							</microcharts:MicroXYChart>
						</StackPanel>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</sdk:DataGridTemplateColumn.HeaderStyle>
	<sdk:DataGridTemplateColumn.CellTemplate>
		...
	</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>

That code seemed to work fine and it showed the same data that appears in the first DataGrid row.  Perhaps you need to set the YPath property?  If you have a complex data object, that is required.


Actipro Software Support

The latest build of this product (v24.1.3) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.