public StatGraphs(string statname, FilterCondition filter) { InitializeComponent(); Title = "Plot: " + statname.Replace("[property] ", ""); if (filter == null) { FilterText.Text = "None"; } else { IList <string> filterstrings = new List <string>(); foreach (FilterCondition c in ((AndCondition)filter).Subconditions) { filterstrings.Add(c.ToString()); } FilterText.Text = string.Join("\n", filterstrings); } PercentChart.AxisX[0].Title = statname.Replace("[property] ", ""); CostChart.AxisX[0].Title = statname.Replace("[property] ", ""); PercentMapper = Mappers.Xy <StatPoint>(); PercentMapper.X(value => value.X); PercentMapper.Y(value => (double)value.Count / value.Total); CostMapper = Mappers.Xy <StatPoint>(); CostMapper.X(value => value.X); CostMapper.Y(value => Math.Log(value.Total * value.Cost / value.Count, 10)); Min = double.NaN; Max = double.NaN; Incr = double.NaN; }
public KDMetricsTestResultWindow(double[] euclidPerformance, double[] manhattanPerformance, double[] chebyshevPerformance, double[] mahalanobisPerformance) { InitializeComponent(); DataContext = this; var mapper = new CartesianMapper <double>() .X((value, index) => index + 1) .Y((value, index) => value); Charting.For <double>(mapper); Collection.Add(new LineSeries { Title = "Euklides", Values = new ChartValues <double>(euclidPerformance), LineSmoothness = 0.01, //0: straight lines, 1: really smooth lines }); Collection.Add(new LineSeries { Title = "Manhattan", Values = new ChartValues <double>(manhattanPerformance), LineSmoothness = 0.01, //0: straight lines, 1: really smooth lines }); Collection.Add(new LineSeries { Title = "Czebyszew", Values = new ChartValues <double>(chebyshevPerformance), LineSmoothness = 0.01, //0: straight lines, 1: really smooth lines }); Collection.Add(new LineSeries { Title = "Mahalanobis", Values = new ChartValues <double>(mahalanobisPerformance), LineSmoothness = 0.01, //0: straight lines, 1: really smooth lines }); }
public ChartModel() { CartesianMapper <DateTimePoint> mapper = Mappers.Xy <DateTimePoint>() .X((item) => (double)item.Timestamp.Ticks / TimeSpan.FromMinutes(5).Ticks) // Set interval to 5 minutes .Y(item => item.Value) .Fill((item) => item.Value > 99 ? Brushes.Red : Brushes.Blue); var series = new ColumnSeries() { Title = "Timestamp Values", Configuration = mapper, Values = new ChartValues <DateTimePoint> { new DateTimePoint() { Timestamp = DateTime.Now, Value = 100 }, new DateTimePoint() { Timestamp = DateTime.Now.AddMinutes(15), Value = 78 }, new DateTimePoint() { Timestamp = DateTime.Now.AddMinutes(30), Value = 21 } } }; this.SeriesCollection = new SeriesCollection() { series }; }
/// <summary> /// Initializes a chart with X axis from type <see cref="AlertPresentation.ChartAxisType.NumberAxis"/>. /// </summary> /// <param name="chartAlertProperty">The chart alert property that should be displayed.</param> private void InitializeNumberXAxisChart(ChartAlertProperty chartAlertProperty) { var sortedNumericPoints = chartAlertProperty.DataPoints.OrderBy(point => point.X).ToList(); var chartPoints = sortedNumericPoints.Select(dataPoint => { double x = ConvertCoordinateValueToDouble(dataPoint.X, "X"); double y = ConvertCoordinateValueToDouble(dataPoint.Y, "Y"); return(new ChartDataPoint <double>(x, y)); }); var chartValues = new ChartValues <ChartDataPoint <double> >(chartPoints); CartesianMapper <ChartDataPoint <double> > pointMapperConfig = Mappers.Xy <ChartDataPoint <double> >() .X(dataPoint => dataPoint.X) .Y(dataPoint => dataPoint.Y); this.SeriesCollection = new SeriesCollection(pointMapperConfig); this.AddSeries(chartAlertProperty.ChartType, chartValues); this.XAxisFormatter = value => value.ToString(CultureInfo.InvariantCulture); this.SetYAxisFormat(chartAlertProperty); }
/// <summary> /// Initializes a chart with X axis from type <see cref="AlertPresentation.ChartAxisType.DateAxis"/>. /// </summary> /// <param name="chartAlertProperty">The chart alert property that should be displayed.</param> private void InitializeDateTimeXAxisChart(ChartAlertProperty chartAlertProperty) { var sortedDateTimePoints = chartAlertProperty.DataPoints.OrderBy(point => point.X).ToList(); var chartDatePoints = sortedDateTimePoints.Select(dataPoint => { DateTime x = ConvertCoordinateValueToDateTime(dataPoint.X, "X"); double y = ConvertCoordinateValueToDouble(dataPoint.Y, "Y"); return(new ChartDataPoint <DateTime>(x, y)); }); var chartValues = new ChartValues <ChartDataPoint <DateTime> >(chartDatePoints); // In order to support Bar Chart, Since we are using DateTime.Ticks as X, the width of the bar is 1 tick and 1 tick is 1 millisecond. // In order to make our bars visible we need to change the unit of the chart. Hence, we are taking the difference between 2 first points (assuming difference between every 2 points is equal) double xAxisFactor = chartValues.Count > 1 ? chartValues.Skip(1).First().X.Ticks - chartValues.First().X.Ticks : chartValues.First().X.Ticks; CartesianMapper <ChartDataPoint <DateTime> > pointMapperConfig = Mappers.Xy <ChartDataPoint <DateTime> >() .X(dateTimeDataPoint => dateTimeDataPoint.X.Ticks / xAxisFactor) .Y(dateTimeDataPoint => dateTimeDataPoint.Y); this.SeriesCollection = new SeriesCollection(pointMapperConfig); this.AddSeries(chartAlertProperty.ChartType, chartValues); this.XAxisFormatter = value => new DateTime((long)(value * xAxisFactor)).ToString(CultureInfo.InvariantCulture); this.SetYAxisFormat(chartAlertProperty); }
public MainWindow() { InitializeComponent(); CartesianMapper <MeasureModel> mapper = Mappers.Xy <MeasureModel>().X(model => model.Time).Y(model => model.Value); Charting.For <MeasureModel>(mapper); ChartValuesRed = new ChartValues <MeasureModel>(); ChartValuesIR = new ChartValues <MeasureModel>(); ChartValuesHeart = new ChartValues <MeasureModel>(); Bpm = new ChartValues <MeasureModel>(); Spo2 = new ChartValues <MeasureModel>(); //lets save the mapper globally. Charting.For <MeasureModel>(mapper); //lets set how to display the X Labels //DateTimeFormatter = value => new DateTime((long)value).ToString("ss"); //AxisStep forces the distance between each separator in the X axis AxisStep = 1; // TimeSpan.FromMilliseconds(50).Ticks; //AxisUnit forces lets the axis know that we are plotting seconds //this is not always necessary, but it can prevent wrong labeling AxisUnit = 1; SetAxisLimits(0); //The next code simulates data changes every 300 ms DataContext = this; this.Loaded += MainWindow_Loaded; }
private void CreateCollumnChart(IEnumerable <XYAxisHelper> totalSpentInGivenInterval) { CartesianMapper <XYAxisHelper> dayConfig = Mappers .Xy <XYAxisHelper>() .X(model => model.x) .Y(model => model.y); ColumnChart.Series = new SeriesCollection(dayConfig) { new ColumnSeries { Values = new ChartValues <XYAxisHelper>(totalSpentInGivenInterval) } }; ColumnChart.AxisX = new AxesCollection() { new Axis() { Title = "Day of month", Separator = new LiveCharts.Wpf.Separator() { Step = 1.0, IsEnabled = true }, MaxValue = 32 } }; }
private void GuiAxelsStock() { _dayConfigStock = Mappers.Xy <DateModel>() .X(dateModel => dateModel.DateTime.Ticks / (_timeFrameStock.Years())) .Y(dateModel => Math.Log(dateModel.Value, 10)); AddStockAxels(); }
private void GuiAxelsPortfolio() { _dayConfigBacktest = Mappers.Xy <DateModel>() .X(dateModel => dateModel.DateTime.Ticks / (_timeFrameBacktest.Years())) .Y(dateModel => dateModel.Value); AddPortfolioAxels(); }
private void ListSelectionChanged(object sender, SelectionChangedEventArgs e) { if (ChartValues != null) { CurrentConfig = CHOICES[choicesList.SelectedIndex]; Plot(ChartValues, DateTime.Now, LastSelected, LastFilter); } }
private void InitGraphSettings() { CartesianMapper <TimeSpanValue> dayConfig = Mappers.Xy <TimeSpanValue>() .X(dateModel => { return(dateModel.TimeSpan.TotalMilliseconds / TimeSpan.FromMilliseconds(1).TotalMilliseconds); }) .Y(dateModel => { return(dateModel.Value); }); SeriesCollection = new SeriesCollection(dayConfig) { new LineSeries { StrokeThickness = 1, Fill = Brushes.Transparent, Stroke = Brushes.CornflowerBlue, PointGeometrySize = 0, Values = new ChartValues <TimeSpanValue>() { }, ScalesYAt = 0, }, new LineSeries { StrokeThickness = 1, Fill = Brushes.Transparent, Stroke = Brushes.Green, PointGeometrySize = 0, Values = new ChartValues <TimeSpanValue>() { }, ScalesYAt = 1, }, new StepLineSeries { StrokeThickness = 1, Fill = Brushes.Transparent, Stroke = Brushes.Red, PointGeometrySize = 0, AlternativeStroke = Brushes.Red, Values = new ChartValues <TimeSpanValue>() { }, ScalesYAt = 2, }, }; Formatter = value => { var x = value > 0 ? value : 0; return(new DateTime((long)(x * TimeSpan.FromMilliseconds(1).Ticks)).ToString("mm\\:ss\\:fff")); }; _graphInitialized = true; }
//Выделяет максимальное и минимальное количество шагов private void ChangeMapper() { Mapper = new CartesianMapper <int>() .X((value, index) => index) .Y((value) => value) .Fill(item => (item == selectedClient.MaxSteps ? FillMaxSteps : item == selectedClient.MinSteps ? FillMinSteps : null)); }
private void ListSelectionChanged(object sender, SelectionChangedEventArgs e) { if (PlayerPetValues.Count > 0) { CurrentChoice = choicesList.SelectedValue as string; CurrentConfig = CHOICES[choicesList.SelectedIndex]; CurrentPetOrPlayerOption = petOrPlayerList.SelectedValue as string; Plot(LastSelected, LastFilter); } }
public Painter(SeriesCollection series) { Series = series; Mapper = Mappers.Xy <DateModel>().X(dateModel => dateModel.Date.Ticks / TimeSpan.FromDays(1).Ticks).Y(dateModel => dateModel.Value); Formatter = FormatterManager.CreateFormatter(); UpdateAxisLimit(); }
private void ChangeThirdChartPointColorToRed() { CartesianMapper <double> mapper = Mappers.Xy <double>() .X((value, index) => index) .Y(value => value) .Fill((value, index) => index == 2 ? Brushes.Red : Brushes.Blue); // Dynamically set the third chart point color to red this.BlueSeries.Configuration = mapper; }
// Sets the unit conversion factor for time (milliseconds <-> seconds), for either axis mapper public void CalculateTimeUnitConversion(CartesianMapper <GraphingEntry> mapper, ControlEnums.TIMEUNITS unit, bool xAxis) { if (xAxis) { mapper.X(entry => entry.uptime * GetTimeUnitConversionFactor(unit)); } else { mapper.Y(entry => entry.uptime * GetTimeUnitConversionFactor(unit)); } }
// Sets the unit conversion factors for voltage (millivolts <-> volts), for either axis mapper public void CalculateVoltageUnitConversion(CartesianMapper <GraphingEntry> mapper, ControlEnums.VOLTAGEUNITS unit, bool xAxis) { if (xAxis) { mapper.X(entry => entry.voltage * GetVoltageUnitConversionFactor(unit)); } else { mapper.Y(entry => entry.voltage * GetVoltageUnitConversionFactor(unit)); } }
// Graph initialization public void GraphInit() { //Brackets including and under poverty line will be one color, normal brackets will be another, //and max will be another color Brush povertyColor = Brushes.Red; Brush normalColor = Brushes.Blue; Brush maxColor = Brushes.Lime; CartesianMapper <int> povertyMapper; if (GraphModel != null) { povertyMapper = new CartesianMapper <int>() .X((value, index) => index) .Y((value) => value) .Fill((value, index) => { if (index <= PovertyLineIndex) { return(povertyColor); } else if (index > PovertyLineIndex && index < totalBrackets - maxBracketCount) { return(normalColor); } else { return(maxColor); } }); } else { povertyMapper = new CartesianMapper <int>() .X((value, index) => index) .Y((value) => value) .Fill((value, index) => { if (index <= 3) { return(povertyColor); } else if (index > 3 && index < totalBrackets - 7) { return(normalColor); } else { return(maxColor); } }); } Charting.For <int>(povertyMapper, SeriesOrientation.Horizontal); }
public GraphicViewModel(ChartValues <SensorValue> values, AxisValues _axisValues, string graphicTitle) { DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss:ms"); mapper = Mappers.Xy <SensorValue>() .X(model => model.GeneratingTime.Ticks) .Y(model => model.Magnitude); Charting.For <SensorValue>(mapper); axisValues = _axisValues; axisValues.PropertyChanged += AxisPropertyChanged; Values = values; GraphicTitle = graphicTitle; }
private void ColorMinAndMaxPoint() { var mapper = new CartesianMapper <int>() .X((value, index) => index) .Y(value => value) .Fill((value, index) => value == SelectedUser?.TheBestResult ? Brushes.Green : value == SelectedUser?.TheWorstResult ? Brushes.Red : null); LiveCharts.Charting.For <int>(mapper, SeriesOrientation.Horizontal); }
public SeriesCollection InitSeriesCollection(CartesianMapper <DateModel> mapper, params Dictionary <DateTime, double>[] dataSeries) { SeriesCollection seriesCollection = new SeriesCollection(mapper); foreach (Dictionary <DateTime, double> diagrammData in dataSeries) { LineSeries lineSeries = CreateLineSeries(diagrammData); seriesCollection.Add(lineSeries); } return(seriesCollection); }
public DataCurveChartViewModel(Prism.Events.IEventAggregator eventAggregator, IDeviceParameterInfoService deviceParameterInfoService) { _eventAggregator = eventAggregator; _deviceParameterInfoService = deviceParameterInfoService; _dateConfig = Mappers.Xy <DateModel>() .X(m => (double)m.DateTime.Ticks / TimeSpan.FromHours(1).Ticks) .Y(m => m.Value); SeriesCollection = new SeriesCollection(_dateConfig); _eventAggregator.GetEvent <HistoryDataUpdatedEvent>().Subscribe(UpdateHistoryDataSeriesCollection); _eventAggregator.GetEvent <SelectedEquipmentChangedEvent>().Subscribe(ResetHistoryDataSeriesCollection); }
public RatioBar() { InitializeComponent(); dateHelper = new DateHelper(TimeSpan.FromDays(1)); FormatterX = val => val.ToString("P0"); FormatterY = val => dateHelper.FromDouble(val).ToString("d"); mapper = new CartesianMapper<DataElement>(); mapper.X(p => Math.Round(p.Value, 0)).Y(p => dateHelper.ToDouble(p.Date)); SeriesCollection = new SeriesCollection(mapper); Chart.DataContext = this; }
private int series_counter; // number of series plotted, zero-indexed /// <summary> /// Initialises a new instance of the NumberRadiusChart class. /// </summary> public NumberRadiusChart() { x_axis_title = "Number of Particles"; y_axis_title = "Aggregate Radius"; // create a mapper using NumberRadiusMeasureModel where // X co-ord is ParticleNumber and Y co-ord is Radius. CartesianMapper <NumberRadiusMeasureModel> mapper = Mappers.Xy <NumberRadiusMeasureModel>() .X(model => model.ParticleNumber) .Y(model => model.AggregateRadius); // save the mapper globally Charting.For <NumberRadiusMeasureModel>(mapper); SeriesCollection = new SeriesCollection(); series_counter = -1; ResetAxisProperties(); PollingInterval = 100U; }
/// <summary> /// Initialises a new instance of the GenerationRateChart class. /// </summary> public GenerationRateChart() { x_axis_title = "Time (s)"; y_axis_title = "Rate of Generation (/s)"; // create a mapper using RateGenerationMeasureModel where X co-ord is // time-span and Y co-ord is the rate of aggregate generation CartesianMapper <RateGenerationMeasureModel> mapper = Mappers.Xy <RateGenerationMeasureModel>() .X(model => model.Time.Seconds) .Y(model => model.Rate); // save mapper globally Charting.For <RateGenerationMeasureModel>(mapper); TimeSpanFormatter = value => new TimeSpan(value).ToString("mm:ss"); SeriesCollection = new SeriesCollection(); series_counter = -1; ResetXAxisProperties(); }
public PointStateExampleViewModel() { ListResult = new ObservableCollection <CoordinateModel>(App.ListResult); Values = new ChartValues <CoordinateModel>(); foreach (var item in ListResult) { CoordinateModel coordinate = new CoordinateModel(); coordinate = item; Values.Add(coordinate); } //Lets define a custom mapper, to set fill and stroke //according to chart values... Mapper = Mappers.Xy <CoordinateModel>() .X(model => model.Xcoord) .Y(model => model.Value); }
public LineChart(List <string> choices) { InitializeComponent(); lvcChart.Hoverable = false; lvcChart.DisableAnimations = true; lvcChart.DataTooltip = null; // reverse regular tooltip //lvcChart.DataTooltip.Foreground = (SolidColorBrush) Application.Current.FindResource(AssetResourceKeys.ToolTipBackgroundNormalBrushKey); //lvcChart.DataTooltip.Background = (SolidColorBrush) Application.Current.FindResource(AssetResourceKeys.ToolTipForegroundNormalBrushKey); lvcChart.ChartLegend.Foreground = (SolidColorBrush)Application.Current.FindResource(AssetResourceKeys.ToolTipBackgroundNormalBrushKey); lvcChart.ChartLegend.Background = (SolidColorBrush)Application.Current.FindResource(AssetResourceKeys.ToolTipForegroundNormalBrushKey); CurrentConfig = CONFIG_VPS; choicesList.ItemsSource = choices; choicesList.SelectedIndex = 0; Reset(); }
private void Plot() { int maxPoint = (int)chartModel.Points.OrderBy(p => p.Y).Last().Y; int minPoint = (int)chartModel.Points.OrderBy(p => p.Y).First().Y; CartesianMapper <ObservablePoint> mapper = Mappers.Xy <ObservablePoint>() .Y(item => item.Y) .Fill((item) => { if (item.Y == maxPoint) { return(Brushes.Green); } if (item.Y == minPoint) { return(Brushes.Red); } return(null); }) .Stroke((item) => { if (item.Y == maxPoint) { return(Brushes.Green); } if (item.Y == minPoint) { return(Brushes.Red); } return(null); }); Series = new SeriesCollection { new LineSeries { Values = chartModel.Points, Configuration = mapper, Fill = Brushes.Transparent, PointGeometrySize = 15 } }; }
public void GraphConsumption(int a_min, string codeText, List <string> a_dateConsumption, List <decimal> a_consumptionList) { if (a_consumptionList.Count() != 0) { LabelsX = new List <string>(a_dateConsumption.AsEnumerable()); MaxY = a_consumptionList.Max() + 2; MinY = a_min; MaxX = a_dateConsumption.Count() - 1; MinX = a_dateConsumption.Count() - 16; Series = new LiveCharts.ChartValues <decimal>(a_consumptionList.AsEnumerable()); Title = ManageLanguage.GetLanguageString(codeText, ManageLanguage.LanguageSelected); var mapper1 = new CartesianMapper <double>() .X((value, index) => index) //use the index as X .Y((value, index) => value); //use the value as Y LiveCharts.Charting.For <double>(mapper1, SeriesOrientation.Horizontal); } }
/// <summary>Converts a value. </summary> /// <param name="value">The value produced by the binding source.</param> /// <param name="targetType">The type of the binding target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> /// <returns>A converted value. If the method returns <see langword="null" />, the valid null value is used.</returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is ChartValues <DateTimePoint> chartValues) { CartesianMapper <DateTimePoint> pointMapperConfig = Mappers.Xy <DateTimePoint>() .X(dateTimeDataPoint => dateTimeDataPoint.DateTime.Ticks * 1.0 / TimeSpan.FromHours(1).Ticks) .Y(dateTimeDataPoint => dateTimeDataPoint.Value); return(new SeriesCollection(pointMapperConfig) { new LineSeries() { Values = chartValues, Stroke = parameter as Brush ?? SeriesColor, Fill = Brushes.Transparent, } }); } return(null); }