private void AddDataToChart(ChartData chartData) { if (_currentSection != null) { _currentSection.SectionWidth = chartData.TimeSeconds - _currentSection.Value; } if (_previousChartData != null) { if (_previousChartData.Running && !chartData.Running) { _currentSection = new AxisSection() { Value = _previousChartData.TimeSeconds, SectionWidth = chartData.TimeSeconds - _previousChartData.TimeSeconds, Fill = PausedSectionBrush }; Sections.Add(_currentSection); } else if (!_previousChartData.Running && chartData.Running) { _currentSection = null; } } ChartValues.Add(chartData); }
private void UpdateGates() { AxisSection RASection = HistChart.AxisX[0].Sections[0]; AxisSection ASection = HistChart.AxisX[0].Sections[1]; RASection.Value = preDelay; RASection.SectionWidth = gateWidth; ((VisualElement)HistChart.VisualElements[0]).X = preDelay + (gateWidth / 2); ASection.Value = preDelay + longDelay; ASection.SectionWidth = gateWidth; ((VisualElement)HistChart.VisualElements[1]).X = preDelay + longDelay + (gateWidth / 2); CalculateGates(); }
private void ClearSession(bool hideScrollbar) { if (_session != null) { _session.RemoveListener(_sessionListener); _session = null; } DisposeHelper.SafeDispose(ref _sysInfoProcessor); DisposeHelper.SafeDispose(ref _eventsProcessor); ViewPortMinValue = 0; ViewPortMaxValue = ViewPortSize; _chartValues.Clear(); _jitSeriesValues.Clear(); _jitEventProcessor.Clear(); _gcSeriesValues.Clear(); _gcEventProcessor.Clear(); LiveTimeline.AxisX[0].Sections.Clear(); LiveTimeline.AxisY[1].MaxValue = 1000; LiveTimeline.Update(true, true); _rangeMaxValue = ViewPortSize; _sysInfoStartTimeSeconds = -1; _profilingEventsDeltaSeconds = 0; _sysInfoEventsDeltaSeconds = 0; _areDeltasSet = false; _previousSysInfo = null; _previousChartData = null; _currentPausedSection = null; _currentDebugBreakSection = null; UpdateScrollBar(hideScrollbar); SessionControlButton.Visibility = Visibility.Collapsed; SessionControlButton.IsEnabled = false; _session = null; }
private SectionsCollection GetSections(bool getToday, bool getWeekends) { var axisSections = new SectionsCollection(); if (getToday) { var todayAxisSection = new AxisSection { Draggable = false, SectionOffset = 0.5 + (DateTime.Today - period.startDate).Days, SectionWidth = 1, Fill = Application.Current.Resources["Alpha-Green"] as SolidColorBrush }; axisSections.Add(todayAxisSection); } if (getWeekends) { var start = period.startDate; int daysUntilSaturday = ((int)DayOfWeek.Saturday - (int)start.DayOfWeek + 7) % 7; var saturday = start.AddDays(daysUntilSaturday); while ((period.endDate - saturday).Days >= 0) { var weekendSection = new AxisSection { Draggable = false, SectionOffset = 0.5 + (saturday - period.startDate).Days, SectionWidth = 2, Fill = Application.Current.Resources["Alpha-Gray-1"] as SolidColorBrush }; axisSections.Add(weekendSection); saturday = saturday.AddDays(7); } } return(axisSections); }
public FunnelExample() { InitializeComponent(); //Credit https://dribbble.com/shots/2673159-Funnel-UI-concept //Icons http://www.flaticon.com/authors/madebyoliver BackColor = Color.FromArgb(255, 20, 20, 75); cartesianChart1.Series.Add(new LineSeries { Values = new ChartValues <double> { 100, 85, 50, 35, 5, 3 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(33, 106, 254)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }); cartesianChart1.Series.Add(new LineSeries { Values = new ChartValues <double> { -100, -85, -50, -35, -5, 3 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(33, 106, 254)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }); var s2 = new LineSeries { Values = new ChartValues <double> { 110, 94, 60, 40, 10, 10 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 44, 120)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }; var s3 = new LineSeries { Values = new ChartValues <double> { -110, -94, -60, -40, -10, -10 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 44, 120)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }; var s4 = new LineSeries { Values = new ChartValues <double> { 120, 104, 70, 50, 15, 15 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(20, 24, 89)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }; var s5 = new LineSeries { Values = new ChartValues <double> { -120, -104, -70, -50, -15, -15 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(20, 24, 89)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }; Panel.SetZIndex(s2, -1); Panel.SetZIndex(s3, -1); Panel.SetZIndex(s4, -2); Panel.SetZIndex(s5, -2); cartesianChart1.Series.Add(s2); cartesianChart1.Series.Add(s3); cartesianChart1.Series.Add(s4); cartesianChart1.Series.Add(s5); cartesianChart1.AxisY.Add(new Axis { IsEnabled = false, ShowLabels = false }); var section1 = new AxisSection { Value = 1.5, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromArgb(38, 255, 255, 255)), StrokeThickness = 5 }; var section2 = new AxisSection { Value = 3.5, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromArgb(38, 255, 255, 255)), StrokeThickness = 5 }; Panel.SetZIndex(section1, 1); Panel.SetZIndex(section2, 1); cartesianChart1.AxisX.Add(new Axis { IsEnabled = false, ShowLabels = false, Sections = new SectionsCollection { section1, section2 } }); var userUri = new Uri(@"Cartesian/FunnelChart/Resources/user.png", UriKind.Relative); var fingerUri = new Uri("Cartesian/FunnelChart/Resources/fingerprint.png", UriKind.Relative); var viewUri = new Uri("Cartesian/FunnelChart/Resources/view.png", UriKind.Relative); var ve1 = new VisualElement { X = 0.75, Y = 120, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new StackPanel { Children = { new Image { Source = new BitmapImage(userUri) }, new TextBlock { Text = "LOADED THE AD", FontSize = 16, Foreground = Brushes.White } } } }; var ve2 = new VisualElement { X = 0.75, Y = 0, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new TextBlock { Text = "100 %", FontSize = 40, Foreground = Brushes.White } }; var ve3 = new VisualElement { X = 2.5, Y = 120, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new StackPanel { Children = { new Image { Source = new BitmapImage(viewUri) }, new TextBlock { Text = "SAW THE AD", FontSize = 16, Foreground = Brushes.White } } } }; var ve4 = new VisualElement { X = 2.5, Y = 0, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new TextBlock { Text = "50 %", FontSize = 40, Foreground = Brushes.White } }; var ve5 = new VisualElement { X = 4.25, Y = 120, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new StackPanel { Children = { new Image { Source = new BitmapImage(fingerUri) }, new TextBlock { Text = "INTERACTED", FontSize = 16, Foreground = Brushes.White } } } }; var ve6 = new VisualElement { X = 4.25, Y = 0, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new TextBlock { Text = "100 %", FontSize = 40, Foreground = Brushes.White } }; cartesianChart1.VisualElements.AddRange(new[] { ve1, ve2, ve3, ve4, ve5, ve6 }); }
private void FunnelChart() { cartesianChart2.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 255, 255)); cartesianChart2.Series.Add(new LineSeries { Values = new ChartValues <double> { 100, 85, 50, 35, 5, 3 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(33, 106, 254)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }); cartesianChart2.Series.Add(new LineSeries { Values = new ChartValues <double> { -100, -85, -50, -35, -5, 3 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(33, 106, 254)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }); var s2 = new LineSeries { Values = new ChartValues <double> { 110, 94, 60, 40, 10, 10 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 44, 120)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }; var s3 = new LineSeries { Values = new ChartValues <double> { -110, -94, -60, -40, -10, -10 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 44, 120)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }; var s4 = new LineSeries { Values = new ChartValues <double> { 120, 104, 70, 50, 15, 15 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(20, 24, 89)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }; var s5 = new LineSeries { Values = new ChartValues <double> { -120, -104, -70, -50, -15, -15 }, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(20, 24, 89)), PointGeometry = null, AreaLimit = 0, StrokeThickness = 0 }; Panel.SetZIndex(s2, -1); Panel.SetZIndex(s3, -1); Panel.SetZIndex(s4, -2); Panel.SetZIndex(s5, -2); cartesianChart2.Series.Add(s2); cartesianChart2.Series.Add(s3); cartesianChart2.Series.Add(s4); cartesianChart2.Series.Add(s5); cartesianChart2.AxisY.Add(new Axis { IsEnabled = false, ShowLabels = false }); var section1 = new AxisSection { Value = 1.5, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromArgb(38, 255, 255, 255)), StrokeThickness = 5 }; var section2 = new AxisSection { Value = 3.5, Stroke = new SolidColorBrush(System.Windows.Media.Color.FromArgb(38, 255, 255, 255)), StrokeThickness = 5 }; Panel.SetZIndex(section1, 1); Panel.SetZIndex(section2, 1); cartesianChart2.AxisX.Add(new Axis { IsEnabled = false, ShowLabels = false, Sections = new SectionsCollection { section1, section2 } }); var userUri = new Uri(@"Cartesian/FunnelChart/Resources/user.png", UriKind.Relative); var fingerUri = new Uri("Cartesian/FunnelChart/Resources/fingerprint.png", UriKind.Relative); var viewUri = new Uri("Cartesian/FunnelChart/Resources/view.png", UriKind.Relative); List <double> Percentages = new List <double>(); int totalClients = clients.GetClientCount(clients); List <double> salesPipeline = clients.GetClientByPipeline(clients); foreach (var item in salesPipeline) { Percentages.Add(Math.Round(item / totalClients, 4) * 100); } var ve1 = new VisualElement { X = 0.75, Y = 150, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new StackPanel { Children = { new System.Windows.Controls.Image { Source = new BitmapImage(userUri) }, new TextBlock { Text = "Awareness", FontSize = 16, Foreground = System.Windows.Media.Brushes.Black } } } }; var ve2 = new VisualElement { X = 0.75, Y = 0, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new TextBlock { Text = $"{Percentages[0]}%", FontSize = 40, Foreground = System.Windows.Media.Brushes.Black } }; var ve3 = new VisualElement { X = 1.9, Y = 150, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new StackPanel { Children = { new System.Windows.Controls.Image { Source = new BitmapImage(viewUri) }, new TextBlock { Text = "Interest", FontSize = 16, Foreground = System.Windows.Media.Brushes.Black } } } }; var ve4 = new VisualElement { X = 1.9, Y = 0, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new TextBlock { Text = $"{Percentages[1]}%", FontSize = 40, Foreground = System.Windows.Media.Brushes.Black } }; var ve5 = new VisualElement { X = 3.1, Y = 150, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new StackPanel { Children = { new System.Windows.Controls.Image { Source = new BitmapImage(fingerUri) }, new TextBlock { Text = "Decision", FontSize = 16, Foreground = System.Windows.Media.Brushes.Black } } } }; var ve6 = new VisualElement { X = 3.1, Y = 0, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new TextBlock { Text = $"{Percentages[2]}%", FontSize = 40, Foreground = System.Windows.Media.Brushes.Black } }; var ve7 = new VisualElement { X = 4.25, Y = 150, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new StackPanel { Children = { new System.Windows.Controls.Image { Source = new BitmapImage(fingerUri) }, new TextBlock { Text = "Action", FontSize = 16, Foreground = System.Windows.Media.Brushes.Black } } } }; var ve8 = new VisualElement { X = 4.25, Y = 0, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, UIElement = new TextBlock { Text = $"{Percentages[3]}%", FontSize = 40, Foreground = System.Windows.Media.Brushes.Black } }; cartesianChart2.VisualElements.AddRange(new[] { ve1, ve2, ve3, ve4, ve5, ve6, ve7, ve8 }); }
} // ProfilerEventProcessor private void AddDataToChart(SysInfoData sysInfoData) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); if (!_areDeltasSet && (_sysInfoStartTimeSeconds >= 0)) { DateTime profilerStartTimeUtc = _session.ProfilerStartTimeUtc; if (profilerStartTimeUtc != DateTime.MinValue) { _areDeltasSet = true; DateTime sysInfoStartTime = _sysInfoStartTimeSeconds.UnixTimeToDateTime(); _profilingEventsDeltaSeconds = (profilerStartTimeUtc - sysInfoStartTime).TotalSeconds; if (_profilingEventsDeltaSeconds < 0) { _sysInfoEventsDeltaSeconds = -_profilingEventsDeltaSeconds; _profilingEventsDeltaSeconds = 0; } // update existing chart items var savedSeries = new List <ISeriesView>(SeriesCollection); SeriesCollection.Clear(); SeriesCollection.AddRange(savedSeries); DebugWrite( $"Profiler start time: {profilerStartTimeUtc.ToString("yyyy-MM-dd HH:mm:ss.fff")} Z. " + $"Profiling events delta: {_profilingEventsDeltaSeconds:F3} s. " + $"System information events delta: {_sysInfoEventsDeltaSeconds:F3} s"); } } bool isBreakState = (ProfilerPlugin.Instance.DebugMode == Microsoft.VisualStudio.Shell.Interop.DBGMODE.DBGMODE_Break); if (_isBreakState != isBreakState) // happens sometimes { _isBreakState = isBreakState; UpdateControlsOnDebugStateChange(isBreakState); } if (_currentDebugBreakSection != null) { _currentDebugBreakSection.SectionWidth = sysInfoData.TimeSeconds + _sysInfoEventsDeltaSeconds - _currentDebugBreakSection.Value; if (!_isBreakState) { DebugWrite($"Debug break section finished. Duration is {_currentDebugBreakSection.SectionWidth:F3} sec"); _currentDebugBreakSection = null; } } else if (_isBreakState) { if (_currentDebugBreakSection == null) { _currentDebugBreakSection = new AxisSection() { Value = sysInfoData.TimeSeconds + _sysInfoEventsDeltaSeconds, SectionWidth = 0.001, // 1 msec Fill = DebugBreakSectionBrush }; LiveTimeline.AxisX[0].Sections.Add(_currentDebugBreakSection); DebugWrite($"Debug break section started at {_currentDebugBreakSection.Value:F3} sec"); } } AxisSection newPausedSection = null; if (sysInfoData.Running) { if ((_previousChartData != null) && !_previousChartData.Running) { _currentPausedSection = null; } } else { if (_previousChartData != null) { if (_previousChartData.Running) { newPausedSection = new AxisSection() { Value = sysInfoData.TimeSeconds + _sysInfoEventsDeltaSeconds, SectionWidth = 0.001, // 1 msec /*!! Value = _previousChartData.TimeSeconds + _sysInfoEventsDeltaSeconds, * SectionWidth = sysInfoData.TimeSeconds - _previousChartData.TimeSeconds,*/ }; } } else { newPausedSection = new AxisSection() { Value = 0, SectionWidth = sysInfoData.TimeSeconds + _sysInfoEventsDeltaSeconds, }; } } if (newPausedSection != null) { newPausedSection.Fill = PausedSectionBrush; _currentPausedSection = newPausedSection; LiveTimeline.AxisX[0].Sections.Add(_currentPausedSection); } else if (_currentPausedSection != null) { _currentPausedSection.SectionWidth = sysInfoData.TimeSeconds + _sysInfoEventsDeltaSeconds - _currentPausedSection.Value; } _chartValues.Add(sysInfoData); List <ClrJobItem> newClrJobItems; newClrJobItems = _jitEventProcessor.TakeJobItems(); if (newClrJobItems != null) { AddClrJobItems(_jitSeriesValues, newClrJobItems, "JIT"); } newClrJobItems = _gcEventProcessor.TakeJobItems(); if (newClrJobItems != null) { AddClrJobItems(_gcSeriesValues, newClrJobItems, "GC"); } }