Not rendering any charts

Charts for WPF Forum

Posted 10 years ago by sravanthi
Version: 13.2.0591
Avatar
public class DashboardData
    {
        public string DigitalFlag { get; set; }
        public int Open { get; set; }
        public int Closed { get; set; }
        public double AverageWaitTime { get; set; }
    }

public ObservableCollection<DashboardData> Data { get; set; }

Random r = new Random();
foreach (var flag in digitalFlags)
Data.Add(new DashboardData { AverageWaitTime = 2.0, Closed = r.Next(1, 20), DigitalFlag = flag.Name, Open = r.Next(1, 20) });

 

<charts:XYChart GridLineMajorVisibility="Y" GridStripeVisibility="Y" >
                <charts:XYChart.YAxes>
                    <charts:XYDoubleAxis x:Name="q1" />
                </charts:XYChart.YAxes>
                <charts:XYChart.XAxes>
                    <charts:XYDoubleAxis LabelFormat="{}{1:0}" AreLabelsVisible="True"/>
                </charts:XYChart.XAxes>
                <charts:BarSeries ItemsSource="{Binding Data}" YPath="Open" StackKind="None"  YAxis="{Binding ElementName=q1}" XPath="DigitalFlag"/>
                <charts:BarSeries ItemsSource="{Binding Data}" YPath="Closed" StackKind="None"  YAxis="{Binding ElementName=q1}" XPath="DigitalFlag"/>
            </charts:XYChart>         

 

Hi, I have followed the sample project for rendering charts and could not be able to see any charts.

Above is the xaml and C# code

I don’t see anything rendered. Pls Help...

Comments (4)

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

Hello, I think part of the problem is that you didn't set your DataContext.  For instance you should set "this.DataContext = this;" or else the binding you have won't work.


Actipro Software Support

Posted 10 years ago by sravanthi
Avatar

I can actually see X-axis Labels but not Y-axis.

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

This XAML will work with one change in the code behind:

<charts:XYChart x:Name="chart" GridLineMajorVisibility="Y" GridStripeVisibility="Y">
	<charts:XYChart.YAxes>
		<charts:XYDoubleAxis TickMajorInterval="4" TickMinorInterval="1" AreMajorTicksVisible="True" AreMinorTicksVisible="True" />
	</charts:XYChart.YAxes>
	<charts:XYChart.XAxes>
		<charts:XYDoubleAxis LabelFormat="{}{1:0}" AreLabelsVisible="True"/>
	</charts:XYChart.XAxes>
	<charts:BarSeries ItemsSource="{Binding Data}" YPath="Open" StackKind="None" XPath="DigitalFlag"/>
	<charts:BarSeries ItemsSource="{Binding Data}" YPath="Closed" StackKind="None" XPath="DigitalFlag"/>
</charts:XYChart>

I think part of the problem is that tick intervals need to be specified for the axis to show.

But also, the DashboardData class needs to be updated so that Open and Close are doubles instead of ints.  That combined with the XAML above gets it rendering nicely.  We will look into why it wasn't working with ints as-is.


Actipro Software Support

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

Hello, we have fixed this issue for the next maintenance release.  With those updates, you will be able to use int-based data and it will automatically upconvert it to doubles behind the scenes so that it can be displayed.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.