private ChartValues<double> GetData() { var r = new Random(); var trend = 100; var values = new ChartValues<double>(); for (var i = 0; i < 160; i++) { var seed = r.NextDouble(); if (seed > .8) trend += seed > .9 ? 50 : -50; values.Add(trend + r.Next(0, 10)); } return values; }
public void AddRandomSeries() { var r = new Random(); var values = new ChartValues<SalesData>(); var numberOfVals = SalesmenSeries.Count == 0 ? 5 : SalesmenSeries[0].Values.Count; for (var i = 0; i < numberOfVals; i++) values.Add(new SalesData { ItemsSold = r.Next(5, 30), Rentability = r.NextDouble() * .2, ItemsAverageSellPrice = 5000 }); SalesmenSeries.Add(new BarSeries { Title = _names[r.Next(0, _names.Count() - 1)], Values = values }); }
public PointStateExample() { InitializeComponent(); var r = new Random(); Values = new ChartValues<ObservableValue> { new ObservableValue(r.Next(10, 400)), new ObservableValue(r.Next(10, 400)), new ObservableValue(r.Next(10, 400)), new ObservableValue(r.Next(10, 400)), new ObservableValue(r.Next(10, 400)), new ObservableValue(r.Next(10, 400)) }; //Lets define a custom mapper, to set fill and stroke //according to chart values... Mapper = Mappers.Xy<ObservableValue>() .X((item, index) => index) .Y(item => item.Value) .Fill(item => item.Value > 200 ? DangerBrush : null) .Stroke(item => item.Value > 200 ? DangerBrush : null); Formatter = x => x + " ms"; OkBrush = new SolidColorBrush(Color.FromArgb(255, 254, 192, 7)); DangerBrush = new SolidColorBrush(Color.FromArgb(255, 238, 83, 80)); DataContext = this; }
public CustomizedLineSeries() { InitializeComponent(); Values1 = new ChartValues<ObservableValue> { new ObservableValue(3), new ObservableValue(4), new ObservableValue(6), new ObservableValue(3), new ObservableValue(2), new ObservableValue(6) }; Values2 = new ChartValues<ObservableValue> { new ObservableValue(5), new ObservableValue(3), new ObservableValue(5), new ObservableValue(7), new ObservableValue(3), new ObservableValue(9) }; DataContext = this; }
public FullyResponsiveExample() { InitializeComponent(); MyValues = new ChartValues<ObservableValue> { new ObservableValue(5), new ObservableValue(7), new ObservableValue(8), new ObservableValue(3) }; var lineSeries = new LineSeries { Values = MyValues, StrokeThickness = 4, Fill = new SolidColorBrush(Windows.UI.Colors.Transparent), PointGeometrySize = 0, DataLabels = true }; SeriesCollection = new SeriesCollection { lineSeries }; DataContext = this; }
public SolidColorExample() { InitializeComponent(); Values = new ChartValues<double> {150, 375, 420, 500, 160, 140}; DataContext = this; }
public InvertedExample() { InitializeComponent(); Values1 = new ChartValues<double> { 3, 5, 2, 6, 2, 7, 1 }; Values2 = new ChartValues<double> { 6, 2, 6, 3, 2, 7, 2 }; DataContext = this; }
public DarkPanelControlVm() { _timer.Interval = TimeSpan.FromMilliseconds(1000); _timer.Tick += TimerOnTick; _timer.Start(); AngularGaugeValue = 50; Yes = new ObservableValue(10); No = new ObservableValue(6); Maybe = new ObservableValue(4); Line1 = new ChartValues<ObservableValue> { new ObservableValue(3), new ObservableValue(5), new ObservableValue(1), new ObservableValue(6), new ObservableValue(8), new ObservableValue(3), new ObservableValue(6), new ObservableValue(3) }; PieSeries = new SeriesCollection { new PieSeries {Title = "Yes",Values = new ChartValues<ObservableValue> {Yes}}, new PieSeries {Title = "No", Values = new ChartValues<ObservableValue> {Maybe}}, new PieSeries {Title = "Maybe", Values = new ChartValues<ObservableValue> {Maybe}} }; GeoValues = new Dictionary<string, double>(); var r = new Random(); GeoValues["MX"] = r.Next(0, 100); GeoValues["RU"] = r.Next(0, 100); GeoValues["CA"] = r.Next(0, 100); GeoValues["US"] = r.Next(0, 100); GeoValues["IN"] = r.Next(0, 100); GeoValues["CN"] = r.Next(0, 100); GeoValues["JP"] = r.Next(0, 100); GeoValues["BR"] = r.Next(0, 100); GeoValues["DE"] = r.Next(0, 100); GeoValues["FR"] = r.Next(0, 100); GeoValues["GB"] = r.Next(0, 100); DynamicValues = new ChartValues<ObservableValue> { new ObservableValue(1), new ObservableValue(5), new ObservableValue(4), new ObservableValue(7), new ObservableValue(4), new ObservableValue(8) }; Formatter = x => x.ToString("P"); }
public CustomTooltipAndLegendExample() { InitializeComponent(); Customers = new ChartValues<CustomerVm> { new CustomerVm { Name = "Irvin", LastName = "Hale", Phone = 123456789, PurchasedItems = 8 }, new CustomerVm { Name = "Malcolm", LastName = "Revees", Phone = 098765432, PurchasedItems = 3 }, new CustomerVm { Name = "Anne", LastName = "Rios", Phone = 758294026, PurchasedItems = 6 }, new CustomerVm { Name = "Vivian", LastName = "Howell", Phone = 309382739, PurchasedItems = 3 }, new CustomerVm { Name = "Caleb", LastName = "Roy", Phone = 682902826, PurchasedItems = 2 } }; Labels = new[] { "Irvin", "Malcolm", "Anne", "Vivian", "Caleb" }; //let create a mapper so LiveCharts know how to plot our CustomerViewModel class var customerVmMapper = Mappers.Xy<CustomerVm>() .X((value, index) => index) // lets use the position of the item as X .Y(value => value.PurchasedItems); //and PurchasedItems property as Y //lets save the mapper globally Charting.For<CustomerVm>(customerVmMapper); DataContext = this; }
private void AddSeriesOnClick(object sender, RoutedEventArgs e) { var vals = new ChartValues<ViewModel>(); var r = new Random(); for (int i = 0; i < Series[0].Values.Count; i++) { vals.Add(new ViewModel {YValue = r.Next(0, 11)}); } Series.Add(new LineSeries {Values = vals, DataLabels = true}); }
public ConstantChanges() { InitializeComponent(); //To handle live data easily, in this case we built a specialized type //the MeasureModel class, it only contains 2 properties //DateTime and Value //We need to configure LiveCharts to handle MeasureModel class //The next code configures MEasureModel globally, this means //that livecharts learns to plot MeasureModel and will use this config every time //a ChartValues instance uses this type. //this code ideally should only run once, when application starts is reccomended. //you can configure series in many ways, learn more at http://lvcharts.net/App/examples/v1/wpf/Types%20and%20Configuration var mapper = Mappers.Xy<MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For<MeasureModel>(mapper); //the ChartValues property will store our values array ChartValues = new ChartValues<MeasureModel>(); cartesianChart1.Series = new SeriesCollection { new LineSeries { Values = ChartValues, PointDiameter = 18, StrokeThickness = 4 } }; cartesianChart1.AxisX.Add(new Axis { DisableAnimations = true, LabelFormatter = value => new System.DateTime((long) value).ToString("mm:ss"), Separator = new Separator { Step = TimeSpan.FromSeconds(1).Ticks } }); SetAxisLimits(System.DateTime.Now); //The next code simulates data changes every 500 ms Timer = new Timer { Interval = 500 }; Timer.Tick += TimerOnTick; R = new Random(); Timer.Start(); }
public MaterialCards() { InitializeComponent(); LastHourSeries = new SeriesCollection { new LineSeries { Values = new ChartValues<ObservableValue> { new ObservableValue(3), new ObservableValue(5), new ObservableValue(6), new ObservableValue(7), new ObservableValue(3), new ObservableValue(4), new ObservableValue(2), new ObservableValue(5), new ObservableValue(8), new ObservableValue(3), new ObservableValue(5), new ObservableValue(6), new ObservableValue(7), new ObservableValue(3), new ObservableValue(4), new ObservableValue(2), new ObservableValue(5), new ObservableValue(8) } } }; _trend = 8; _timer.Tick += (sender, o) => { var r = new Random(); _trend += (r.NextDouble() > 0.3 ? 1 : -1) * r.Next(0, 5); LastHourSeries[0].Values.Add(new ObservableValue(_trend)); LastHourSeries[0].Values.RemoveAt(0); SetLecture(); }; _timer.Start(); Vals = new ChartValues<double> { 5, 9, 8, 6, 1, 5, 7, 3, 6, 3 }; Nan = double.NaN; DataContext = this; }
private ChartValues<DateTimePoint> GetData() { var r = new Random(); var trend = 100; var values = new ChartValues<DateTimePoint>(); for (var i = 0; i < 100; i++) { var seed = r.NextDouble(); if (seed > .8) trend += seed > .9 ? 50 : -50; values.Add(new DateTimePoint(System.DateTime.Now.AddDays(i), trend + r.Next(0, 10))); } return values; }
public FullyResponsive() { InitializeComponent(); Values = new ChartValues<ObservableValue> { new ObservableValue(3), new ObservableValue(6), new ObservableValue(7), new ObservableValue(4), new ObservableValue(2) }; cartesianChart1.LegendLocation = LegendLocation.Right; }
public UserControlDynamicGraph() { InitializeComponent(); var mapper = Mappers.Xy<MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For<MeasureModel>(mapper); //the values property will store our values array ValuesChannel1 = new ChartValues<MeasureModel>(); ValuesChannel2 = new ChartValues<MeasureModel>(); ValuesChannel3 = new ChartValues<MeasureModel>(); ValuesChannel4 = new ChartValues<MeasureModel>(); _channelValues.Add(ValuesChannel1); _channelValues.Add(ValuesChannel2); _channelValues.Add(ValuesChannel3); _channelValues.Add(ValuesChannel4); _channelLines.Add(LineSeriesChannel1); _channelLines.Add(LineSeriesChannel2); _channelLines.Add(LineSeriesChannel3); _channelLines.Add(LineSeriesChannel4); UpdateChannelNames(); //lets set how to display the X Labels DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss"); AxisStep = TimeSpan.FromSeconds(1).Ticks; SetAxisLimits(DateTime.Now); //The next code simulates data changes every 300 ms Timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(intervalInMs) }; Timer.Tick += TimerOnTick; IsDataInjectionRunning = false; R = new Random(); DataContext = this; e2010.OnData += OnDataE2010; }
public GanttExample() { InitializeComponent(); var now = System.DateTime.Now; _values = new ChartValues<GanttPoint> { new GanttPoint(now.Ticks, now.AddDays(2).Ticks), new GanttPoint(now.AddDays(1).Ticks, now.AddDays(3).Ticks), new GanttPoint(now.AddDays(3).Ticks, now.AddDays(5).Ticks), new GanttPoint(now.AddDays(5).Ticks, now.AddDays(8).Ticks), new GanttPoint(now.AddDays(6).Ticks, now.AddDays(10).Ticks), new GanttPoint(now.AddDays(7).Ticks, now.AddDays(14).Ticks), new GanttPoint(now.AddDays(9).Ticks, now.AddDays(12).Ticks), new GanttPoint(now.AddDays(9).Ticks, now.AddDays(14).Ticks), new GanttPoint(now.AddDays(10).Ticks, now.AddDays(11).Ticks), new GanttPoint(now.AddDays(12).Ticks, now.AddDays(16).Ticks), new GanttPoint(now.AddDays(15).Ticks, now.AddDays(17).Ticks), new GanttPoint(now.AddDays(18).Ticks, now.AddDays(19).Ticks) }; cartesianChart1.Zoom = ZoomingOptions.X; cartesianChart1.Series = new SeriesCollection { new RowSeries { Values = _values, DataLabels = true } }; cartesianChart1.AxisX.Add(new Axis { LabelFormatter = value => new System.DateTime((long)value).ToString("dd MMM") }); var labels = new List<string>(); for (var i = 0; i < 12; i++) labels.Add("Task " + i); cartesianChart1.AxisY.Add(new Axis { Labels = labels.ToArray() }); button1_Click(null, null); }
public LineExample() { InitializeComponent(); Values = Values = new ChartValues<float> { 3, 4, 6, 3, 2, 6 }; DataContext = this; }
public void AddRandomSeries() { var c = this.FirstOrDefault() == null ? 5 : this.First().Values.Count; var values = new ChartValues<SalesInfo>(); for (int i = 0; i < c; i++) { values.Add(new SalesInfo { Id = 1, Income = _r.Next(5000, 15000), Rentability = _r.NextDouble()*.15 }); } Add(new BarSeries {Title = "Random Series", Values = values}); }
private void AddSeriesOnClick(object sender, RoutedEventArgs e) { var r = new Random(); var c = SeriesCollection.Count > 0 ? SeriesCollection[0].Values.Count : 5; var vals = new ChartValues<ObservableValue>(); for (var i = 0; i < c; i++) { vals.Add(new ObservableValue(r.Next(0, 10))); } SeriesCollection.Add(new PieSeries { Values = vals }); }
public TestVm() { var r = new Random(); var values = new ChartValues<double> { 12,6,8,2,8,2,11 }; SeriesCollection = new SeriesCollection { new ColumnSeries { Values = values } }; }
public ScatterExample() { InitializeComponent(); var r = new Random(); ValuesA = new ChartValues<ObservablePoint>(); ValuesB = new ChartValues<ObservablePoint>(); ValuesC = new ChartValues<ObservablePoint>(); for (var i = 0; i < 20; i++) { ValuesA.Add(new ObservablePoint(r.NextDouble() * 10, r.NextDouble() * 10)); ValuesB.Add(new ObservablePoint(r.NextDouble() * 10, r.NextDouble() * 10)); ValuesC.Add(new ObservablePoint(r.NextDouble() * 10, r.NextDouble() * 10)); } DataContext = this; }
public ManualZAndPExample() { InitializeComponent(); Values = new ChartValues<double>(); var r = new Random(); for (var i = 0; i < 100; i++) { Values.Add(r.Next(0, 10)); } //In this case we are paginating the data only showing the first 25 records //clicking the buttons previous and next changes the page From = 0; To = 25; DataContext = this; }
public BindingLine() { InitializeComponent(); Func<int, DateTime> buildADate = x => { return DateTime.Now + TimeSpan.FromDays(x); }; var tokio = new ChartValues<WeatherDay>() .WithTitle("Tokio") // set a title for the values .Y(day => day.Temperature) //idicate which property to use as Y .AddRange(new[] { new WeatherDay {DateTime = buildADate(-5), Temperature = 15}, new WeatherDay {DateTime = buildADate(-4), Temperature = 18}, new WeatherDay {DateTime = buildADate(-3), Temperature = 20}, new WeatherDay {DateTime = buildADate(-2), Temperature = 25}, new WeatherDay {DateTime = buildADate(-1), Temperature = 22}, new WeatherDay {DateTime = buildADate(0), Temperature = 19} }); var newYork = new ChartValues<WeatherDay>() .WithTitle("New York") .Y(day => day.Temperature) .AddRange(new[] { new WeatherDay {DateTime = buildADate(-5), Temperature = 9}, new WeatherDay {DateTime = buildADate(-4), Temperature = 13}, new WeatherDay {DateTime = buildADate(-3), Temperature = 15}, new WeatherDay {DateTime = buildADate(-2), Temperature = 16}, new WeatherDay {DateTime = buildADate(-1), Temperature = 15}, new WeatherDay {DateTime = buildADate(0), Temperature = 13} }); ViewModel = new WeatherViewModel { Tokio = tokio, NewYork = newYork }; DataContext = this; }
public void EmptyValues() { var vals = new ChartValues<double>(); var barChart = new BarChart { Series = new SeriesCollection { new BarSeries {Values = vals}, new LineSeries {Values = vals} } }; barChart.UnsafeUpdate(); var lineChart = new LineChart { Series = new SeriesCollection { new LineSeries {Values = vals} } }; lineChart.UnsafeUpdate(); var pieChart = new PieChart { Series = new SeriesCollection { new PieSeries {Values = vals} } }; pieChart.UnsafeUpdate(); var stackedChart = new StackedBarChart { Series = new SeriesCollection { new StackedBarSeries {Values = vals} } }; stackedChart.UnsafeUpdate(); }
public GanttExample() { this.InitializeComponent(); var now = DateTime.Now; _values = new ChartValues<GanttPoint> { new GanttPoint(now.Ticks, now.AddDays(2).Ticks), new GanttPoint(now.AddDays(1).Ticks, now.AddDays(3).Ticks), new GanttPoint(now.AddDays(3).Ticks, now.AddDays(5).Ticks), new GanttPoint(now.AddDays(5).Ticks, now.AddDays(8).Ticks), new GanttPoint(now.AddDays(6).Ticks, now.AddDays(10).Ticks), new GanttPoint(now.AddDays(7).Ticks, now.AddDays(14).Ticks), new GanttPoint(now.AddDays(9).Ticks, now.AddDays(12).Ticks), new GanttPoint(now.AddDays(9).Ticks, now.AddDays(14).Ticks), new GanttPoint(now.AddDays(10).Ticks, now.AddDays(11).Ticks), new GanttPoint(now.AddDays(12).Ticks, now.AddDays(16).Ticks), new GanttPoint(now.AddDays(15).Ticks, now.AddDays(17).Ticks), new GanttPoint(now.AddDays(18).Ticks, now.AddDays(19).Ticks) }; Series = new SeriesCollection { new RowSeries { Values = _values, DataLabels = true } }; Formatter = value => new DateTime((long)value).ToString("dd MMM"); var labels = new List<string>(); for (var i = 0; i < 12; i++) labels.Add("Task " + i); Labels = labels.ToArray(); ResetZoomOnClick(null, null); DataContext = this; }
public ConstantChangesChart() { InitializeComponent(); //To handle live data easily, in this case we built a specialized type //the MeasureModel class, it only contains 2 properties //DateTime and Value //We need to configure LiveCharts to handle MeasureModel class //The next code configures MEasureModel globally, this means //that livecharts learns to plot MeasureModel and will use this config every time //a ChartValues instance uses this type. //this code ideally should only run once, when application starts is reccomended. //you can configure series in many ways, learn more at http://lvcharts.net/App/examples/v1/wpf/Types%20and%20Configuration var mapper = Mappers.Xy<MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For<MeasureModel>(mapper); //the values property will store our values array ChartValues = new ChartValues<MeasureModel>(); //lets set how to display the X Labels DateTimeFormatter = value => new DateTime((long)(value)).ToString("mm:ss"); AxisStep = TimeSpan.FromSeconds(1).Ticks; SetAxisLimits(DateTime.Now); //The next code simulates data changes every 300 ms Timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(300) }; Timer.Tick += TimerOnTick; IsDataInjectionRunning = false; R = new Random(); DataContext = this; }
public void MaxEqMinValues() { var vals = new ChartValues<double> {1, 1}; var barChart = new BarChart { Series = new SeriesCollection { new BarSeries {Values = vals}, new LineSeries {Values = vals} } }; barChart.UnsafeRedraw(); var lineChart = new LineChart { Series = new SeriesCollection { new LineSeries {Values = vals} } }; lineChart.UnsafeRedraw(); var pieChart = new PieChart { Series = new SeriesCollection { new PieSeries {Values = vals} } }; pieChart.UnsafeRedraw(); var stackedChart = new StackedBarChart { Series = new SeriesCollection { new StackedBarSeries {Values = vals} } }; stackedChart.UnsafeRedraw(); }
private void AddSeriesOnClick(object sender, RoutedEventArgs e) { //Yes it also listens for series changes var r = new Random(); var c = SeriesCollection[0].Values.Count; var val = new ChartValues<ObservableValue>(); for (int i = 0; i < c; i++) { val.Add(new ObservableValue(r.Next(-20, 20))); } SeriesCollection.Add(new LineSeries { Values = val, StrokeThickness = 4, Fill = new SolidColorBrush(Windows.UI.Colors.Transparent), PointGeometrySize = 0 }); }
public PointState() { InitializeComponent(); var r = new Random(); _values = new ChartValues<ObservableValue> { new ObservableValue(r.Next(10, 400)), new ObservableValue(r.Next(10, 400)), new ObservableValue(r.Next(10, 400)), new ObservableValue(r.Next(10, 400)), new ObservableValue(r.Next(10, 400)), new ObservableValue(r.Next(10, 400)) }; var dangerBrush = new SolidColorBrush(Color.FromRgb(238, 83, 80)); //Lets define a custom mapper, to set fill and stroke //according to chart values... var mapper = Mappers.Xy<ObservableValue>() .X((item, index) => index) .Y(item => item.Value) .Fill(item => item.Value > 200 ? dangerBrush : null) .Stroke(item => item.Value > 200 ? dangerBrush : null); cartesianChart1.Series.Add(new LineSeries { Configuration = mapper, Values = _values, PointGeometrySize = 20, PointForeround = Brushes.White }); cartesianChart1.AxisY.Add(new Axis { LabelFormatter = x => x + " ms" }); }
public DataPaginationExample() { InitializeComponent(); var values = new ChartValues<double>(); var r = new Random(); for (var i = 0; i < 100; i++) { values.Add(r.Next(0, 10)); } cartesianChart1.Series.Add(new LineSeries { Values = values }); cartesianChart1.AxisX.Add(new Axis { MinValue = 0, MaxValue = 25 }); }
/// <summary> /// Get data graphic activity by month with time by source or by genre. /// </summary> /// <param name="year"></param> /// <param name="month"></param> public void getActivityByMonth(int year, int month) { DateTime startOfMonth = new DateTime(year, month, 1, 0, 0, 0); DateTime endOfMonth = new DateTime(year, month, DateTime.DaysInMonth(year, month), 23, 59, 59); JObject activityByMonth = new JObject(); // Total hours by source. if (isMonthSources) { List <GameActivityClass> listGameActivities = GameActivityDatabases.GetListGameActivity(); for (int iGame = 0; iGame < listGameActivities.Count; iGame++) { try { List <Activity> gameActivities = listGameActivities[iGame].Activities; for (int iActivity = 0; iActivity < gameActivities.Count; iActivity++) { long elapsedSeconds = gameActivities[iActivity].ElapsedSeconds; DateTime dateSession = Convert.ToDateTime(gameActivities[iActivity].DateSession).AddSeconds(-elapsedSeconds).ToLocalTime(); string sourceName = gameActivities[iActivity].SourceName; // Cumul data if (activityByMonth[sourceName] != null) { if (startOfMonth <= dateSession && dateSession <= endOfMonth) { activityByMonth[sourceName] = (long)activityByMonth[sourceName] + elapsedSeconds; } } else { if (startOfMonth <= dateSession && dateSession <= endOfMonth) { activityByMonth.Add(new JProperty(sourceName, elapsedSeconds)); } } } } catch (Exception ex) { Common.LogError(ex, "GameActivity", $"Error in getActivityByMonth({year}, {month}) with {listGameActivities[iGame].GameName}"); } } gridMonth.Width = 605; acwSeries.Visibility = Visibility.Visible; acwLabel.Visibility = Visibility.Visible; } // Total hours by genres. else { List <GameActivityClass> listGameActivities = GameActivityDatabases.GetListGameActivity(); for (int iGame = 0; iGame < listGameActivities.Count; iGame++) { try { List <Genre> listGameListGenres = listGameActivities[iGame].Genres; List <Activity> gameActivities = listGameActivities[iGame].Activities; for (int iActivity = 0; iActivity < gameActivities.Count; iActivity++) { long elapsedSeconds = gameActivities[iActivity].ElapsedSeconds; DateTime dateSession = Convert.ToDateTime(gameActivities[iActivity].DateSession).AddSeconds(-elapsedSeconds).ToLocalTime(); for (int iGenre = 0; iGenre < listGameListGenres.Count; iGenre++) { // Cumul data if (activityByMonth[listGameListGenres[iGenre].Name] != null) { if (startOfMonth <= dateSession && dateSession <= endOfMonth) { activityByMonth[listGameListGenres[iGenre].Name] = (long)activityByMonth[listGameListGenres[iGenre].Name] + elapsedSeconds; } } else { if (startOfMonth <= dateSession && dateSession <= endOfMonth) { activityByMonth.Add(new JProperty(listGameListGenres[iGenre].Name, elapsedSeconds)); } } } } } catch (Exception ex) { Common.LogError(ex, "GameActivity", $"Error in getActivityByMonth({year}, {month}) with {listGameActivities[iGame].GameName}"); } } gridMonth.Width = 1223; acwSeries.Visibility = Visibility.Hidden; acwLabel.Visibility = Visibility.Hidden; } // Set data in graphic. ChartValues <CustomerForTime> series = new ChartValues <CustomerForTime>(); string[] labels = new string[activityByMonth.Count]; int compteur = 0; foreach (var item in activityByMonth) { series.Add(new CustomerForTime { Name = item.Key, Values = (long)item.Value, }); labels[compteur] = item.Key; if (settings.showLauncherIcons) { labels[compteur] = TransformIcon.Get(labels[compteur]); } compteur = compteur + 1; } SeriesCollection ActivityByMonthSeries = new SeriesCollection { new ColumnSeries { Title = "", Values = series } }; string[] ActivityByMonthLabels = labels; //let create a mapper so LiveCharts know how to plot our CustomerViewModel class var customerVmMapper = Mappers.Xy <CustomerForTime>() .X((value, index) => index) .Y(value => value.Values); //lets save the mapper globally Charting.For <CustomerForTime>(customerVmMapper); Func <double, string> activityForGameLogFormatter = value => (string)converter.Convert((long)value, null, null, CultureInfo.CurrentCulture); acmLabelsY.LabelFormatter = activityForGameLogFormatter; acmSeries.Series = ActivityByMonthSeries; acmLabelsY.MinValue = 0; ((CustomerToolTipForTime)acmSeries.DataTooltip).ShowIcon = settings.showLauncherIcons; acmLabelsX.Labels = ActivityByMonthLabels; }
public StatisticFreeRooms(DateTime dateFrom, DateTime dateTo) { InitializeComponent(); // // Not so genius code that generate money for the day // double daysBetween = (dateTo - dateFrom).TotalDays; // List<double> randomMoney = new List<double>(); // Random rand = new Random(); // for (int i = 0; i <= daysBetween; i++) // { // randomMoney.Add(rand.Next(0, 33)); // } // // Not so genius code of translate List<double> to CharValues // ChartValues<double> values = new ChartValues<double>(); // for (int i = 0; i < randomMoney.Count; i++) // { // values.Add(randomMoney[i]); // } string connString = "Server=26.146.217.182;Port=3306;Database=hotel;Uid=DoomSlayer;pwd=lilboss;charset=utf8;"; MySqlConnection connect = new MySqlConnection(connString); connect.Open(); int idFrom, idTo; double daysBetween = (dateTo - dateFrom).TotalDays; int[] freeRoomsCount = new int[(int)daysBetween]; for (int i = 0; i < daysBetween; i++) { freeRoomsCount[i] = 0; } ChartValues <double> values = new ChartValues <double>(); int tries = 0; for (int i = 0; i < daysBetween; i++) { DataTable table = new DataTable(); string sql = "select FreeRoomsTotal from hotelhistory where EnterDay=\'" + dateFrom.AddDays(i).ToShortDateString() + "\'"; MySqlDataAdapter sda = new MySqlDataAdapter(sql, connect); sda.Fill(table); freeRoomsCount[i] += Convert.ToInt32(table.Rows[0].ItemArray.GetValue(0).ToString()); } for (int j = 0; j < freeRoomsCount.Length; j++) { values.Add(freeRoomsCount[j]); } connect.Close(); SeriesCollection = new SeriesCollection { new ColumnSeries { Title = "Кол-во свободных комнат.", Values = values } }; // adding series will update and animate the chart automatically // SeriesCollection.Add(new ColumnSeries // { // Title = "2016", // Values = new ChartValues<double> { 11, 56, 42 } // }); // // also adding values updates and animates the chart automatically // SeriesCollection[1].Values.Add(48d); // Genius code that find days between 2 dates (like 01.01.2020) List <string> dateBetween = new List <string>(); for (int i = 0; i <= daysBetween; i++) { dateBetween.Add(dateFrom.AddDays(i).ToString().Remove(10)); } Labels = dateBetween.ToArray(); Formatter = value => value.ToString("N"); DataContext = this; }
public ChartViewModel(CoinViewModel coinVm) { this.Hide = new DelegateCommand(() => { this.IsShow = false; }); _coinVm = coinVm; var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <MeasureModel>(mapper); string DateTimeFormatter(double value) => new DateTime((long)value).ToString("HH:mm"); string SpeedFormatter(double value) => value.ToUnitSpeedText(); //AxisStep forces the distance between each separator in the X axis double axisStep = TimeSpan.FromMinutes(1).Ticks; //AxisUnit forces lets the axis know that we are plotting Minutes //this is not always necessary, but it can prevent wrong labeling double axisUnit = TimeSpan.TicksPerMinute; var axisYSpeed = new Axis() { LabelFormatter = SpeedFormatter, MinValue = 0, Separator = new Separator(), Foreground = SAxisForeground, FontSize = 13, Position = AxisPosition.RightTop }; var axisYOnlineCount = new Axis() { LabelFormatter = value => Math.Round(value, 0) + "miner", Separator = new Separator(), Foreground = SAxisForeground, MinValue = 0, FontSize = 11 }; var axisYShareCount = new Axis() { LabelFormatter = value => Math.Round(value, 0) + "share", Separator = new Separator(), Foreground = SAxisForeground, MinValue = 0, FontSize = 11, Position = AxisPosition.RightTop }; this._axisY = new AxesCollection { axisYOnlineCount, axisYSpeed, axisYShareCount }; DateTime now = DateTime.Now; this._axisX = new AxesCollection() { new Axis() { LabelFormatter = DateTimeFormatter, MaxValue = now.Ticks, MinValue = now.Ticks - TimeSpan.FromMinutes(NTMinerRoot.Current.SpeedHistoryLengthByMinute).Ticks, Unit = axisUnit, Separator = new Separator() { Step = axisStep }, Foreground = SAxisForeground, FontSize = 12, } }; LineSeries mainCoinSpeedLs = new LineSeries { Title = "speed", DataLabels = false, PointGeometrySize = 0, StrokeThickness = 1, ScalesYAt = 1, Values = new ChartValues <MeasureModel>() }; LineSeries onlineCountLs = new LineSeries { Title = "onlineCount", DataLabels = false, PointGeometrySize = 0, StrokeThickness = 1, ScalesYAt = 0, Fill = STransparent, Stroke = OnlineColor, Values = new ChartValues <MeasureModel>() }; LineSeries miningCountLs = new LineSeries { Title = "miningCount", DataLabels = false, PointGeometrySize = 0, StrokeThickness = 1, ScalesYAt = 0, Fill = STransparent, Stroke = MiningColor, Values = new ChartValues <MeasureModel>() }; _rejectValues = new ChartValues <MeasureModel>(); _acceptValues = new ChartValues <MeasureModel>(); StackedColumnSeries rejectScs = new StackedColumnSeries { Title = "rejectShare", Values = _rejectValues, DataLabels = false, ScalesYAt = 2, MaxColumnWidth = 7 }; StackedColumnSeries acceptScs = new StackedColumnSeries { Title = "acceptShare", Values = _acceptValues, DataLabels = false, ScalesYAt = 2, MaxColumnWidth = 7 }; this._series = new SeriesCollection() { mainCoinSpeedLs, rejectScs, acceptScs, miningCountLs, onlineCountLs }; }
private Chart MediaConsumedPerMonth() { var chart = new CartesianChart { DisableAnimations = true }; var animeStats = animeService.GetCustom(a => a.ViewingStatus.Equals(StatusView.VIEWED) && a.DateAdded != null) .GroupBy(a => new { GroupDate = a.DateAdded?.ToString("MMMM yyyy") }) .Select(a => new { Label = a.Key.GroupDate, Items = a.Count() }); var mangaStats = mangaService.GetCustom(a => a.ReadingStatus.Equals(StatusView.READ) && a.DateAdded != null) .GroupBy(a => new { GroupDate = a.DateAdded?.ToString("MMMM yyyy") }) .Select(a => new { Label = a.Key.GroupDate, Items = a.Count() }); var earliestDate = animeStats.Select(aS => aS.Label) .Concat(mangaStats.Select(ms => ms.Label)) .Select(l => DateTime.Parse(l)) .DefaultIfEmpty(DateTime.Now) .Min(); var maxDate = DateTime.Parse(DateTime.Now.ToString("MMMM yyyy")).AddMonths(1); var animes = new ChartValues <double>(); var mangas = new ChartValues <double>(); var labels = new List <string>(); for (var currDate = earliestDate; currDate < maxDate; currDate = currDate.AddMonths(1)) { var currStringDate = currDate.ToString("MMMM yyyy"); animes.Add(animeStats.FirstOrDefault(aS => aS.Label.Equals(currStringDate))?.Items ?? 0); mangas.Add(mangaStats.FirstOrDefault(ms => ms.Label.Equals(currStringDate))?.Items ?? 0); labels.Add(currStringDate); } chart.AxisX.Add(new Axis { Foreground = Brushes.Black, FontSize = 14, Labels = labels, Separator = new Separator { Step = 1 }, LabelsRotation = 45 }); chart.AxisY.Add(new Axis { MinValue = 0, Foreground = Brushes.Black, FontSize = 14 }); chart.Series.Add(new ColumnSeries { Values = animes, Title = "Animes viewed", ColumnPadding = 5 }); chart.MinWidth = labels.Count / 2 * 100; chart.Series.Add(new ColumnSeries { Values = mangas, Title = "Mangas read", ColumnPadding = 5 }); return(chart); }
private void PUPH_Click(object sender, RoutedEventArgs e) { if (a1.IsChecked == true) { // string F = Func.Text; double a = Convert.ToDouble(TA.Text); double b = Convert.ToDouble(TB.Text); int n = Convert.ToInt32(Num.Text); double[] x = new double[n]; double[] y = new double[n]; double[] dy = new double[n]; double[] yt = new double[n]; double[] ye = new double[n]; double h = (b - a) / (n - 1); x[0] = a; y[0] = a; for (int i = 1; i < n; i++) { x[i] = x[i - 1] + h; //y[i] = f(x[i]); } //y[0] = a; List <tabl> tabls = new List <tabl>(n); //tabls.Add(new tabl(x[0], y[0] - h * f(x[i - 1], y[i - 1]), h * f(x[i - 1], y[i - 1]), ft(x[i]), ft(x[i] - y[0] - h * f(x[i - 1], y[i - 1])) for (int i = 0; i < n; i++) { if (i == 0) { dy[i] = a; y[i] = a; yt[i] = a; ye[i] = a; } else { dy[i] = h * f(x[i - 1], y[i - 1]); y[i] = y[i - 1] + dy[i]; yt[i] = ft(x[i]); ye[i] = yt[i] - y[i]; } tabls.Add(new tabl(x[i], y[i], dy[i], yt[i], ye[i])); } List <XY> FU = new List <XY>(n); for (int i = 0; i < n; i++) { FU.Add(new XY(x[i], y[i])); } Tabl.ItemsSource = FU; vidp.ItemsSource = tabls; //-------------------------------график--------------- DataContext = null; MyValues = new ChartValues <ObservablePoint>(); MyValuesT = new ChartValues <ObservablePoint>(); for (int i = 0; i < n; i++) { MyValues.Add(new ObservablePoint(x[i], y[i])); MyValuesT.Add(new ObservablePoint(x[i], yt[i])); } var lineSeries = new LineSeries { Values = MyValues, StrokeThickness = 2, Fill = Brushes.Transparent, Title = "шукана", //PointGeometrySize = 10, //PointGeometry = DefaultGeometries.Circle, DataLabels = false, }; var lineSeries2 = new LineSeries { Values = MyValuesT, StrokeThickness = 2, Fill = Brushes.Transparent, Title = "уточнена", //PointGeometrySize = 10, //PointGeometry = DefaultGeometries.Circle, DataLabels = false, }; SeriesCollection = new SeriesCollection { lineSeries, lineSeries2 }; DataContext = this; } else if (a2.IsChecked == true) { // string F = Func.Text; double a = Convert.ToDouble(TA.Text); double b = Convert.ToDouble(TB.Text); int n = Convert.ToInt32(Num.Text); double[] x = new double[n]; double[] y = new double[n]; double[] yp = new double[n]; double[] dy = new double[n]; double[] yt = new double[n]; double[] ye = new double[n]; double h = (b - a) / (n - 1); x[0] = a; y[0] = a; for (int i = 1; i < n; i++) { x[i] = x[i - 1] + h; //y[i] = f(x[i]); } //y[0] = a; List <tabl> tabls = new List <tabl>(n); //tabls.Add(new tabl(x[0], y[0] - h * f(x[i - 1], y[i - 1]), h * f(x[i - 1], y[i - 1]), ft(x[i]), ft(x[i] - y[0] - h * f(x[i - 1], y[i - 1])) for (int i = 0; i < n; i++) { if (i == 0) { dy[i] = a; y[i] = a; yt[i] = a; ye[i] = a; yp[i] = a; } else { dy[i] = h * f(x[i - 1], y[i - 1]); y[i] = y[i - 1] + dy[i]; yp[i] = y[i - 1] + h * f(x[i], y[i]); y[i] = yp[i]; yt[i] = ft(x[i]); ye[i] = yt[i] - y[i]; } tabls.Add(new tabl(x[i], y[i], dy[i], yt[i], ye[i])); } List <XY> FU = new List <XY>(n); for (int i = 0; i < n; i++) { FU.Add(new XY(x[i], y[i])); } Tabl.ItemsSource = FU; vidp.ItemsSource = tabls; //-------------------------------график--------------- DataContext = null; MyValues = new ChartValues <ObservablePoint>(); MyValuesT = new ChartValues <ObservablePoint>(); for (int i = 0; i < n; i++) { MyValues.Add(new ObservablePoint(x[i], y[i])); MyValuesT.Add(new ObservablePoint(x[i], yt[i])); } var lineSeries = new LineSeries { Values = MyValues, StrokeThickness = 2, Fill = Brushes.Transparent, Title = "шукана", //PointGeometrySize = 10, //PointGeometry = DefaultGeometries.Circle, DataLabels = false, }; var lineSeries2 = new LineSeries { Values = MyValuesT, StrokeThickness = 2, Fill = Brushes.Transparent, Title = "уточнена", //PointGeometrySize = 10, //PointGeometry = DefaultGeometries.Circle, DataLabels = false, }; SeriesCollection = new SeriesCollection { lineSeries, lineSeries2 }; DataContext = this; } else { double a = Convert.ToDouble(TA.Text); double b = Convert.ToDouble(TB.Text); int n = Convert.ToInt32(Num.Text); double[] x = new double[n]; double[] y = new double[n]; double[] yp = new double[n]; double[] dy = new double[n]; double[] yt = new double[n]; double[] ye = new double[n]; double h = (b - a) / (n - 1); x[0] = a; y[0] = a; for (int i = 1; i < n; i++) { x[i] = x[i - 1] + h; //y[i] = f(x[i]); } //y[0] = a; List <tabl> tabls = new List <tabl>(n); //tabls.Add(new tabl(x[0], y[0] - h * f(x[i - 1], y[i - 1]), h * f(x[i - 1], y[i - 1]), ft(x[i]), ft(x[i] - y[0] - h * f(x[i - 1], y[i - 1])) for (int i = 0; i < n; i++) { if (i == 0) { dy[i] = a; y[i] = a; yt[i] = a; ye[i] = a; yt[i] = a; } else { dy[i] = h * f(x[i - 1], y[i - 1]); y[i] = y[i - 1] + dy[i]; yp[i] = y[i - 1] + (h / 2) * (f(x[i - 1], y[i - 1]) + f(x[i], y[i])); y[i] = yp[i]; yt[i] = ft(x[i]); ye[i] = yt[i] - y[i]; } tabls.Add(new tabl(x[i], y[i], dy[i], yt[i], ye[i])); } List <XY> FU = new List <XY>(n); for (int i = 0; i < n; i++) { FU.Add(new XY(x[i], y[i])); } Tabl.ItemsSource = FU; vidp.ItemsSource = tabls; DataContext = null; MyValues = new ChartValues <ObservablePoint>(); MyValuesT = new ChartValues <ObservablePoint>(); for (int i = 0; i < n; i++) { MyValues.Add(new ObservablePoint(x[i], y[i])); MyValuesT.Add(new ObservablePoint(x[i], yt[i])); } var lineSeries = new LineSeries { Values = MyValues, StrokeThickness = 2, Fill = Brushes.Transparent, Title = "шукана", //PointGeometrySize = 10, //PointGeometry = DefaultGeometries.Circle, DataLabels = false, }; var lineSeries2 = new LineSeries { Values = MyValuesT, StrokeThickness = 2, Fill = Brushes.Transparent, Title = "уточнена", //PointGeometrySize = 10, //PointGeometry = DefaultGeometries.Circle, DataLabels = false, }; SeriesCollection = new SeriesCollection { lineSeries, lineSeries2 }; DataContext = this; } }
public void GetActivityForGamesLogGraphics(GameActivityClass gameActivity, bool withTitle, string dateSelected = "") { List <ActivityDetailsData> gameActivitiesDetails = gameActivity.GetSessionActivityDetails(dateSelected); string[] activityForGameLogLabels = new string[0]; List <ActivityDetailsData> gameLogsDefinitive = new List <ActivityDetailsData>(); if (gameActivitiesDetails.Count > 0) { if (gameActivitiesDetails.Count > 10) { // Variateur int conteurEnd = gameActivitiesDetails.Count + variateurLog; int conteurStart = conteurEnd - 10; if (conteurEnd > gameActivitiesDetails.Count) { int temp = conteurEnd - gameActivitiesDetails.Count; conteurEnd = gameActivitiesDetails.Count; conteurStart = conteurEnd - 10; variateurLog = variateurLogTemp; } if (conteurStart < 0) { conteurStart = 0; conteurEnd = 10; variateurLog = variateurLogTemp; } variateurLogTemp = variateurLog; // Create data int sCount = 0; activityForGameLogLabels = new string[10]; for (int iLog = conteurStart; iLog < conteurEnd; iLog++) { gameLogsDefinitive.Add(gameActivitiesDetails[iLog]); activityForGameLogLabels[sCount] = Convert.ToDateTime(gameActivitiesDetails[iLog].Datelog).ToLocalTime().ToString(Playnite.Common.Constants.TimeUiFormat); sCount += 1; } } else { gameLogsDefinitive = gameActivitiesDetails; activityForGameLogLabels = new string[gameActivitiesDetails.Count]; for (int iLog = 0; iLog < gameActivitiesDetails.Count; iLog++) { activityForGameLogLabels[iLog] = Convert.ToDateTime(gameActivitiesDetails[iLog].Datelog).ToLocalTime().ToString(Playnite.Common.Constants.TimeUiFormat); } } } // Set data in graphic. ChartValues <int> CPUseries = new ChartValues <int>(); ChartValues <int> GPUseries = new ChartValues <int>(); ChartValues <int> RAMseries = new ChartValues <int>(); ChartValues <int> FPSseries = new ChartValues <int>(); for (int iLog = 0; iLog < gameLogsDefinitive.Count; iLog++) { CPUseries.Add(gameLogsDefinitive[iLog].CPU); GPUseries.Add(gameLogsDefinitive[iLog].GPU); RAMseries.Add(gameLogsDefinitive[iLog].RAM); FPSseries.Add(gameLogsDefinitive[iLog].FPS); } SeriesCollection activityForGameLogSeries = new SeriesCollection { new ColumnSeries { Title = "cpu usage (%)", Values = CPUseries }, new ColumnSeries { Title = "gpu usage (%)", Values = GPUseries }, new ColumnSeries { Title = "ram usage (%)", Values = RAMseries }, new LineSeries { Title = "fps", Values = FPSseries } }; Func <double, string> activityForGameLogFormatter = value => value.ToString("N"); gameSeriesLog.DataTooltip = new LiveCharts.Wpf.DefaultTooltip(); gameSeriesLog.DataTooltip.Background = (Brush)resources.GetResource("CommonToolTipBackgroundBrush"); gameSeriesLog.DataTooltip.Padding = new Thickness(10); gameSeriesLog.DataTooltip.BorderThickness = (Thickness)resources.GetResource("CommonToolTipBorderThickness"); gameSeriesLog.DataTooltip.BorderBrush = (Brush)resources.GetResource("CommonToolTipBorderBrush"); gameSeriesLog.DataTooltip.Foreground = (Brush)resources.GetResource("CommonToolTipForeground"); gameSeriesLog.Series = activityForGameLogSeries; gameLabelsY.MinValue = 0; gameLabelsX.Labels = activityForGameLogLabels; gameLabelsY.LabelFormatter = activityForGameLogFormatter; if (withTitle) { lGameSeriesLog.Visibility = Visibility.Visible; lGameSeriesLog.Content = resources.GetString("LOCGameActivityLogTitleDate") + " " + ((DateTime)gameActivitiesDetails[0].Datelog).ToString(Playnite.Common.Constants.DateUiFormat); } }
private void init(int id) { localDbConnection.Open(); localDbConnectionUnity.Open(); SqlCommand commandToGetInfo = new SqlCommand("SELECT * FROM dbo.getInformationForReportGraphics(@id)", localDbConnection); commandToGetInfo.Parameters.AddWithValue("@id", id); SqlDataAdapter dataAdapterInfo = new SqlDataAdapter(commandToGetInfo); DataTable dataTableInfo = new DataTable(); dataAdapterInfo.Fill(dataTableInfo); deviceName.Content = dataTableInfo.Rows[0][0].ToString(); operatorName.Content = dataTableInfo.Rows[0][1].ToString(); companyName.Content = dataTableInfo.Rows[0][2].ToString(); productName.Content = dataTableInfo.Rows[0][3].ToString(); projectName.Content = dataTableInfo.Rows[0][4].ToString(); db = dataTableInfo.Rows[0][5].ToString(); deviceType = int.Parse(dataTableInfo.Rows[0][6].ToString()); if (localDbConnection.State == ConnectionState.Closed) { localDbConnection.Open(); } SeriesCollection = new SeriesCollection(); ChartValues <double> diameterList = new ChartValues <double>(); ChartValues <double> diameterSetList = new ChartValues <double>(); ChartValues <double> plusToleranceList = new ChartValues <double>(); ChartValues <double> minusToleranceList = new ChartValues <double>(); string query = String.Format("SELECT * FROM {0}", db); SqlCommand command = new SqlCommand(query, localDbConnection); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { diameterList.Add(double.Parse(reader[1].ToString())); diameterSetList.Add(double.Parse(reader[2].ToString())); plusToleranceList.Add(double.Parse(reader[4].ToString())); minusToleranceList.Add(double.Parse(reader[5].ToString())); i++; } SeriesCollection.Add(new LineSeries { Title = rm.GetString("diameter"), Values = diameterList, PointGeometry = null }); SeriesCollection.Add(new LineSeries { Title = rm.GetString("diameterSet"), Values = diameterSetList, PointGeometry = null }); SeriesCollection.Add(new LineSeries { Title = rm.GetString("plusTolerance"), Values = plusToleranceList, PointGeometry = null }); SeriesCollection.Add(new LineSeries { Title = rm.GetString("minusTolerance"), Values = minusToleranceList, PointGeometry = null }); labelTime.Content = i.ToString(); DataContext = this; localDbConnection.Close(); localDbConnectionUnity.Close(); }
private void btnadd_Click(object sender, RoutedEventArgs e) { var r = new Random(); ChartValues.AddRange(Enumerable.Range(counter, 20).Select(x => ( double )(x + r.Next(0, 50)))); }
private void DrawLine() { bool preData = true; double trueDataNum = 0; double preDataNum = 0; if (measureModels.Count > 0) { Action <DateTime> AsyncUIDelegate1 = delegate(DateTime now) { cartesianChart1.AxisX[0].MaxValue = now.Ticks + TimeSpan.FromSeconds(1).Ticks; // lets force the axis to be 100ms ahead cartesianChart1.AxisX[0].MinValue = now.Ticks - TimeSpan.FromSeconds(19).Ticks; //we only care about the last 8 seconds }; //定义一个委托,用于修改坐标轴1 Action <DateTime> AsyncUIDelegate2 = delegate(DateTime now) { cartesianChart2.AxisX[0].MaxValue = now.Ticks + TimeSpan.FromSeconds(1).Ticks; // lets force the axis to be 100ms ahead cartesianChart2.AxisX[0].MinValue = now.Ticks - TimeSpan.FromSeconds(19).Ticks; //we only care about the last 8 seconds }; //定义一个委托,用于修改坐标轴2 Action <String> AsyncUIDelegate3 = delegate(String data) { textBox1.Clear(); textBox1.AppendText(data); };//定义一个委托,用于设置准确率 Action <String> AsyncUIDelegate4 = delegate(String data) { textBox2.Clear(); textBox2.AppendText(data); };//定义一个委托,用于设置灰色系统预测参数A0 Action <String> AsyncUIDelegate5 = delegate(String data) { textBox3.Clear(); textBox3.AppendText(data); };//定义一个委托,用于设置灰色系统预测参数A1 Action <String> AsyncUIDelegate6 = delegate(String data) { textBox4.Clear(); textBox4.AppendText(data); };//定义一个委托,用于设置灰色系统预测参数A2 try { cartesianChart1.Invoke(AsyncUIDelegate1, new object[] { measureModels.Last().DateTime }); // 添加异常声明,进行处理 } catch (Exception) { } foreach (MeasureModel mm in measureModels) { ChartValues.Add(mm); trueDataNum = mm.Value; if (ChartValues.Count > 20) { ChartValues.RemoveAt(0); } } if (graymodel.GetSize() == 30) { if (ChartPredictionValues.Count > 0) { for (int i = 0; i < 6; i++) { ChartPredictionValues.RemoveAt(ChartPredictionValues.Count - 1); } } foreach (MeasureModel mm in graymodel.PredictMeaseureModelRange(7)) { if (preData) { preDataNum = mm.Value; preData = false; } ChartPredictionValues.Add(mm); } try { cartesianChart2.Invoke(AsyncUIDelegate2, new object[] { ChartPredictionValues.Last().DateTime }); } catch (Exception) { } } try { double precent = Math.Abs(trueDataNum - preDataNum) / trueDataNum; precent = precent * 100; textBox1.Invoke(AsyncUIDelegate3, new object[] { precent.ToString("F2") + " %" }); textBox2.Invoke(AsyncUIDelegate4, new object[] { graymodel.Geta0().ToString("F2") }); textBox3.Invoke(AsyncUIDelegate5, new object[] { graymodel.Geta1().ToString("F2") }); textBox4.Invoke(AsyncUIDelegate6, new object[] { graymodel.Geta2().ToString("F2") }); } catch (Exception) { } measureModels.Clear(); preData = true; } }
private void ShowChart() { var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <MeasureModel>(mapper); //the ChartValues property will store our values array ChartValues = new ChartValues <MeasureModel>(); ChartPredictionValues = new ChartValues <MeasureModel>(); cartesianChart1.Series = new SeriesCollection { new LineSeries { Title = "观测值", Values = ChartValues, PointGeometrySize = 18, StrokeThickness = 3, Stroke = System.Windows.Media.Brushes.ForestGreen, }, }; cartesianChart2.Series = new SeriesCollection { new LineSeries { Title = "预测值", Values = ChartPredictionValues, PointGeometrySize = 18, StrokeThickness = 3, Stroke = System.Windows.Media.Brushes.ForestGreen, }, }; cartesianChart1.AxisX.Add(new Axis { DisableAnimations = true, Title = "Time", LabelFormatter = value => new System.DateTime((long)value).ToString("mm:ss"), Separator = new Separator { Step = TimeSpan.FromSeconds(1).Ticks } }); cartesianChart1.LegendLocation = LegendLocation.Right; cartesianChart2.AxisX.Add(new Axis { DisableAnimations = true, Title = "Time", LabelFormatter = value => new System.DateTime((long)value).ToString("mm:ss"), Separator = new Separator { Step = TimeSpan.FromSeconds(1).Ticks } }); cartesianChart2.LegendLocation = LegendLocation.Right; SetAxisLimits(System.DateTime.Now); thread = new Thread(new ThreadStart(ShowData)); thread.IsBackground = true; thread.Start(); // 设置线程启动,完成对于数据的监控处理 }
public static Tuple <double, double> GradientDescent(double[,] data, double thetaOne, double thetaTwo, ChartValues <ObservablePoint> hypothesis, double interations) { Debug.OutPut("--- INITIAL ---" + thetaOne + " " + thetaTwo); double m = data.GetLength(0); int count = 0; while (count < interations) { double sumOne = 0; double sumTwo = 0; for (int i = 0; i < m; i++) { Point currentPoint = new Point(data[i, 0], data[i, 1]); double modelValue = SolveRegressionModel(currentPoint.X, thetaOne, thetaTwo); sumOne += modelValue - currentPoint.Y; } double tempThetaOne = thetaOne - LeariningRate * (1 / m) * sumOne; for (int i = 0; i < m; i++) { Point currentPoint = new Point(data[i, 0], data[i, 1]); double modelValue = SolveRegressionModel(currentPoint.X, thetaOne, thetaTwo); sumTwo += (modelValue - currentPoint.Y) * currentPoint.X; } double tempThetaTwo = thetaTwo - LeariningRate * (1 / m) * sumTwo; thetaOne = tempThetaOne; thetaTwo = tempThetaTwo; Debug.OutPut("Iter: " + count + " T0: " + thetaOne + " T1: " + thetaTwo); count++; if (count % 10 == 0) { // Add for first var x = 0; var y = thetaOne + thetaTwo * x; var a = new ObservablePoint(x, y); x = 20; y = thetaOne + thetaTwo * x; var b = new ObservablePoint(x, y); hypothesis.Clear(); hypothesis.Add(a); hypothesis.Add(b); } } return(new Tuple <double, double>(thetaOne, thetaTwo)); }
private void btn_CacThang_Click(object sender, EventArgs e) { lbl_Nam.Visible = false; cmb_Nam.Visible = false; ClearChart(); var list = from p in Cons.dataContext.Receipts group p by p.receiptdate.Value.Year into g select new { Nam = g.FirstOrDefault().receiptdate.Value.Year, toTal = g.Sum(x => x.total) }; dataGridView1.DataSource = list; //lấy ra năm và số lượng bệnh nhân điều trị. Axis axis = new Axis() { Title = "BIỂU ĐỒ BIẾN ĐỘNG NĂM", FontSize = 15, IsMerged = true, Separator = new Separator { StrokeThickness = 1, StrokeDashArray = new System.Windows.Media.DoubleCollection(2), Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(64, 79, 86)) } }; //dataGridView1.Visible = false; List <string> temp = new List <string>(); foreach (var item in list.ToList()) { temp.Add(item.Nam.ToString()); } axis.Labels = temp; cartesianChart_DoanhThu.AxisX.Add(axis); // vẽ biểu đồ. LineSeries lineSeries = new LineSeries() { Title = "Tổng doanh thu: ", //Values = new ChartValues<double> { 14, 16, 13, 12, 16 }, StrokeThickness = 4, StrokeDashArray = new System.Windows.Media.DoubleCollection(20), Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(93, 12, 123)), LineSmoothness = 0, PointGeometry = null }; ChartValues <double> ts = new ChartValues <double>(); foreach (var item in list.ToList()) { ts.Add(double.Parse(item.toTal.ToString())); } lineSeries.Values = ts; cartesianChart_DoanhThu.Series.Add(lineSeries); }
/// <summary> /// Creates a line chart for balance /// </summary> public void SetLineChart() { BalanceViewModel.LineChart.SeriesCollection = new SeriesCollection(); List <FilterGroupData> labelData = GetFilterGroupData(); using (var db = new DataModel()) { var allTransaction = db.Transactions .Include(t => t.Categories.CategoryDirections) .Where(t => t.AccountID == MainViewModel.CurrentAccount.AccountID && t.TransactionDate >= CurrentFilter.StartDate && t.TransactionDate <= CurrentFilter.EndDate) .ToList(); var startingTransactions = db.Transactions .Include(t => t.Categories.CategoryDirections) .Where(t => t.AccountID == MainViewModel.CurrentAccount.AccountID && t.TransactionDate < CurrentFilter.StartDate) .ToList(); decimal balance = MainViewModel.CurrentAccount.StartBalance; foreach (var transaction in startingTransactions) { if (transaction.Categories.CategoryDirections.DirectionName == "Kiadás") { balance -= transaction.Amount; } else { balance += transaction.Amount; } } var balanceValues = new ChartValues <double>(); foreach (var period in labelData) { var expenseAmount = allTransaction.Where(t => t.TransactionDate >= period.StartDate && t.TransactionDate <= period.EndDate && t.Categories.CategoryDirections.DirectionName == "Kiadás") .Sum(t => t.Amount); var incomeAmount = allTransaction.Where(t => t.TransactionDate >= period.StartDate && t.TransactionDate <= period.EndDate && t.Categories.CategoryDirections.DirectionName == "Bevétel") .Sum(t => t.Amount); balance += incomeAmount - expenseAmount; balanceValues.Add((double)balance); } var series = new List <Series>(); series.Add(new StepLineSeries { Title = MainViewModel.CurrentAccount.AccountName, Values = balanceValues }); BalanceViewModel.LineChart.SeriesCollection.AddRange(series); BalanceViewModel.LineChart.Labels = new string[labelData.Count]; int cycleCounter = 0; foreach (var label in labelData) { BalanceViewModel.LineChart.Labels[cycleCounter] = label.Name; cycleCounter++; } } }
public ActionResult Index() { StatisticsViewModel ViewModel = new StatisticsViewModel(); var products = context.Products; var statuses = context.OrderStatuses; var values = new ChartValues(); var values2 = new ChartValues(); var values3 = new ChartValues(); //charts foreach (var product in products) { var count = context.OrderItems.Where(o => o.Name == product.Name).Count(); values.xValues.Add(product.Name); values.yValues.Add(count.ToString()); System.Diagnostics.Debug.WriteLine(product.Name + " " + count); } foreach (var status in statuses) { var count = context.Orders.Where(o => o.OrderStatusId == status.OrderStatusId).Count(); values2.xValues.Add(status.Name); values2.yValues.Add(count.ToString()); } //orders ViewModel.Orders_total = context.Orders.Count(); if (ViewModel.Orders_total > 0) { ViewModel.Orders_totalPrice = context.Orders.Sum(o => o.Total); } else { ViewModel.Orders_totalPrice = 0; } ViewModel.Orders_notComplete = context.Orders.Where(o => !o.OrderStatus.Name.Equals("Complete")).Count(); ViewModel.Orders_complete = context.Orders.Where(o => o.OrderStatus.Name.Equals("Complete")).Count(); ViewModel.Orders_total_thisMonth = context.Orders.Where(o => o.DateAdded.Month == DateTime.Now.Month).Count(); if (ViewModel.Orders_total_thisMonth > 0) { ViewModel.Orders_totalPrice_thisMonth = context.Orders.ToList().Where(o => o.DateAdded.Month == DateTime.Now.Month).Sum(o => o.Total); } else { ViewModel.Orders_totalPrice_thisMonth = 0; } ViewModel.Orders_totalCosts = context.Orders.ToList().Sum(o => o.Costs); if (ViewModel.Orders_total_thisMonth > 0) { ViewModel.Orders_totalCostsThisMonth = context.Orders.ToList().Where(o => o.DateAdded.Month == DateTime.Now.Month).Sum(o => o.Costs); } else { ViewModel.Orders_totalCostsThisMonth = 0; } ViewModel.Orders_totalProfit = context.Orders.ToList().Sum(o => o.Profit); if (ViewModel.Orders_total_thisMonth > 0) { ViewModel.Orders_totalProfitThisMonth = context.Orders.ToList().Where(o => o.DateAdded.Month == DateTime.Now.Month).Sum(o => o.Profit); } else { ViewModel.Orders_totalCostsThisMonth = 0; } //Products ViewModel.Products_total = products.Count(); ViewModel.Products_total_sold = context.OrderItems.Count(); if (ViewModel.Orders_complete > 0) { ViewModel.Products_total_sold_price = context.OrderItems.Where(oi => oi.Order.OrderStatus.Name.Equals("Complete")).Sum(oi => oi.Total); } else { ViewModel.Products_total_sold_price = 0; } //Routes ViewModel.Routes_total = context.Routes.Count(); ViewModel.Routes_planed = context.Routes.Where(r => r.Status.Name.Equals("Pending To Delivery")).Count(); ViewModel.Routes_onTheWay = context.Routes.Where(r => r.Status.Name.Equals("On The Way")).Count(); ViewModel.Routes_complete = context.Routes.Where(r => r.Status.Name.Equals("Complete")).Count(); ViewModel.Routes_totalDistance = ViewModel.Routes_complete == 0 ? 0 : context.Routes.Where(r => r.Status.Name.Equals("Complete")).Sum(r => r.Distance) / 1000; ViewModel.Routes_totalTime = ViewModel.Routes_complete == 0 ? 0 : context.Routes.Where(r => r.Status.Name.Equals("Complete")).Sum(r => r.Duration) / 3600; ViewModel.Routes_total_thisMonth = ViewModel.Routes_complete == 0 ? 0 : context.Routes.Where(r => r.DateAdded.Month == DateTime.Now.Month && r.Status.Name.Equals("Complete")).Count(); ViewModel.Routes_total_distance_thisMonth = ViewModel.Routes_complete == 0 ? 0 : context.Routes.Where(r => r.Status.Name.Equals("Complete")).Sum(r => r.Distance) / 1000; ViewModel.Routes_total_time_thisMonth = ViewModel.Routes_complete == 0 ? 0 : context.Routes.Where(r => r.Status.Name.Equals("Complete")).Sum(r => r.Duration) / 3600; ViewModel.Routes_Costs = ViewModel.Routes_complete == 0 ? 0 : context.Routes.Where(r => r.Status.Name.Equals("Complete")).ToList().Sum(r => r.TotalCosts); ViewModel.Route_CostsThisMonth = ViewModel.Routes_complete == 0 ? 0 : context.Routes.Where(r => r.Status.Name.Equals("Complete") && r.DateAdded.Month == DateTime.Now.Month).ToList().Sum(r => r.TotalCosts); ViewModel.cars = context.Cars.ToList(); ViewModel.values.Add("QuickProduct", values); ViewModel.values.Add("QuickOrder", values2); TempData["statistics"] = ViewModel.values; return(View(ViewModel)); }
/// <summary> /// This method generates the chart /// </summary> private void Read() { while (IsReading) { measurements = new List <DTO_Measurement>(); //Receive measurement data measurements = controller.GetMeasurementData(); try { foreach (DTO_Measurement data in measurements) { if (data.mmHg > 1) { ChartValues.Add(new MeasurementModel { Time = data.Tid, RawData = data.mmHg }); } //SetAxisLimits(DateTime.Now); SetAxisLimits(data.Tid); //Only use the last 800 values if (ChartValues.Count > 800) { ChartValues.RemoveAt(0); } //Update pulse, systolic, diastolic and mean this.Dispatcher.Invoke(() => { if (data.CalculatedPulse > 1) { Puls_L.Content = Convert.ToString(data.CalculatedPulse); } if (data.CalculatedSys > 1) { SysDia_L.Content = Convert.ToString(data.CalculatedSys) + "/" + Convert.ToString(data.CalculatedDia); } if (data.CalculatedMean > 1) { Mean_L.Content = Convert.ToString(data.CalculatedMean); } if (data.CalculatedMean > 1) { BatteryStatus_L.Content = "Batteristatus: " + Convert.ToString(data.Batterystatus) + "%"; } //Calling alarm method Alarm(); }); } } catch (InvalidExpressionException) { } } }
private async void Search_Click(object sender, RoutedEventArgs e) { db = new ApplicationContext(); List <TradeTransaction> tradeTransactions = new List <TradeTransaction>(); List <TradeTransaction> list = db.TradeTransactions.ToList(); //tradeTransactions.Add(new TradeTransaction()); month = monthList.Text; year = yearsList.Text; await Task.Run(() => { list = db.TradeTransactions.ToList(); int sum = 0; bool locked = true; for (int j = 1; j <= 31; j++) { locked = true; foreach (var i in list) { if (i.Day == j && i.Month.ToString() == month && i.Year.ToString() == year) { tradeTransactions.Add(i); locked = false; } } if (locked) { tradeTransactions.Add(new TradeTransaction() { Amount = int.MinValue, Day = j, Month = Convert.ToInt32(month) }); } } //size проверочный день //sum это переменная через которую прогоняем сумму //cost запоминает сколько повторяющихся дней //IdSave запоминает индекс первого попавшегося дня //locker блокирует idSave int size = 1, cost = 0, idSave = 0, locker = 0; List <TradeTransaction> listRemove = new List <TradeTransaction>(); while (size <= 31) { cost = 0; locker = 0; idSave = 0; for (int i = 0; i < tradeTransactions.Count; i++) { if (tradeTransactions[i].Day == size) { if (locker == 0) { idSave = i; locker = -1; } if (tradeTransactions[i].Amount == int.MinValue) { tradeTransactions[i].Amount = sum; } else { sum += tradeTransactions[i].Amount; } tradeTransactions[idSave].Amount = sum; if (cost != 0) { listRemove.Add(tradeTransactions[i]); } cost++; } } //if (cost == 0) //{ // tradeTransactions.Add(new TradeTransaction() { Amount = sum, Day = size, Month = Convert.ToInt32(month) }); //} size++; } //Удаление ненужных элементов foreach (var i in listRemove) { tradeTransactions.Remove(i); } }); ChartValues <int> result = new ChartValues <int>(); foreach (var i in tradeTransactions) { result.Add(i.Amount); } Values2 = result; PerformanceWindow performanceWindow = new PerformanceWindow(Values2); performanceWindow.Show(); Close(); }
private void Application_Startup(object sender, StartupEventArgs e) { Func <double, double> function = null; { int funSelection = 0; bool isParsable = false; bool isBetween = false; do { Console.WriteLine("Wybierz wariant funkcji do całkowania:"); Console.WriteLine("(1). f(x) = 4x^4 -2x^3 + 4x^2 -4x +1 "); Console.WriteLine("(2). f(x) = 4sin(2x) "); Console.WriteLine("(3). f(x) = 2|x^3|"); isParsable = Int32.TryParse(Console.ReadLine(), out funSelection); isBetween = funSelection.IsBetween(1, 3); } while (!(isParsable && isBetween)); switch (funSelection) { case 1: function = Example.Polynomial; break; case 2: function = Example.Sinus; break; case 3: function = Example.Absolute; break; } } double a, b; { bool isNumber = false; bool isCorrect = false; do { Console.WriteLine("Określ przedziały całkowania:"); Console.Write("a:"); isNumber = double.TryParse(Console.ReadLine(), NumberStyles.Any, CultureInfo.InvariantCulture, out a); Console.Write("b:"); isNumber = double.TryParse(Console.ReadLine(), NumberStyles.Any, CultureInfo.InvariantCulture, out b); isCorrect = a < b; } while (!isNumber || !isCorrect); } int polynomialDegree; { bool isDegreeCorrect = false; do { Console.Write("Określ stopień wielomianu aproksymującego: "); isDegreeCorrect = int.TryParse(Console.ReadLine(), out polynomialDegree); } while (!isDegreeCorrect); } /// /// oblicanie funkcji aproksymującej /// HermitePolynomials hermites = new HermitePolynomials(); double[] factors = new double[polynomialDegree + 1]; for (int i = 0; i <= polynomialDegree; i++) { double fun(double x) { return(function(x) * hermites[i](x)); } double integral = new Gauss_Hermite(fun, 0.00001).GetResult(); factors[i] = integral / (Math.Pow(2, i) * MathExtensions.Factorial(i) * Math.Sqrt(Math.PI)); } Approximation approximationResult = new Approximation(factors, hermites, polynomialDegree); Func <double, double> approximatedFunction = approximationResult.GetResult(); /// end /// ChartValues <ObservablePoint> functionPoints = new ChartValues <ObservablePoint>(); ChartValues <ObservablePoint> approximatedFunctionPoints = new ChartValues <ObservablePoint>(); for (double i = a; i <= b; i++) { functionPoints.Add(new ObservablePoint(i, function(i))); // wypełnianie listy wartościami (x,y) approximatedFunctionPoints.Add(new ObservablePoint(i, approximatedFunction(i))); } MainWindow window = new MainWindow(); window.Plot.FunctionValues = functionPoints; window.Plot.ApproximatedFunctionValues = approximatedFunctionPoints; window.Plot.Update(); // rysowanie wykresu window.Show(); }
public GraphUC(string name) { user = name; InitializeComponent(); SqlConnection connection = new SqlConnection(strconnect); connection.Open(); #region string count = " select COUNT(data_entry) from Трекервеса where name_us=@user"; SqlCommand sq = new SqlCommand(count, connection); sq.Parameters.Add("@user", SqlDbType.NVarChar).Value = user; object v = sq.ExecuteScalar(); int counter = Convert.ToInt16(v.ToString()); if (counter != 0) { string sel = "select data_entry,weight_us from Трекервеса where name_us=@user order by data_entry"; SqlCommand com = new SqlCommand(sel, connection); com.Parameters.Add("@user", SqlDbType.NVarChar).Value = user; SqlDataReader reader = com.ExecuteReader(); List <string> dates = new List <string>(); List <Double> weights = new List <Double>(); DataTable dt = new DataTable(); dt.Load(reader); for (int i = 0; i < counter; i++) { DataRow drow = dt.Rows[i]; DateTime values = drow.Field <DateTime>("data_entry"); Double w = drow.Field <Double>("weight_us"); dates.Add(values.ToShortDateString()); weights.Add(w); } reader.Close(); ChartValues <Double> vs = new ChartValues <Double>(); foreach (Double k in weights) { vs.Add(Convert.ToDouble(k)); } SeriesCollection = new SeriesCollection { new LineSeries { Title = "Ваш вес", Values = vs, PointGeometry = DefaultGeometries.Circle, PointGeometrySize = 10, Stroke = Brushes.Yellow, StrokeThickness = 1, Foreground = Brushes.White } }; Labels = dates.ToArray(); DataContext = this; } else { MessageBox.Show("Сначала внесите данные о своём весе"); } #endregion string count2 = " select COUNT(distinct data_entry) from Трекерпитания_продукты where NAME_USER=@user"; SqlCommand sql = new SqlCommand(count2, connection); sql.Parameters.Add("@user", SqlDbType.NVarChar).Value = user; object value = sql.ExecuteScalar(); int counter2 = Convert.ToInt16(value.ToString()); if (counter2 != 0) { string count3 = "select data_entry, sum(caloricity) as sum from Трекерпитания_продукты where NAME_USER=@user group by data_entry"; SqlCommand comm = new SqlCommand(count3, connection); comm.Parameters.Add("@user", SqlDbType.NVarChar).Value = user; SqlDataReader read = comm.ExecuteReader(); List <string> dates_prod = new List <string>(); List <Double> calories = new List <Double>(); DataTable dtt = new DataTable(); dtt.Load(read); for (int i = 0; i < counter2; i++) { DataRow drow = dtt.Rows[i]; DateTime values = drow.Field <DateTime>("data_entry"); Double w = drow.Field <Double>("sum"); dates_prod.Add(values.ToShortDateString()); calories.Add(w); } read.Close(); ChartValues <Double> chart = new ChartValues <Double>(); foreach (Double k in calories) { chart.Add(Convert.ToDouble(k)); } Seriescalor = new SeriesCollection { new LineSeries { Title = "Вы скушали(в ккал.)", Values = chart, PointGeometry = DefaultGeometries.Circle, PointGeometrySize = 10, Stroke = Brushes.Magenta, StrokeThickness = 1, Foreground = Brushes.White } }; Labelscalor = dates_prod.ToArray(); } else { MessageBox.Show("Данные о приёмах пищи не внесены, попробуйте ещё раз"); } DataContext = this; }
internal static IEnumerable <ObservablePoint> SegregateSamples(ChartValues <ObservablePoint> samples, int seenSamplesAmount, double time) { return(samples.OrderBy(s => (Math.Abs(s.X - time))).Take(seenSamplesAmount * 2)); }
public Redresseur(SqlDataReader reader) { ValuesA = new ChartValues <double> { 0 }; ValuesB = new ChartValues <double> { 0 }; Id = (int)reader["Id"]; IdProcess = (int)reader["IdProcess"]; IpAdresse = (string)reader["IpAdresse"]; OnOff = (bool)reader["OnOff"]; MiseSousTension = (bool)reader["MiseSousTension"]; Etat = (MODES)Enum.Parse(typeof(MODES), (string)reader["Etat"]); Type = (TYPEREDRESSEUR)Enum.Parse(typeof(TYPEREDRESSEUR), (string)reader["Type"]); UMax = (int)reader["UMax"]; IMax = (int)reader["IMax"]; ConsigneV = (int)reader["ConsigneV"]; ConsigneA = (int)reader["ConsigneA"]; LectureV = (int)reader["LectureV"]; LectureA = (int)reader["LectureA"]; Temperature = (int)reader["Temperature"]; AH = (bool)reader["AH"]; CompteurAH = (int)reader["CompteurAH"]; CalibreAH = (CALIBRE)Enum.Parse(typeof(CALIBRE), (string)reader["CalibreAH"]); Pulse = (bool)reader["Pulse"]; Temporisation = (bool)reader["Temporisation"]; TempsOn = (int)reader["TempsOn"]; TempsOff = (int)reader["TempsOff"]; DureeTempo = DateTime.Parse(reader["DureeTempo"].ToString()); DureeRestante = DateTime.Parse(reader["DureeRestante"].ToString()); Rampe = (bool)reader["Rampe"]; DureeRampe = DateTime.Parse(reader["DureeRampe"].ToString()); Defaut = (bool)reader["Defaut"]; //OrdreFabrication = (string)reader["OrdreFabrication"]; //EtatFin = (ETATFIN)Enum.Parse(typeof(ETATFIN), (string)reader["EtatFin"]); Options = OptionsService.GetAllOptionsFromTableId(Id, "Id" + this.GetType().Name); Registres = Registre.GetAllRegisterFromRedresseurId(Id); ListRecette = RecetteService.GetListRecetteFromProcessId(IdProcess); switch (Etat) { case MODES.LocalManuel: if (onOff) { EtatImageSource = "../Resources/liasonOkLocal.png"; } else { EtatImageSource = "../Resources/liasonPas.png"; } break; case MODES.LocalRecette: if (onOff) { EtatImageSource = "../Resources/liasonOkRecette.png"; } else { EtatImageSource = "../Resources/liasonPas.png"; } break; case MODES.RemoteManuel: if (onOff) { EtatImageSource = "../Resources/liasonOkRemote.png"; } else { EtatImageSource = "../Resources/liasonPas.png"; } break; case MODES.RemoteRecette: EtatImageSource = "../Resources/liasonPas.png"; break; case MODES.Supervision: if (onOff) { EtatImageSource = "../Resources/supervision.png"; } else { EtatImageSource = "../Resources/supervisionPas.png"; } break; } RedresseurPoolingTask = new Thread(RedresseurPooling); RedresseurPoolingTask.Start(); }
public PerformanceWindow(ChartValues <int> value) { InitializeComponent(); Values2 = value; DataContext = this; }
/// <summary> /// Creates a column chart /// </summary> /// <param name="chartType">If expense is given then stacked chart is created, else normal column chart</param> public void SetStackedColumnChart(ChartType chartType) { // let's clear the series first var expenseSeries = new List <Series>(); var incomeSeries = new List <Series>(); switch (chartType) { case ChartType.Expense: StackedSixMonths.SeriesCollection = new SeriesCollection(); break; case ChartType.Both: ExpenseIncomeColumn.SeriesCollection = new SeriesCollection(); break; default: break; } List <FilterGroupData> labelData = GetFilterGroupData(); using (var db = new DataModel()) { var allTransactions = db.Transactions .Include(t => t.Categories.CategoryDirections) .Where(t => t.AccountID == MainViewModel.CurrentAccount.AccountID && t.TransactionDate >= CurrentFilter.StartDate && t.TransactionDate <= CurrentFilter.EndDate) .ToList(); if (chartType == ChartType.Expense) { var categoryList = db.UserCategory .Include(uc => uc.Category.CategoryDirections) .Where(uc => uc.UserID == MainViewModel.CurrentUser.UserID && uc.Category.CategoryDirections.DirectionName == "Kiadás") .ToList(); foreach (var category in categoryList) { ChartValues <double> expenseValues = new ChartValues <double>(); foreach (var period in labelData) { var currentAmount = allTransactions.Where(t => t.Categories.CategoryName == category.Category.CategoryName && t.TransactionDate >= period.StartDate && t.TransactionDate <= period.EndDate).Sum(t => t.Amount); expenseValues.Add((double)currentAmount); } expenseSeries.Add(new StackedColumnSeries { Title = category.Category.CategoryName, Values = expenseValues, DataLabels = false }); } StackedSixMonths.SeriesCollection.AddRange(expenseSeries); StackedSixMonths.Labels = new string[labelData.Count]; } if (chartType == ChartType.Both) { ChartValues <double> expenseValues = new ChartValues <double>(); ChartValues <double> incomeValues = new ChartValues <double>(); foreach (var period in labelData) { var expenseAmount = allTransactions.Where(t => t.Categories.CategoryDirections.DirectionName == "Kiadás" && t.TransactionDate >= period.StartDate && t.TransactionDate <= period.EndDate).Sum(t => t.Amount); var incomeAmount = allTransactions.Where(t => t.Categories.CategoryDirections.DirectionName == "Bevétel" && t.TransactionDate >= period.StartDate && t.TransactionDate <= period.EndDate).Sum(t => t.Amount); expenseValues.Add((double)expenseAmount); incomeValues.Add((double)incomeAmount); } expenseSeries.Add(new ColumnSeries { Title = "Kiadás", Values = expenseValues, DataLabels = false }); incomeSeries.Add(new ColumnSeries { Title = "Bevétel", Values = incomeValues, DataLabels = false }); ExpenseIncomeColumn.SeriesCollection.AddRange(incomeSeries); ExpenseIncomeColumn.SeriesCollection.AddRange(expenseSeries); ExpenseIncomeColumn.Labels = new string[labelData.Count]; } int cycleCounter = 0; foreach (var label in labelData) { if (chartType == ChartType.Expense) { StackedSixMonths.Labels[cycleCounter] = label.Name; } if (chartType == ChartType.Both) { ExpenseIncomeColumn.Labels[cycleCounter] = label.Name; } cycleCounter++; } } }
/// <summary> /// Get data for the selected game. /// </summary> /// <param name="gameID"></param> /// <param name="variateur"></param> public void getActivityForGamesTimeGraphics(string gameID) { DateTime dateStart = DateTime.Now.AddDays(variateurTime); string[] listDate = new string[10]; ChartValues <CustomerForTime> series = new ChartValues <CustomerForTime>(); // Periode data showned for (int iDay = 0; iDay < 10; iDay++) { listDate[iDay] = dateStart.AddDays(iDay - 9).ToString("yyyy-MM-dd"); //series.Add(0); series.Add(new CustomerForTime { Name = dateStart.AddDays(iDay - 9).ToString("yyyy-MM-dd"), Values = 0, //ValuesFormat = (int)TimeSpan.FromSeconds(0).TotalHours + "h " + TimeSpan.FromSeconds(0).ToString(@"mm") + "min" }); } // Search data in periode GameActivityClass gameActivity = GameActivityDatabases.Get(Guid.Parse(gameID)); List <Activity> gameActivities = gameActivity.Activities; for (int iActivity = 0; iActivity < gameActivities.Count; iActivity++) { long elapsedSeconds = gameActivities[iActivity].ElapsedSeconds; string dateSession = Convert.ToDateTime(gameActivities[iActivity].DateSession).ToLocalTime().ToString("yyyy-MM-dd"); for (int iDay = 0; iDay < 10; iDay++) { if (listDate[iDay] == dateSession) { string tempName = series[iDay].Name; double tempElapsed = series[iDay].Values + elapsedSeconds; series[iDay] = new CustomerForTime { Name = tempName, Values = tempElapsed, }; } } } // Set data in graphic. SeriesCollection activityForGameSeries = new SeriesCollection { new ColumnSeries { Title = "", Values = series } }; string[] activityForGameLabels = listDate; //let create a mapper so LiveCharts know how to plot our CustomerViewModel class var customerVmMapper = Mappers.Xy <CustomerForTime>() .X((value, index) => index) .Y(value => value.Values); //lets save the mapper globally Charting.For <CustomerForTime>(customerVmMapper); Func <double, string> activityForGameLogFormatter = value => (int)TimeSpan.FromSeconds(value).TotalHours + "h " + TimeSpan.FromSeconds(value).ToString(@"mm") + "min"; gameLabelsY.LabelFormatter = activityForGameLogFormatter; gameSeries.DataTooltip = new CustomerToolTipForTime(); gameLabelsY.MinValue = 0; gameLabel.Content = resources.GetString("LOCGameActivityTimeTitle"); gameSeries.Series = activityForGameSeries; gameLabelsX.Labels = activityForGameLabels; }
public SpeedChartViewModel(GpuSpeedViewModel gpuSpeedVm) { _gpuSpeedVm = gpuSpeedVm; var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <MeasureModel>(mapper); Func <double, string> emptyDateTimeFormatter = (d) => { return(string.Empty); }; Func <double, string> emptySpeedFormatter = (d) => { return(string.Empty); }; Func <double, string> dateTimeFormatter = value => new DateTime((long)value).ToString("HH:mm"); Func <double, string> speedFormatter = value => value.ToUnitSpeedText(); //AxisStep forces the distance between each separator in the X axis double axisStep = TimeSpan.FromMinutes(1).Ticks; //AxisUnit forces lets the axis know that we are plotting Minutes //this is not always necessary, but it can prevent wrong labeling double axisUnit = TimeSpan.TicksPerMinute; ChartValues <MeasureModel> mainCoinSpeedValues = new ChartValues <MeasureModel>(); ChartValues <MeasureModel> mainCoinSpeedValuesShadow = new ChartValues <MeasureModel>(); LineSeries mainCoinSpeedLs = new LineSeries { Title = gpuSpeedVm.GpuVm.IndexText, DataLabels = false, PointGeometrySize = 0, StrokeThickness = 1, Values = mainCoinSpeedValues }; LineSeries mainCoinSpeedLsShadow = new LineSeries { Title = gpuSpeedVm.GpuVm.IndexText, DataLabels = false, PointGeometrySize = 0, StrokeThickness = 1, Values = mainCoinSpeedValuesShadow }; this.Series.Add(mainCoinSpeedLs); this.SeriesShadow.Add(mainCoinSpeedLsShadow); Axis axisYMainCoin = new Axis() { LabelFormatter = emptySpeedFormatter, MinValue = 0, Separator = new Separator() }; this._axisY = new AxesCollection() { axisYMainCoin }; DateTime now = DateTime.Now; this._axisX = new AxesCollection() { new Axis() { LabelFormatter = emptyDateTimeFormatter, MaxValue = now.Ticks, MinValue = now.Ticks - TimeSpan.FromMinutes(NTMinerContext.SpeedHistoryLengthByMinute).Ticks, Unit = axisUnit, Separator = new Separator() { Step = axisStep } } }; Axis axisYShadowMainCoin = new Axis() { LabelFormatter = speedFormatter, MinValue = 0, FontSize = 14, Foreground = WpfUtil.BlackBrush, Separator = new Separator() }; this._axisYShadow = new AxesCollection() { axisYShadowMainCoin }; this._axisXShadow = new AxesCollection() { new Axis() { LabelFormatter = dateTimeFormatter, Foreground = WpfUtil.BlackBrush, MaxValue = 0, FontSize = 12, MinValue = 0, Unit = axisUnit, Separator = new Separator() { Step = axisStep } } }; }
private void btn_CacNam_Click(object sender, EventArgs e) { //hiển thị năm lbl_Nam.Visible = true; cmb_Nam.Visible = true; //Clear ClearChart(); //lấy ra năm và số lượng bệnh nhân điều trị. Axis axis = new Axis() { Title = "BIỂU ĐỒ BIẾN ĐỘNG DOANH THU THÁNG", FontSize = 15, IsMerged = true, Separator = new Separator { StrokeThickness = 1, StrokeDashArray = new System.Windows.Media.DoubleCollection(2), Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(64, 79, 86)) } }; List <string> temp = new List <string>(); for (int i = 1; i <= 12; i++) { temp.Add("Tháng " + i.ToString()); } axis.Labels = temp; cartesianChart_DoanhThu.AxisX.Add(axis); List <double> l = new List <double>(); for (int i = 0; i < 12; i++) { l.Add(0); } var list = from p in Cons.dataContext.Receipts where p.receiptdate.Value.Year == 2018 select new { p.receiptdate, p.total }; dataGridView1.DataSource = list; foreach (var item in list.ToList()) { l[item.receiptdate.Value.Month - 1] += double.Parse(item.total.ToString()); } LineSeries lineSeries = new LineSeries() { Title = "Tổng doanh thu: ", //Values = new ChartValues<double> { 14, 16, 13, 12, 16 }, StrokeThickness = 4, StrokeDashArray = new System.Windows.Media.DoubleCollection(20), Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(93, 12, 123)), LineSmoothness = 0, PointGeometry = null }; ChartValues <double> ts = new ChartValues <double>(); for (int i = 0; i < 12; i++) { ts.Add(l[i]); } lineSeries.Values = ts; cartesianChart_DoanhThu.Series.Add(lineSeries); }
public LiveChartViewModel() { _eventAggregator = IoC.Get <IEventAggregator>(); _eventAggregator.Subscribe(this); #region realchart var mapper = Mappers.Xy <MeasureModel>() .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X .Y(model => model.Value); //use the value property as Y //lets save the mapper globally. Charting.For <MeasureModel>(mapper); //the values property will store our values array ChartValues = new ChartValues <MeasureModel>(); //lets set how to display the X Labels DateTimeFormatter = value => new DateTime((long)value).ToString("hh.mm:ss"); //AxisStep forces the distance between each separator in the X axis AxisStep = TimeSpan.FromSeconds(1).Ticks; //AxisUnit forces lets the axis know that we are plotting seconds //this is not always necessary, but it can prevent wrong labeling AxisUnit = TimeSpan.TicksPerSecond; SetAxisLimits(DateTime.Now); //The next code simulates data changes every 300 ms IsReading = false; #endregion Name_mum = "2"; Value = 100; #region cloumn0 SeriesCollection = new SeriesCollection { new ColumnSeries { Title = "TAB0", Values = new ChartValues <double> { 10, 50, 39, 50, 10, 50, 39, 50, 11, 56, 42, 10, 50, 39, 50, 50, 39, 50, 10, 50, 39, 50, 11, 56 } } }; //adding series will update and animate the chart automatically SeriesCollection.Add(new ColumnSeries { Title = "TAB1", Values = new ChartValues <double> { 11, 56, 42, 10, 50, 39, 50, 11, 56, 42, 10, 50, 39, 50, 56, 42, 10, 50, 39, 50, 11, 56, 42, 10 } }); //also adding values updates and animates the chart automatically SeriesCollection[1].Values.Add(48d); Labels = new[] { "00:00:00", "01:00:00", "02:00:00", "03:00:00", "04:00:00", "05:00:00", "06:00:00", "07:00:00", "08:00:00", "09:00:00", "10:00:00", "11:00:00", "12:00:00", "13:00:00", "14:00:00", "15:00:00", "16:00:00", "17:00:00", "18:00:00", "19:00:00", "20:00:00", "21:00:00", "22:00:00", "23:00:00", }; #endregion #region cloumn1 SeriesCollection2 = new SeriesCollection { new ColumnSeries { Title = "OK", Values = new ChartValues <double> { 10, 50, 39, 50, 10, 50, 39, 50, 11, 56 } } }; //adding series will update and animate the chart automatically SeriesCollection2.Add(new ColumnSeries { Title = "NG", Values = new ChartValues <double> { 11, 56, 42, 10, 50, 39, 50, 11, 56, 42 } }); //also adding values updates and animates the chart automatically SeriesCollection2[1].Values.Add(48d); Labels1 = new[] { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09" }; #endregion #region pie Formatter = value => value.ToString("N"); PointLabel = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation); SeriesCollection1 = new SeriesCollection { new PieSeries { Title = "Maria", Values = new ChartValues <double> { 4 }, DataLabels = true, LabelPoint = PointLabel }, new PieSeries { Title = "Charles", Values = new ChartValues <double> { 3 }, DataLabels = true, LabelPoint = PointLabel }, new PieSeries { Title = "Frida", Values = new ChartValues <double> { 2 }, DataLabels = true, LabelPoint = PointLabel }, new PieSeries { Title = "Frederic", Values = new ChartValues <double> { 3 }, DataLabels = true, LabelPoint = PointLabel }, }; #endregion InjectStopOnClick(); }
public async Task LoadData() { var context = await DataAccess.DbContext.GetCurrent(); // Sélection du nombre de total de média ObservableCollection <Class.Media> allMedia = new ObservableCollection <Class.Media>(context.Medias.ToList()); nbrMedia = allMedia.Count; // Sélection du nombre de total de film ObservableCollection <Class.Media> allFilm = new ObservableCollection <Class.Media>(context.Films.ToList()); nbrFilm = allFilm.Count; // Sélection du nombre de total de serie ObservableCollection <Class.Media> allSerie = new ObservableCollection <Class.Media>(context.Series.ToList()); nbrSerie = allSerie.Count; //Sélection du nombre de films/Séries à voir ObservableCollection <Class.Media> aVoir = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Statut.ToString() == "A_voir").ToList()); nbrAVoir = aVoir.Count; //Sélection du nombre de films/Séries vu ObservableCollection <Class.Media> Vu = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Statut.ToString() == "Vu").ToList()); nbrVu = Vu.Count; //Sélection du nombre de films/Séries vu ObservableCollection <Class.Media> EnCours = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Statut.ToString() == "En_cours").ToList()); nbrEnCours = EnCours.Count; // Sélection du nombre de total de média suivant le Genre sélectionné ObservableCollection <Class.Media> dansGenre = new ObservableCollection <Class.Media>(context.Medias.Include(m => m.Genres).Where(m => m.Genres.Any(g => g.Genre.nom == typeCBoxSelected)).ToList()); nbrDansGenre = dansGenre.Count; //Sélections des films suivant la notes: if (isChecked1 == true) { ObservableCollection <Class.Media> deLaNote = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Note == 1).ToList()); nbrNotes = deLaNote.Count; } else if (isChecked2 == true) { ObservableCollection <Class.Media> deLaNote = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Note == 2).ToList()); nbrNotes = deLaNote.Count; } else if (isChecked3 == true) { ObservableCollection <Class.Media> deLaNote = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Note == 3).ToList()); nbrNotes = deLaNote.Count; } else if (isChecked4 == true) { ObservableCollection <Class.Media> deLaNote = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Note == 4).ToList()); nbrNotes = deLaNote.Count; } else if (isChecked5 == true) { ObservableCollection <Class.Media> deLaNote = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Note == 5).ToList()); nbrNotes = deLaNote.Count; } else { nbrNotes = 0; } valeurSerie = new ChartValues <Double> { nbrSerie }; valeurFilm = new ChartValues <Double> { nbrFilm }; PointLabel = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation); valeurMediaVu = new ChartValues <Double> { nbrVu }; valeurMediaAvoir = new ChartValues <Double> { nbrAVoir }; valeurMediaEnCours = new ChartValues <Double> { nbrEnCours }; // Sélection du nombre de média par note ObservableCollection <Class.Media> listeNote0 = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Note == 0).ToList()); note0 = listeNote0.Count; ObservableCollection <Class.Media> listeNote1 = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Note == 1).ToList()); note1 = listeNote1.Count; ObservableCollection <Class.Media> listeNote2 = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Note == 2).ToList()); note2 = listeNote2.Count; ObservableCollection <Class.Media> listeNote3 = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Note == 3).ToList()); note3 = listeNote3.Count; ObservableCollection <Class.Media> listeNote4 = new ObservableCollection <Class.Media>(context.Medias.Where(m => m.Note == 4).ToList()); note4 = listeNote4.Count; ObservableCollection <Class.Film> listeNote5 = new ObservableCollection <Class.Film>(context.Films.Where(m => m.Note == 5).ToList()); note5 = listeNote5.Count; valeurNote0 = new ChartValues <Double> { note0 }; valeurNote1 = new ChartValues <Double> { note1 }; valeurNote2 = new ChartValues <Double> { note2 }; valeurNote3 = new ChartValues <Double> { note3 }; valeurNote4 = new ChartValues <Double> { note4 }; valeurNote5 = new ChartValues <Double> { note5 }; }
/// <summary> /// Get data graphic activity by week. /// </summary> /// <param name="year"></param> /// <param name="month"></param> public void getActivityByWeek(int year, int month) { //https://www.codeproject.com/Questions/1276907/Get-every-weeks-start-and-end-date-from-series-end //usage: DateTime StartDate = new DateTime(year, month, 1, 0, 0, 0); DateTime SeriesEndDate = new DateTime(year, month, DateTime.DaysInMonth(year, month), 23, 59, 59); //find first monday DateTime firstMonday = Enumerable.Range(0, 7) .SkipWhile(x => StartDate.AddDays(x).DayOfWeek != DayOfWeek.Monday) .Select(x => StartDate.AddDays(x)) .First(); //get count of days TimeSpan ts = (TimeSpan)(SeriesEndDate - firstMonday); //create new list of WeekStartEnd class List <WeekStartEnd> datesPeriodes = new List <WeekStartEnd>(); //add dates to list for (int i = 0; i < ts.Days; i += 7) { datesPeriodes.Add(new WeekStartEnd() { Monday = firstMonday.AddDays(i), Sunday = firstMonday.AddDays(i + 6).AddHours(23).AddMinutes(59).AddSeconds(59) }); } // Source activty by month JObject activityByWeek1 = new JObject(); JObject activityByWeek2 = new JObject(); JObject activityByWeek3 = new JObject(); JObject activityByWeek4 = new JObject(); JObject activityByWeek5 = new JObject(); JArray activityByWeek = new JArray(); SeriesCollection activityByWeekSeries = new SeriesCollection(); if (isMonthSources) { // Insert sources for (int iSource = 0; iSource < listSources.Count; iSource++) { activityByWeek1.Add((string)listSources[iSource], 0); activityByWeek2.Add((string)listSources[iSource], 0); activityByWeek3.Add((string)listSources[iSource], 0); activityByWeek4.Add((string)listSources[iSource], 0); activityByWeek5.Add((string)listSources[iSource], 0); } activityByWeek.Add(activityByWeek1); activityByWeek.Add(activityByWeek2); activityByWeek.Add(activityByWeek3); activityByWeek.Add(activityByWeek4); activityByWeek.Add(activityByWeek5); List <GameActivityClass> listGameActivities = GameActivityDatabases.GetListGameActivity(); for (int iGame = 0; iGame < listGameActivities.Count; iGame++) { List <Activity> gameActivities = listGameActivities[iGame].Activities; for (int iActivity = 0; iActivity < gameActivities.Count; iActivity++) { long elapsedSeconds = gameActivities[iActivity].ElapsedSeconds; DateTime dateSession = Convert.ToDateTime(gameActivities[iActivity].DateSession).AddSeconds(-elapsedSeconds).ToLocalTime(); string sourceName = gameActivities[iActivity].SourceName; // Cumul data for (int iWeek = 0; iWeek < datesPeriodes.Count; iWeek++) { if (datesPeriodes[iWeek].Monday <= dateSession && dateSession <= datesPeriodes[iWeek].Sunday) { activityByWeek[iWeek][sourceName] = (long)activityByWeek[iWeek][sourceName] + elapsedSeconds; } } } } // Check source with data (only view this) JArray listNoDelete = new JArray(); for (int i = 0; i < activityByWeek.Count; i++) { foreach (var item in (JObject)activityByWeek[i]) { if ((long)item.Value != 0 && listNoDelete.TakeWhile(x => x.ToString() == item.Key).Count() != 1) { listNoDelete.Add(item.Key); } } } listNoDelete = JArray.FromObject(listNoDelete.Distinct().ToArray()); // Prepare data. string[] labels = new string[listNoDelete.Count]; for (int iSource = 0; iSource < listNoDelete.Count; iSource++) { labels[iSource] = (string)listNoDelete[iSource]; if (settings.showLauncherIcons) { labels[iSource] = TransformIcon.Get((string)listNoDelete[iSource]); } IChartValues Values = new ChartValues <CustomerForTime>() { new CustomerForTime { Name = (string)listNoDelete[iSource], Values = (int)activityByWeek[0][(string)listNoDelete[iSource]] }, new CustomerForTime { Name = (string)listNoDelete[iSource], Values = (int)activityByWeek[1][(string)listNoDelete[iSource]] }, new CustomerForTime { Name = (string)listNoDelete[iSource], Values = (int)activityByWeek[2][(string)listNoDelete[iSource]] }, new CustomerForTime { Name = (string)listNoDelete[iSource], Values = (int)activityByWeek[3][(string)listNoDelete[iSource]] } }; if (datesPeriodes.Count == 5) { Values.Add(new CustomerForTime { Name = (string)listNoDelete[iSource], Values = (int)activityByWeek[4][(string)listNoDelete[iSource]] }); } activityByWeekSeries.Add(new StackedColumnSeries { Title = labels[iSource], Values = Values, StackMode = StackMode.Values, DataLabels = false }); } } // Set data in graphics. string[] activityByWeekLabels = new[] { resources.GetString("LOCGameActivityWeekLabel") + " " + Tools.WeekOfYearISO8601(datesPeriodes[0].Monday), resources.GetString("LOCGameActivityWeekLabel") + " " + Tools.WeekOfYearISO8601(datesPeriodes[1].Monday), resources.GetString("LOCGameActivityWeekLabel") + " " + Tools.WeekOfYearISO8601(datesPeriodes[2].Monday), resources.GetString("LOCGameActivityWeekLabel") + " " + Tools.WeekOfYearISO8601(datesPeriodes[3].Monday) }; if (datesPeriodes.Count == 5) { activityByWeekLabels = new[] { resources.GetString("LOCGameActivityWeekLabel") + " " + Tools.WeekOfYearISO8601(datesPeriodes[0].Monday), resources.GetString("LOCGameActivityWeekLabel") + " " + Tools.WeekOfYearISO8601(datesPeriodes[1].Monday), resources.GetString("LOCGameActivityWeekLabel") + " " + Tools.WeekOfYearISO8601(datesPeriodes[2].Monday), resources.GetString("LOCGameActivityWeekLabel") + " " + Tools.WeekOfYearISO8601(datesPeriodes[3].Monday), resources.GetString("LOCGameActivityWeekLabel") + " " + Tools.WeekOfYearISO8601(datesPeriodes[4].Monday) }; } //let create a mapper so LiveCharts know how to plot our CustomerViewModel class var customerVmMapper = Mappers.Xy <CustomerForTime>() .X((value, index) => index) .Y(value => value.Values); //lets save the mapper globally Charting.For <CustomerForTime>(customerVmMapper); Func <double, string> activityForGameLogFormatter = value => (string)converter.Convert((long)value, null, null, CultureInfo.CurrentCulture); acwLabelsY.LabelFormatter = activityForGameLogFormatter; acwSeries.Series = activityByWeekSeries; acwLabelsY.MinValue = 0; ((CustomerToolTipForMultipleTime)acwSeries.DataTooltip).ShowIcon = settings.showLauncherIcons; acwLabelsX.Labels = activityByWeekLabels; }
public BitsChartViewModel() { Values = new ChartValues <double>(); }
public HeatSeriesExample() { InitializeComponent(); var r = new Random(); Values = new ChartValues <HeatPoint> { //X means sales man //Y is the day //"Jeremy Swanson" new HeatPoint(0, 0, r.Next(0, 10)), new HeatPoint(0, 1, r.Next(0, 10)), new HeatPoint(0, 2, r.Next(0, 10)), new HeatPoint(0, 3, r.Next(0, 10)), new HeatPoint(0, 4, r.Next(0, 10)), new HeatPoint(0, 5, r.Next(0, 10)), new HeatPoint(0, 6, r.Next(0, 10)), //"Lorena Hoffman" new HeatPoint(1, 0, r.Next(0, 10)), new HeatPoint(1, 1, r.Next(0, 10)), new HeatPoint(1, 2, r.Next(0, 10)), new HeatPoint(1, 3, r.Next(0, 10)), new HeatPoint(1, 4, r.Next(0, 10)), new HeatPoint(1, 5, r.Next(0, 10)), new HeatPoint(1, 6, r.Next(0, 10)), //"Robyn Williamson" new HeatPoint(2, 0, r.Next(0, 10)), new HeatPoint(2, 1, r.Next(0, 10)), new HeatPoint(2, 2, r.Next(0, 10)), new HeatPoint(2, 3, r.Next(0, 10)), new HeatPoint(2, 4, r.Next(0, 10)), new HeatPoint(2, 5, r.Next(0, 10)), new HeatPoint(2, 6, r.Next(0, 10)), //"Carole Haynes" new HeatPoint(3, 0, r.Next(0, 10)), new HeatPoint(3, 1, r.Next(0, 10)), new HeatPoint(3, 2, r.Next(0, 10)), new HeatPoint(3, 3, r.Next(0, 10)), new HeatPoint(3, 4, r.Next(0, 10)), new HeatPoint(3, 5, r.Next(0, 10)), new HeatPoint(3, 6, r.Next(0, 10)), //"Essie Nelson" new HeatPoint(4, 0, r.Next(0, 10)), new HeatPoint(4, 1, r.Next(0, 10)), new HeatPoint(4, 2, r.Next(0, 10)), new HeatPoint(4, 3, r.Next(0, 10)), new HeatPoint(4, 4, r.Next(0, 10)), new HeatPoint(4, 5, r.Next(0, 10)), new HeatPoint(4, 6, r.Next(0, 10)) }; Days = new[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }; SalesMan = new[] { "Jeremy Swanson", "Lorena Hoffman", "Robyn Williamson", "Carole Haynes", "Essie Nelson" }; DataContext = this; }