129 строки
4.0 KiB
C#
129 строки
4.0 KiB
C#
#region Copyright Syncfusion Inc. 2001 - 2024
|
|
// Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
|
|
// Use of this code is subject to the terms of our license.
|
|
// A copy of the current license can be obtained at any time by e-mailing
|
|
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
|
// applicable laws.
|
|
#endregion
|
|
|
|
|
|
namespace syncfusion.olapchartdemos.wpf
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Syncfusion.Olap.Manager;
|
|
using Syncfusion.Olap.Reports;
|
|
using Syncfusion.Windows.Shared;
|
|
using System.Windows.Media;
|
|
using System.Reflection;
|
|
|
|
/// <summary>
|
|
/// ViewModel Class
|
|
/// </summary>
|
|
public class ChartWaterMarkViewModel : NotificationObject, IDisposable
|
|
{
|
|
#region Members
|
|
|
|
/// <summary>
|
|
/// Shared connection string.
|
|
/// </summary>
|
|
public static string ConnectionString;
|
|
private OlapDataManager olapDataManager;
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ChartWaterMarkViewModel"/> class.
|
|
/// </summary>
|
|
public ChartWaterMarkViewModel()
|
|
{
|
|
ConnectionString = OlapChartModel.Initialize(System.IO.Path.GetFullPath(@"Assets\Config\OLAPSample.config"));
|
|
olapDataManager = new OlapDataManager(ConnectionString);
|
|
olapDataManager.SetCurrentReport(SimpleDimensions());
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
|
|
/// <summary>
|
|
/// Gets or sets the grid data manager.
|
|
/// </summary>
|
|
/// <value>The grid data manager.</value>
|
|
public OlapDataManager DataManager
|
|
{
|
|
get { return olapDataManager; }
|
|
set { olapDataManager = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the color collection.
|
|
/// </summary>
|
|
/// <value>The color collection.</value>
|
|
public List<string> ColorCollection
|
|
{
|
|
get
|
|
{
|
|
List<string> lst = new List<string>();
|
|
Type br = typeof(Brushes);
|
|
foreach (MemberInfo info in br.GetMembers())
|
|
{
|
|
if (info is PropertyInfo)
|
|
{
|
|
PropertyInfo pi = info as PropertyInfo;
|
|
lst.Add(pi.Name);
|
|
}
|
|
}
|
|
return lst;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Helper Method
|
|
|
|
public void Dispose()
|
|
{
|
|
this.Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
private void Dispose(bool disposing)
|
|
{
|
|
if (disposing && this.olapDataManager != null)
|
|
this.olapDataManager.Dispose();
|
|
}
|
|
|
|
private OlapReport SimpleDimensions()
|
|
{
|
|
OlapReport olapReport = new OlapReport();
|
|
olapReport.CurrentCubeName = "Adventure Works";
|
|
DimensionElement dimensionElementColumn = new DimensionElement();
|
|
|
|
//Specifying the Column Name for the Dimension and measure elements
|
|
dimensionElementColumn.Name = "Customer";
|
|
dimensionElementColumn.AddLevel("Customer Geography", "Country");
|
|
MeasureElements measureElementColumn = new MeasureElements();
|
|
measureElementColumn.Elements.Add(new MeasureElement { Name = "Internet Sales Amount" });
|
|
|
|
//Specifying the Row Name for the Dimension element
|
|
DimensionElement dimensionElementRow = new DimensionElement();
|
|
//Specifying the Dimension Name
|
|
dimensionElementRow.Name = "Date";
|
|
dimensionElementRow.AddLevel("Fiscal", "Fiscal Year");
|
|
|
|
// Adding Column Members
|
|
olapReport.CategoricalElements.Add(dimensionElementColumn);
|
|
//Adding Measure Element
|
|
olapReport.CategoricalElements.Add(measureElementColumn);
|
|
//Adding Row Members
|
|
olapReport.SeriesElements.Add(dimensionElementRow);
|
|
return olapReport;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|