private void AddPointInChart(DataSeries lineSeries, string _xCategory, double _newYValue, bool _assignXCategory) { int _countPoint = lineSeries.Count(); if (_countPoint != 0) { DataPoint _lastPoint = lineSeries[_countPoint - 1]; if (_lastPoint.XCategory != _xCategory) { if (_assignXCategory) { lineSeries.Add(new DataPoint() { YValue = _newYValue, XCategory = _xCategory }); } else { //DataPoint _penultPoint = lineSeries[_countPoint - 2]; lineSeries.Add(new DataPoint() { YValue = _lastPoint.YValue, XCategory = _xCategory }); } } else { if (_assignXCategory) { _lastPoint.YValue = _newYValue; _lastPoint.XCategory = _xCategory; } } } else { if (_assignXCategory) { lineSeries.Add(new DataPoint() { YValue = _newYValue, XCategory = _xCategory }); } } }
private LineSeries MetaSerieLag(DataType datatype, GrowthMeasurements growthMeasurements) { if (!growthMeasurements.VariableMetaDatas.ContainsKey(datatype)) { return(null); } var metaSerieLag = CreateMetaSerie(Colors.Violet, 8, ShapeType.Ellipse); var dataSeries = new DataSeries <double, double>("Lag Macro Data"); foreach (var metaData in growthMeasurements.VariableMetaDatas[datatype].Lag) { foreach (var groundPoint in metaData.GroundPoints) { var point = new DataPoint <double, double>(groundPoint.Time, groundPoint.OD); dataSeries.Add(point); } } foreach (var metaData in growthMeasurements.VariableMetaDatas[datatype].Lag) { foreach (var slopePoint in metaData.SlopePoints) { var point = new DataPoint <double, double>(slopePoint.Time, slopePoint.OD); dataSeries.Add(point); } } foreach (var metaData in growthMeasurements.VariableMetaDatas[datatype].Lag) { var point = new DataPoint <double, double>(metaData.InterceptTime, metaData.InterceptOD); dataSeries.Add(point); } metaSerieLag.DataSeries = dataSeries; return(metaSerieLag); }
public static void FillWithSampleBubbleData(DataSeries series) { series.Add(new DataPoint { YValue = 20, BubbleSize = 40 }); series.Add(new DataPoint { YValue = 40, BubbleSize = 80 }); series.Add(new DataPoint { YValue = 80, BubbleSize = 20 }); series.Add(new DataPoint { YValue = 60, BubbleSize = 100 }); series.Add(new DataPoint { YValue = 10, BubbleSize = 20 }); }
void generateProgress(A6WEntryDTO entry) { var series = new DataSeries <string, double>(); series.Add(new DataPoint <string, double>(A6WEntryStrings.usrA6WProgress_Completed, entry.MyTraining.PercentageCompleted)); series.Add(new DataPoint <string, double>(A6WEntryStrings.usrA6WProgress_NotCompleted, 100 - entry.MyTraining.PercentageCompleted)); MainChart.DataSeries = series; }
//string _DeviceName; // Constructor public MainPage() { InitializeComponent(); Application.Current.Host.Settings.EnableFrameRateCounter = true; PrintInfo(); /////////////////////////// //Line Graph ////////////////////////// //We need one data series for each chart series DataSeries <double, double> xData = new DataSeries <double, double>("y=x"); DataSeries <double, double> xSquaredData = new DataSeries <double, double>("y=x^2"); DataSeries <double, double> xCubedData = new DataSeries <double, double>("y=x^3"); //Add the data points to the data series according to the correct equation for (double i = 0.0; i < 2; i += 0.01) { xData.Add(new DataPoint <double, double>() { X = i, Y = i }); xSquaredData.Add(new DataPoint <double, double>() { X = i, Y = i * i }); xCubedData.Add(new DataPoint <double, double>() { X = i, Y = i * i * i }); } //Finally, associate the data series with the chart series exampleChart.Series[0].DataSeries = xData; exampleChart.Series[1].DataSeries = xSquaredData; exampleChart.Series[2].DataSeries = xCubedData; ///////////////////////// //Pie Chart //////////////////////// DataSeries <string, double> series = new DataSeries <string, double>(); series.Add(new DataPoint <string, double>("F. Alonso", 10)); series.Add(new DataPoint <string, double>("J. Button", 2)); series.Add(new DataPoint <string, double>("L. Hamilton", 3)); series.Add(new DataPoint <string, double>("S. Vettel", 5)); series.Add(new DataPoint <string, double>("M. Webber", 4)); MainChart.DataSeries = series; }
public void NewHigh(int bar, double price) { // If no low since last high and this high is higher, // the replace the last high point, else add it. if (highs.Count > 0 && lows.Count > 0 && lows[0].X < highs[0].X) { if (price > highs[0].Y) { // Make the replaced one Red. Chart.DrawBox(Color.Red, (int)highs[0].X, highs[0].Y); highs[0] = new ChartPoint(bar, price); } else { // Skip a lower high without a low in between. return; } } else { highs.Add(new ChartPoint(bar, price)); } Chart.DrawBox(Color.Blue, bar, price); if (highs.Count > 1 && lows.Count > 1) { try { ChartPoint point1 = highs[0]; ChartPoint point2 = FindPoint(lows, point1.X); ChartPoint point3 = FindPoint(highs, point2.X); if (point1.Y < point3.Y) { WideChannel wchannel = new WideChannel(Trend.Down, Bars); wchannel.Chart = Chart; wchannel.addHigh(point1.X); wchannel.addLow(point2.X); wchannel.addHigh(point3.X); wchannel.TryDraw(); channels.Add(wchannel); // Chart.DrawLine(Color.Red,highs[1].X,highs[1].Y,highs[0].X,highs[0].Y,LineStyle.Solid); } } catch (ApplicationException) { // Return if FindPoint failed. return; } } }
private LineSeries MetaSerieRate(DataType datatype, GrowthMeasurements growthMeasurements, bool isFirstDeriv = false) { if (!growthMeasurements.VariableMetaDatas.ContainsKey(datatype)) { return(null); } var metaSerieRate = CreateMetaSerie(Colors.Red, 12, ShapeType.Cross); var dataSeries = new DataSeries <double, double>("Rate Macro Data"); foreach (var metaData in growthMeasurements.VariableMetaDatas[datatype].Rate) { float od; if (isFirstDeriv) { od = growthMeasurements.GetMeasurements(DataType.FirstDerivative).First(m => Math.Abs(m.Time - metaData.Time) < double.Epsilon).OD; } else { od = metaData.OD; } var point = new DataPoint <double, double>(metaData.Time, od); dataSeries.Add(point); } metaSerieRate.DataSeries = dataSeries; return(metaSerieRate); }
private void UpdateACFChart() { Complex[] acf = m_contourInformation.Contour.ACF; var acfValueDataSeries = new DataSeries <int, float>("ACF (absolute value)"); var acfArgumentDataSeries = new DataSeries <int, float>("ACF (argument)"); for (int i = 0; i < acf.Length; i++) { acfValueDataSeries.Add(new DataPoint <int, float>(i, acf[i].AbsoluteValue())); float argument = acf[i].ArgumentDegrees(); if (argument < 0) { argument += 360; } acfArgumentDataSeries.Add(new DataPoint <int, float>(i, argument)); } ACFValueSeries.DataSeries = acfValueDataSeries; ACFArgumentSeries.YAxis = ACFArgumentAxis; ACFArgumentSeries.DataSeries = acfArgumentDataSeries; }
protected override void UpdateData(float[] data) { // Update the DataSeries of each Line and add the last sampling of all Lines in a Dictionary. Dictionary <int, float> dataDict = new Dictionary <int, float>(); Transform transf = PlotterGroup.transform; for (int idx = 0; idx < transf.childCount; idx++) { string name = MeshUtils.NameGenerator(Identifier, idx); GameObject obj = transf.Find(name).gameObject; DataSeries pltr = obj.GetComponent <DataSeries>(); pltr.UpdateDataLength(); // Sometimes the mData might have been changed during scheduledUpdate if (idx < data.Length) { pltr.Add(data[idx]); dataDict.Add(idx, data[idx]); } } // Rearranging the order of the legend due to the last sampling of each Line, from the Dictionary. List <KeyValuePair <int, float> > dataList = dataDict.ToList(); dataList.Sort((firstPair, nextPair) => { return(firstPair.Value.CompareTo(nextPair.Value)); }); dataList.Reverse(); //string str = ""; legendOrder = new int[dataList.Count]; for (int i = dataList.Count - 1; i >= 0; i--) { legendOrder[i] = dataList[i].Key; } }
public void PlotProfitChart() { string saveSort = tradeEstimateSource.Sort; tradeEstimateSource.Sort = ""; data.tmpDS.tradeEstimateDataTable tbl = tradeEstimateSource.DataSource as data.tmpDS.tradeEstimateDataTable; chartPnl.ResetGraph(); chartPnl.RemoveAllCurves(); DataSeries xSeries = new DataSeries(); DataSeries ySeries = new DataSeries(); for (int idx = 0; idx < tbl.Count; idx++) { if (!allTransactionMenuItem.Checked && tbl[idx].ignored) { continue; } ySeries.Add((double)tbl[idx].profit); xSeries.Add(tbl[idx].onDate.ToOADate()); } //Handle bug in graph for curve with only on point ???? if (ySeries.Count > 1) { chartPnl.myGraphObj.SetSeriesX(xSeries.Values, Charts.AxisType.DateAsOrdinal); chartPnl.myGraphObj.SetFont(Settings.sysChartFontSize); chartPnl.myGraphObj.ChartMarginTOP = constProfitChartMarginTOP; chartPnl.myGraphObj.ChartMarginBOTTOM = constProfitChartMarginBOTTOM; CurveItem curveItem = chartPnl.myGraphObj.AddCurveBar("profit", ySeries.Values, Settings.sysChartVolumesColor, Settings.sysChartVolumesColor, 1); chartPnl.myGraphObj.DefaultViewport(); chartPnl.PlotGraph(); } tradeEstimateSource.Sort = saveSort; }
private void Checkbox_Click_1(object sender, RoutedEventArgs e) { CheckBox checkbox = (CheckBox)sender; int index = (int)checkbox.Tag; if (checkbox.IsChecked == true) { _frequencyDomainLinkedToCheckboxes[index] = new Complex(); } else { _frequencyDomainLinkedToCheckboxes[index] = _frequencyDomain[index]; } FFTW fftw = new FFTW(); _ret = fftw.Backward(_frequencyDomainLinkedToCheckboxes); DataSeries <double, double> points = new DataSeries <double, double>("Data"); for (int c = 0; c < _ret.Length; c++) { points.Add(new DataPoint <double, double> { X = c, Y = _ret[c] }); } dataChart.Series[0].DataSeries = points; }
public void SolveDiffEquation(double T, double b, double sigma, double f, int n) { try { double[] u = new double[n + 1]; u[0] = 0; u[n] = 0; var coefficients = FindCoefficients(T, b, sigma, f, n).Reverse().ToArray(); for (int i = 1; i < n; i++) { double sum = 0; for (int j = 1; j < n; j++) { double x = (double)i / n; sum += coefficients[j - 1] * CourantFun(x, n, j); } u[i] = sum; } DataSeries <double, double> fun = new DataSeries <double, double>("u(x)"); for (int i = 0; i < n + 1; i++) { fun.Add(new DataPoint <double, double>() { X = (double)i / n, Y = u[i] }); } exampleChart.Series[0].DataSeries = fun; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void SolveDiffEquation(double T, double b, double sigma, double f, int n) { try { double[] u = new double[n + 1]; u[0] = 0; u[n] = 0; var coefficients = FindCoefficients(T, b, sigma, f, n).Reverse().ToArray(); for (int i = 1; i < n; i++) { double sum = 0; for (int j = 1; j < n; j++) { double x = (double)i / n; sum += coefficients[j - 1]*CourantFun(x, n, j); } u[i] = sum; } DataSeries<double, double> fun = new DataSeries<double, double>("u(x)"); for (int i = 0; i < n + 1; i++) { fun.Add(new DataPoint<double, double>() { X = (double)i / n, Y = u[i] }); } exampleChart.Series[0].DataSeries = fun; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private IDataSeries GenerateDataSeries(string filename, string legendName) { //Create a data series with the appropriate name var series = new DataSeries <DateTime, float>(legendName); using (StreamReader streamReader = new StreamReader(Helpers.GetApplicationResourceStream("Opentime/Data/" + filename).Stream)) { float rebaseValue = 0; while (streamReader.Peek() >= 0) { string line = streamReader.ReadLine(); string[] parts = line.Split(','); //the files are formatted like so: "DD/MM/YYYY,VALUE" String[] dateParts = parts[0].Split('/'); DateTime time = new DateTime(int.Parse(dateParts[2]), int.Parse(dateParts[0]), int.Parse(dateParts[1])); float rate = float.Parse(parts[1]); //If it's the first data point, work out the rebase value if (rebaseValue == 0) { rebaseValue = 100 / rate; } //rebase value to 0 rate = (rate * rebaseValue) - 100; series.Add(new DataPoint <DateTime, float>(time, rate)); } } return(series); }
public static void FillWithSampleData(DataSeries series, int numberOfItems, int sum) { int localSum = 0; Random random = new Random((int)(series.GetHashCode() + DateTime.Now.Ticks)); for (int i = 0; i < numberOfItems; i++) { int randomNumber = 0; while (randomNumber <= 0) { randomNumber = random.Next(sum / numberOfItems - 3, sum / numberOfItems + 3); } if (localSum + randomNumber > sum) { randomNumber = sum - localSum; } if ((i == numberOfItems - 1) && (localSum + randomNumber < sum)) { randomNumber = sum - localSum; } localSum += randomNumber; DataPoint dataPoint = new DataPoint(); dataPoint.YValue = randomNumber; series.Add(dataPoint); } }
public MainPage() { InitializeComponent(); DataSeries lineSeries = new DataSeries(); lineSeries.LegendLabel = "Monthly Sales"; lineSeries.Definition = new LineSeriesDefinition(); Random r = new Random(0); for (int i = 0; i < 12; i++) { lineSeries.Add(new DataPoint() { YValue = i + r.Next(0, 20) }); } radChart.DefaultView.ChartArea.DataSeries.Add(lineSeries); string[] months = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", }; for (int i = 0; i < months.Length; i++) { radChart.DefaultView.ChartArea.AxisX.TickPoints[i].Label = months[i]; } }
private void fillChartByDistance(IList <GPSPointViewModel> points, LineSeries speedSeries, LineSeries altitudeSeries) { var xAxis = new LinearAxis(); xAxis.ShowMinorTicks = false; xAxis.ShowMajorGridlines = false; XAxis = xAxis; XAxis.Title = GPSStrings.GpsTrackerChart_XAxis_Distance; var speedData = new DataSeries <decimal, decimal>(GPSStrings.GpsTrackerChart_YAxis_Speed); speedSeries.DataSeries = speedData; var altitudeData = new DataSeries <decimal, decimal>(GPSStrings.GpsTrackerChart_YAxis_Altitude); altitudeSeries.DataSeries = altitudeData; for (int index = 0; index < points.Count; index++) { var gpsPoint1 = points[index]; if (gpsPoint1.Point.IsPoint()) { var displayDistance = gpsPoint1.Distance.ToDisplayDistance(); var data = new DataPoint <decimal, decimal>(displayDistance, ((decimal)gpsPoint1.Point.Altitude).ToDisplayAltitude()); data.Tag = gpsPoint1; altitudeData.Add(data); var speed = new DataPoint <decimal, decimal>(displayDistance, ((decimal)gpsPoint1.Point.Speed).ToDisplaySpeed()); speed.Tag = gpsPoint1; speedData.Add(speed); } } }
public static void FillWithSampleRangeData(DataSeries series, int numberOfItems) { Random r = new Random(); DataPoint data = new DataPoint(); data.Low = r.Next(20, 70); data.High = data.Low + r.Next(20, 30); series.Add(data); for (int i = 1; i < numberOfItems; i++) { data = new DataPoint(); int change = r.Next(0, 24) - 12; data.Low = series[i - 1].Low + change; data.High = Math.Max(series[i - 1].High + change + r.Next(0, 12) - 6, data.Low + 4); series.Add(data); } }
public DailyHighLow() { _highSeres = (ValueDataSeries)DataSeries[0]; _highSeres.Name = "High"; _highSeres.Color = Color.FromArgb(255, 135, 135, 135); _highSeres.VisualType = VisualMode.Square; DataSeries.Add(_lowSeres); DataSeries.Add(_medianSeres); DataSeries.Add(_yesterdaymedianaSeres); }
private static DataSeries <double, double> CreateNewSeries(List <GrowthMeasurement> rawGrowthMeasurements, string title) { var newRawGraph = new DataSeries <double, double>(title); foreach (var growthMeasurement in rawGrowthMeasurements) { newRawGraph.Add(growthMeasurement.Time, growthMeasurement.OD); } return(newRawGraph); }
protected bool NewChannel(int lastLineBar, Trend trend) { Channel channel = new Channel(Bars); channel.LongColor = LongColor; channel.ShortColor = ShortColor; int bar = Bars.CurrentBar; int lookBack = 1; channel.InterceptBar = lastLineBar; for ( ; bar > Bars.CurrentBar - Bars.Capacity && bar >= lastLineBar; bar--) { switch (trend) { case Trend.Flat: channel.addPoint(bar, Formula.Middle(Bars, Bars.CurrentBar - bar)); break; case Trend.Up: channel.addPoint(bar, Bars.Low[Bars.CurrentBar - bar]); channel.addPoint2(bar, Bars.High[Bars.CurrentBar - bar]); break; case Trend.Down: channel.addPoint(bar, Bars.High[Bars.CurrentBar - bar]); channel.addPoint2(bar, Bars.Low[Bars.CurrentBar - bar]); break; } } if (channel.CountPoints > lookBack) { channel.Calculate(); channel.UpdateEnds(); // If new channel isn't in the direction expected // then forget it. if (trend == Trend.Up && !channel.IsUp) { return(false); } else if (trend == Trend.Down && !channel.IsDown) { return(false); } channel.calcMaxDev(Bars); if (drawLines) { channel.DrawChannel(Chart, extend, drawDashedLines); } lines.Add(channel); hasNewChannel = true; return(true); } return(false); }
public void GenerateDataSeries(Dictionary<string,double> data, ChartBy chartBy) { var series = new DataSeries<string, double>(); foreach (var d in data) { series.Add(new DataPoint<string, double>((chartBy == ChartBy.Cols ? "Column " : "Row ") + d.Key, d.Value)); } MainChart.DataSeries = series; }
public void GenerateDataSeries(Dictionary <string, double> data, ChartBy chartBy) { var series = new DataSeries <string, double>(); foreach (var d in data) { series.Add(new DataPoint <string, double>((chartBy == ChartBy.Cols ? "Column " : "Row ") + d.Key, d.Value)); } MainChart.DataSeries = series; }
//public static void LogTicks(long symbol, int quantity) //{ // symbols = new Dictionary<long, long>(); // LogTicks(symbol, quantity); // foreach( var kvp in symbols) // { // var otherSymbol = kvp.Value; // if( otherSymbol == symbol) continue; // for( var i=0; i<nextMetricId; i++) // { // var metric = metrics[i]; // LogTicks(otherSymbol, metric, quantity); // } // } //} public static void AddTick(int metricId, ref TickBinary binary) { var metric = metrics[metricId - 1]; if (metric.Enabled) { tickLog.Add(new DiagnoseTickEntry { MetricId = metricId, TickBinary = binary }); } }
public static DataSeries SMAFilter(string path, int len) { DataSeries f = new DataSeries(""); Bars bars = new Bars("", BarScale.Daily, 0); StreamReader sr = new StreamReader(path); while (sr.Peek() >= 0) { string next_line = sr.ReadLine(); string[] temp_ar = next_line.Split(' '); string date = temp_ar[0].Trim(); string open = temp_ar[1].Trim(); string high = temp_ar[2].Trim(); string low = temp_ar[3].Trim(); string close = temp_ar[4].Trim(); string volume = temp_ar[5].Trim(); if ((Convert.ToDouble(open) > 0) & (Convert.ToDouble(high) > 0) & (Convert.ToDouble(low) > 0) & (Convert.ToDouble(close) > 0)) { bars.Add(Convert.ToDateTime(date), Convert.ToDouble(open), Convert.ToDouble(high), Convert.ToDouble(low), Convert.ToDouble(close), Convert.ToDouble(volume)); } } sr.Close(); for (int b = len; b < bars.Count; b++) { if (bars.Close[b] > SMA.Value(b, bars.Close, len)) { f.Add(0, bars.Date[b]); } else { f.Add(1, bars.Date[b]); } } return(f); }
public static void FillWithSampleData(DataSeries series, int numberOfItems, int max, int deviation) { Random random = new Random((int)(series.GetHashCode() + DateTime.Now.Ticks)); if (deviation > max) deviation = max; for (int i = 0; i < numberOfItems; i++) { series.Add(new DataPoint(random.Next(max - deviation, max))); } }
public RVI() : base(true) { Panel = IndicatorDataProvider.NewPanel; ((ValueDataSeries)DataSeries[0]).Color = Colors.Green; DataSeries.Add(new ValueDataSeries("Signal") { VisualType = VisualMode.Line }); }
private void AddSeries(string key) { var dataSerie = new SerialDataSerie() { Name = key }; DictSeries.Add(key, dataSerie); DataSeries.Add(dataSerie); MessageBus.Current.SendMessage(dataSerie, "NewDataSerie"); }
public static void FillWithSampleData(DataSeries series, int numberOfItems) { Random random = new Random((int)(series.GetHashCode() + DateTime.Now.Ticks)); for (int i = 0; i < numberOfItems; i++) { int randomNumber = random.Next(30, 100); series.Add(new DataPoint { YValue = randomNumber }); } }
private void addSerise() { DataSeries series = new DataSeries(); series.Definition = new LineSeriesDefinition(); series.LegendLabel = "温度"; for (int i = 1; i < 20; i++) { series.Add(new DataPoint(DateTime.Now.AddMinutes(i).ToString("HH:mm:00"), i * i)); } radChart.DefaultView.ChartArea.DataSeries.Add(series); }
private void Button_Click_1(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == true) { TextBox_InputName.Text = ofd.FileName; FFTW fftw = new FFTW(); _input = DataLoader.Load(ofd.FileName); double[] inputCopy = new double[_input.Length]; _input.CopyTo(inputCopy, 0); _frequencyDomain = fftw.Forward(inputCopy); _frequencyDomainLinkedToCheckboxes = new Complex[_frequencyDomain.Length]; _frequencyDomain.CopyTo(_frequencyDomainLinkedToCheckboxes, 0); DataSeries <double, double> points = new DataSeries <double, double>("Magnitudes"); TheList = new ObservableCollection <CheckBoxBinder>(); List <CheckBoxBinder> mags = new List <CheckBoxBinder>(); for (int c = 0; c < _frequencyDomain.Length; c++) { points.Add(new DataPoint <double, double> { X = c, Y = _frequencyDomain[c].Magnitude }); mags.Add(new CheckBoxBinder { TheValue = _frequencyDomain[c].Magnitude, Index = c }); } foreach (CheckBoxBinder d in mags.OrderByDescending(m => m.TheValue)) { TheList.Add(d); } exampleChart.Series[0].DataSeries = points; this.DataContext = this; DataSeries <double, double> data = new DataSeries <double, double>("Data"); for (int c = 0; c < _input.Length; c++) { data.Add(new DataPoint <double, double> { X = c, Y = _input[c] }); } dataChart.Series[0].DataSeries = data; return; } }
public MainPage() //MainWindow() in WPF { InitializeComponent(); DataSeries series = new DataSeries(); series.Definition = new CustomCandleStickSeriesDefinition() { ItemStyle = this.LayoutRoot.Resources["CustomCandleStickStyle"] as Style }; series.Add(new DataPoint() { Open = 10, High = 30, Low = 5, Close = 15 }); series.Add(new DataPoint() { Open = 15, High = 40, Low = 10, Close = 20 }); series.Add(new DataPoint() { Open = 20, High = 35, Low = 15, Close = 30 }); series.Add(new DataPoint() { Open = 10, High = 25, Low = 5, Close = 18 }); series.Add(new DataPoint() { Open = 15, High = 40, Low = 10, Close = 20 }); series.Add(new DataPoint() { Open = 20, High = 35, Low = 9, Close = 30 }); series.Add(new DataPoint() { Open = 10, High = 25, Low = 5, Close = 15 }); series.Add(new DataPoint() { Open = 15, High = 30, Low = 7, Close = 25 }); RadChart1.DefaultView.ChartArea.DataSeries.Add(series); RadChart1.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed; RadChart1.DefaultView.ChartArea.AxisX.Title = "Experiment No"; RadChart1.DefaultView.ChartArea.AxisY.Title = "Results"; RadChart1.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Inside; }
private void Data() { DataSeries series = new DataSeries(); series.Definition = new Pie3DSeriesDefinition();// DoughnutSeriesDefinition();// Doughnut3DSeriesDefinition();// PieSeriesDefinition();// Pie3DSeriesDefinition(); radChart.Width = 600; radChart.Height = 300; for (int i = 1; i < 4; i++) { series.Add(new DataPoint(i, i * i)); } radChart.DefaultView.ChartArea.DataSeries.Add(series); }
public virtual void removePointsBefore(double x) { DataSeries <ChartPoint> newCoord = Factory.Engine.Series <ChartPoint>(); for (int i = coord.Count - 1; i >= 0; i--) { if (coord[i].X >= x || i < 3) { newCoord.Add(coord[i]); } } coord = newCoord; }
public static void FillWithSampleBubbleMixedData(DataSeries series) { series.Add(new DataPoint { YValue = 75, BubbleSize = -60 }); series.Add(new DataPoint { YValue = 10, BubbleSize = 40 }); series.Add(new DataPoint { YValue = 40, BubbleSize = -60 }); series.Add(new DataPoint { YValue = 20, BubbleSize = 50 }); series.Add(new DataPoint { YValue = 50, BubbleSize = 80 }); series.Add(new DataPoint { YValue = 30, BubbleSize = -40 }); }
private void Button_Click_1(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == true) { TextBox_InputName.Text = ofd.FileName; FFTW fftw = new FFTW(); _input = DataLoader.Load(ofd.FileName); double[] inputCopy = new double[_input.Length]; _input.CopyTo(inputCopy, 0); _frequencyDomain = fftw.Forward(inputCopy); _frequencyDomainLinkedToCheckboxes = new Complex[_frequencyDomain.Length]; _frequencyDomain.CopyTo(_frequencyDomainLinkedToCheckboxes, 0); DataSeries<double, double> points = new DataSeries<double, double>("Magnitudes"); TheList = new ObservableCollection<CheckBoxBinder>(); List<CheckBoxBinder> mags = new List<CheckBoxBinder>(); for (int c = 0; c < _frequencyDomain.Length; c++) { points.Add(new DataPoint<double, double> { X = c, Y = _frequencyDomain[c].Magnitude }); mags.Add(new CheckBoxBinder { TheValue = _frequencyDomain[c].Magnitude, Index = c }); } foreach (CheckBoxBinder d in mags.OrderByDescending(m => m.TheValue)) { TheList.Add(d); } exampleChart.Series[0].DataSeries = points; this.DataContext = this; DataSeries<double, double> data = new DataSeries<double, double>("Data"); for (int c = 0; c < _input.Length; c++) { data.Add(new DataPoint<double, double> { X = c, Y = _input[c] }); } dataChart.Series[0].DataSeries = data; return; } }
public void processCransData(Chart CurrentChart, List<int>Crans) { CurrentChart.Series.Clear(); DateTime min = DateTime.MaxValue; DateTime max = DateTime.MinValue; foreach (CranTaskInfo task in CurrentFilter.Data) { if (!task.Allowed) { if (task.NeedStartDate < min) min = task.NeedStartDate; if (task.NeedEndDate > max) max = task.NeedEndDate; } if (task.Allowed) { if (task.AllowDateStart < min) min = task.AllowDateStart; if (task.AllowDateEnd > max) max = task.AllowDateEnd; } } LineSeries nulSer = new LineSeries(); DataSeries<DateTime, double> nulP = new DataSeries<DateTime, double>(); nulP.Add(new DataPoint<DateTime, double>(min, 0.5)); nulP.Add(new DataPoint<DateTime, double>(max, 0.5)); nulSer.DataSeries = nulP; LineSeries ser15 = new LineSeries(); DataSeries<DateTime, double> p15 = new DataSeries<DateTime, double>(); p15.Add(new DataPoint<DateTime, double>(min, 1.5)); p15.Add(new DataPoint<DateTime, double>(max, 1.5)); ser15.DataSeries = p15; LineSeries ser3 = new LineSeries(); DataSeries<DateTime, double> p3 = new DataSeries<DateTime, double>(); p3.Add(new DataPoint<DateTime, double>(min, 2.5)); p3.Add(new DataPoint<DateTime, double>(max, 2.5)); ser3.DataSeries = p3; CurrentChart.Series.Add(nulSer); CurrentChart.Series.Add(ser15); CurrentChart.Series.Add(ser3); int i = 1; foreach (int cran in Crans){ processSingleCran(cran,CurrentChart,i++); } }
private void clearChart() { // graph //We need one data series for each chart series DataSeries<int, double> cc1 = new DataSeries<int, double>(cc1legend); DataSeries<int, double> cc2 = new DataSeries<int, double>(cc2legend); DataSeries<int, double> cc3 = new DataSeries<int, double>(cc3legend); for (int i = 1; i <= 5; i++) { cc1.Add(new DataPoint<int, double>() { X = i, Y = 0 }); cc2.Add(new DataPoint<int, double>() { X = i, Y = 0 }); cc3.Add(new DataPoint<int, double>() { X = i, Y = 0 }); } //Finally, associate the data series with the chart series userchart.Series[0].DataSeries = cc1; userchart.Series[1].DataSeries = cc2; userchart.Series[2].DataSeries = cc3; criticalComponent1.Text = ""; criticalComponent1.Text = ""; criticalComponent1.Text = ""; }
private void Checkbox_Click_1(object sender, RoutedEventArgs e) { CheckBox checkbox = (CheckBox)sender; int index = (int)checkbox.Tag; if (checkbox.IsChecked == true) { _frequencyDomainLinkedToCheckboxes[index] = new Complex(); } else { _frequencyDomainLinkedToCheckboxes[index] = _frequencyDomain[index]; } FFTW fftw = new FFTW(); _ret = fftw.Backward(_frequencyDomainLinkedToCheckboxes); DataSeries<double, double> points = new DataSeries<double, double>("Data"); for (int c = 0; c < _ret.Length; c++) { points.Add(new DataPoint<double, double> { X = c, Y = _ret[c] }); } dataChart.Series[0].DataSeries = points; }
private void reconstructGraph() { // graph //We need one data series for each chart series DataSeries<int, double> cc1 = new DataSeries<int, double>(cc1legend); DataSeries<int, double> cc2 = new DataSeries<int, double>(cc2legend); DataSeries<int, double> cc3 = new DataSeries<int, double>(cc3legend); String MyDocs = Environment.GetFolderPath(Environment.SpecialFolder.Personal); String ProjectLocation = "Visual Studio 2010\\Projects\\Kinect-Tracking-Project\\MatlabPrototypes\\FeatureDetection"; StreamReader FileStreamReader; FileStreamReader = File.OpenText(System.IO.Path.Combine(MyDocs, ProjectLocation) + "\\results.csv"); int i = 1; while (FileStreamReader.Peek() != -1) { string[] words; words = FileStreamReader.ReadLine().Split(','); double test = double.Parse(words[0]); if (test == -1) { continue; } double cc1v = test; double cc2v = double.Parse(words[1]); double cc3v = double.Parse(words[2]); if (cc1v == 0) { cc1v = 0.05; } if (cc2v == 0) { cc2v = 0.05; } if (cc3v == 0) { cc3v = 0.05; } cc1.Add(new DataPoint<int, double>() { X = i, Y = cc1v }); cc2.Add(new DataPoint<int, double>() { X = i, Y = cc2v }); cc3.Add(new DataPoint<int, double>() { X = i, Y = cc3v }); i = i + 1; } FileStreamReader.Close(); //Finally, associate the data series with the chart series userchart.Series[0].DataSeries = cc1; userchart.Series[1].DataSeries = cc2; userchart.Series[2].DataSeries = cc3; }
private void ExportChart(DataSet sheet) { graph.Width = 800; graph.Height = 600; graph.Measure(new System.Windows.Size(graph.Width, graph.Height)); graph.Arrange(new System.Windows.Rect(graph.DesiredSize)); graph.DefaultView.ChartArea.EnableAnimations = false; string semester = onBeginSheet ? " Beginning" : " End"; int num; if (onBeginSheet) { string name = sheet.Tables[0].Columns[LeftToExportBegin].ColumnName.ToString(); foreach (char c in name) { if (int.TryParse(c.ToString(), out num)) name = name.Remove(name.IndexOf(c)); } name = name.Trim(); graph.DefaultView.ChartTitle.Content = name + semester + " of Semester Results"; } else { string name = sheet.Tables[0].Columns[LeftToExportEnd].ColumnName.ToString(); foreach (char c in name) { if (int.TryParse(c.ToString(), out num)) name = name.Remove(name.IndexOf(c)); } name = name.Trim(); graph.DefaultView.ChartTitle.Content = name + semester + " of Semester Results"; } graph.DefaultView.ChartTitle.HorizontalAlignment = HorizontalAlignment.Center; graph.DefaultView.ChartLegend.UseAutoGeneratedItems = true; DataSeries barSeries = new DataSeries(); barSeries.LegendLabel = "Results"; barSeries.Definition = new BarSeriesDefinition(); string complete, very, moderate, somewhat, notatall, norating; if (onBeginSheet) { complete = sheet.Tables[0].Rows[startGraphBegin][LeftToExportBegin].ToString(); very = sheet.Tables[0].Rows[startGraphBegin + 1][LeftToExportBegin].ToString(); moderate = sheet.Tables[0].Rows[startGraphBegin + 2][LeftToExportBegin].ToString(); somewhat = sheet.Tables[0].Rows[startGraphBegin + 3][LeftToExportBegin].ToString(); notatall = sheet.Tables[0].Rows[startGraphBegin + 4][LeftToExportBegin].ToString(); norating = sheet.Tables[0].Rows[startGraphBegin + 5][LeftToExportBegin].ToString(); } else { complete = sheet.Tables[0].Rows[startGraphEnd][LeftToExportEnd].ToString(); very = sheet.Tables[0].Rows[startGraphEnd + 1][LeftToExportEnd].ToString(); moderate = sheet.Tables[0].Rows[startGraphEnd + 2][LeftToExportEnd].ToString(); somewhat = sheet.Tables[0].Rows[startGraphEnd + 3][LeftToExportEnd].ToString(); notatall = sheet.Tables[0].Rows[startGraphEnd + 4][LeftToExportEnd].ToString(); norating = sheet.Tables[0].Rows[startGraphEnd + 5][LeftToExportEnd].ToString(); } barSeries.Add(new DataPoint() { YValue = Convert.ToDouble(complete), XCategory = "Completely" }); barSeries.Add(new DataPoint() { YValue = Convert.ToDouble(very), XCategory = "Very" }); barSeries.Add(new DataPoint() { YValue = Convert.ToDouble(moderate), XCategory = "Moderately" }); barSeries.Add(new DataPoint() { YValue = Convert.ToDouble(somewhat), XCategory = "Somewhat" }); barSeries.Add(new DataPoint() { YValue = Convert.ToDouble(notatall), XCategory = "Not At All" }); barSeries.Add(new DataPoint() { YValue = Convert.ToDouble(norating), XCategory = "No Rating" }); graph.DefaultView.ChartArea.DataSeries.Add(barSeries); Dispatcher.BeginInvoke((Action)(() => { string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\Bar Charts\"; if (!Directory.Exists(filePath)) Directory.CreateDirectory(filePath); using (FileStream fs = File.Create(filePath + graph.DefaultView.ChartTitle.Content.ToString() + ".png")) { if (onBeginSheet) { graph.ExportToImage(fs, new PngBitmapEncoder()); if (LeftToExportBegin == 1) { ExportBtn.IsEnabled = false; if (importTwoGraphs) { onBeginSheet = false; ExportInitialGraph(); } LeftToExportText.Text = "Graphs successfully exported!"; } else ExportGraphs(); } else { graph.ExportToImage(fs, new PngBitmapEncoder()); if (LeftToExportEnd == 1) { ExportBtn.IsEnabled = false; LeftToExportText.Text = "Graphs successfully exported!"; } else ExportGraphs(); } } }), DispatcherPriority.ApplicationIdle, null); }
private void Data() { DataSeries series = new DataSeries(); series.Definition = new HorizontalBarSeriesDefinition(); radChart.Width = 600; radChart.Height = 300; for (int i = 1; i < 8; i++) { series.Add(new DataPoint(i, i * i)); } radChart.DefaultView.ChartArea.DataSeries.Add(series); }
private void chartMostRecent() { // graph //We need one data series for each chart series DataSeries<int, double> cc1 = new DataSeries<int, double>(cc1legend); DataSeries<int, double> cc2 = new DataSeries<int, double>(cc2legend); DataSeries<int, double> cc3 = new DataSeries<int, double>(cc3legend); IMongoSortBy sort = SortBy.Descending("time"); MongoCollection<BsonDocument> history = exerHist.GetCollection<BsonDocument>("history"); var query = Query.And(Query.EQ("exercise", exercisesCB.SelectedValue.ToString()), Query.EQ("name", user.Content.ToString())); int i = 1; bool perfect1 = true; bool perfect2 = true; bool perfect3 = true; bool pass = false; DateTime dateSearch = new DateTime(); foreach (BsonDocument rep in history.Find(query).SetSortOrder(sort)) { dateSearch = (DateTime)rep["timeid"]; pass = true; break; } if (pass) { var query1 = Query.And(Query.EQ("exercise", exercisesCB.SelectedValue.ToString()), Query.EQ("name", user.Content.ToString()), Query.EQ("timeid", dateSearch)); foreach (BsonDocument rep in history.Find(query1).SetSortOrder(sort)) { double cc1v = (double)rep["cc1"]; double cc2v = (double)rep["cc2"]; double cc3v = (double)rep["cc3"]; if (cc1v == 0) { cc1v = 0.05; } if (cc2v == 0) { cc2v = 0.05; } if (cc3v == 0) { cc3v = 0.05; } if (perfect1 & (cc1v == 0.05 | cc1v == 1)) { perfect1 = false; } if (perfect2 & (cc2v == 0.05 | cc2v == 1)) { perfect2 = false; } if (perfect3 & (cc3v == 0.05 | cc3v == 1)) { perfect3 = false; } cc1.Add(new DataPoint<int, double>() { X = i, Y = cc1v }); cc2.Add(new DataPoint<int, double>() { X = i, Y = cc2v }); cc3.Add(new DataPoint<int, double>() { X = i, Y = cc3v }); i++; } } if (i == 1) { //// plot nothing //for (int j = 1; j <= 5; j++) //{ // cc1.Add(new DataPoint<int, double>() { X = j, Y = 0 }); // cc2.Add(new DataPoint<int, double>() { X = j, Y = 0 }); // cc3.Add(new DataPoint<int, double>() { X = j, Y = 0 }); //} criticalComponent1.Text = ""; criticalComponent1.Text = ""; criticalComponent1.Text = ""; date.Content = "N/A"; } else { if (perfect1) { criticalComponent1.Text = cc1legend + ": Excellent!"; buttoncc1.IsEnabled = false; } else { criticalComponent1.Text = criticalComponent1Feedback; buttoncc1.IsEnabled = true; } if (perfect2) { criticalComponent2.Text = cc2legend + ": Excellent!"; buttoncc2.IsEnabled = false; } else { criticalComponent2.Text = criticalComponent2Feedback; buttoncc2.IsEnabled = true; } if (perfect3) { criticalComponent3.Text = cc3legend + ": Excellent!"; buttoncc3.IsEnabled = false; } else { criticalComponent3.Text = criticalComponent3Feedback; buttoncc3.IsEnabled = true; } date.Content = dateSearch.AddHours(-4).ToLongDateString() + " " + dateSearch.AddHours(-4).ToShortTimeString(); } //Finally, associate the data series with the chart series userchart.Series[0].DataSeries = cc1; userchart.Series[1].DataSeries = cc2; userchart.Series[2].DataSeries = cc3; }
public MainWindow() { InitializeComponent(); telerikChart.DefaultView.ChartArea.AxisY.IsInverse = true; telerikChart.DefaultView.ChartArea.AxisX.IsInverse = true; //Line Chart DataSeries lineSeries = new DataSeries(); lineSeries.LegendLabel = "Turnover"; lineSeries.Definition = new LineSeriesDefinition(); lineSeries.Add(new DataPoint() { YValue = 154, XCategory = "Jan" }); lineSeries.Add(new DataPoint() { YValue = 138, XCategory = "Feb" }); lineSeries.Add(new DataPoint() { YValue = 143, XCategory = "Mar" }); lineSeries.Add(new DataPoint() { YValue = 120, XCategory = "Apr" }); lineSeries.Add(new DataPoint() { YValue = 135, XCategory = "May" }); lineSeries.Add(new DataPoint() { YValue = 125, XCategory = "Jun" }); lineSeries.Add(new DataPoint() { YValue = 179, XCategory = "Jul" }); lineSeries.Add(new DataPoint() { YValue = 170, XCategory = "Aug" }); lineSeries.Add(new DataPoint() { YValue = 198, XCategory = "Sep" }); lineSeries.Add(new DataPoint() { YValue = 187, XCategory = "Oct" }); lineSeries.Add(new DataPoint() { YValue = 193, XCategory = "Nov" }); lineSeries.Add(new DataPoint() { YValue = 176, XCategory = "Dec" }); telerikChart.DefaultView.ChartArea.DataSeries.Add(lineSeries); //Bar Chart DataSeries barSeries = new DataSeries(); barSeries.LegendLabel = "Expenses"; barSeries.Definition = new BarSeriesDefinition(); barSeries.Add(new DataPoint() { YValue = 45, XCategory = "Jan" }); barSeries.Add(new DataPoint() { YValue = 48, XCategory = "Feb" }); barSeries.Add(new DataPoint() { YValue = 53, XCategory = "Mar" }); barSeries.Add(new DataPoint() { YValue = 41, XCategory = "Apr" }); barSeries.Add(new DataPoint() { YValue = 32, XCategory = "May" }); barSeries.Add(new DataPoint() { YValue = 28, XCategory = "Jun" }); barSeries.Add(new DataPoint() { YValue = 63, XCategory = "Jul" }); barSeries.Add(new DataPoint() { YValue = 74, XCategory = "Aug" }); barSeries.Add(new DataPoint() { YValue = 77, XCategory = "Sep" }); barSeries.Add(new DataPoint() { YValue = 85, XCategory = "Oct" }); barSeries.Add(new DataPoint() { YValue = 89, XCategory = "Nov" }); barSeries.Add(new DataPoint() { YValue = 80, XCategory = "Dec" }); telerikChart.DefaultView.ChartArea.DataSeries.Add(barSeries); }
public MainWindow() { InitializeComponent(); RadChart telerikChart = new RadChart(); //Chart Title telerikChart.DefaultView.ChartTitle.Content = "Year 2009"; telerikChart.DefaultView.ChartTitle.HorizontalAlignment = HorizontalAlignment.Center; //Chart Legend telerikChart.DefaultView.ChartLegend.UseAutoGeneratedItems = true; //Line Chart DataSeries lineSeries = new DataSeries(); lineSeries.LegendLabel = "Turnover"; lineSeries.Definition = new LineSeriesDefinition(); lineSeries.Add(new DataPoint() { YValue = 154, XCategory = "Jan" }); lineSeries.Add(new DataPoint() { YValue = 138, XCategory = "Feb" }); lineSeries.Add(new DataPoint() { YValue = 143, XCategory = "Mar" }); lineSeries.Add(new DataPoint() { YValue = 120, XCategory = "Apr" }); lineSeries.Add(new DataPoint() { YValue = 135, XCategory = "May" }); lineSeries.Add(new DataPoint() { YValue = 125, XCategory = "Jun" }); lineSeries.Add(new DataPoint() { YValue = 179, XCategory = "Jul" }); lineSeries.Add(new DataPoint() { YValue = 170, XCategory = "Aug" }); lineSeries.Add(new DataPoint() { YValue = 198, XCategory = "Sep" }); lineSeries.Add(new DataPoint() { YValue = 187, XCategory = "Oct" }); lineSeries.Add(new DataPoint() { YValue = 193, XCategory = "Nov" }); lineSeries.Add(new DataPoint() { YValue = 176, XCategory = "Dec" }); telerikChart.DefaultView.ChartArea.DataSeries.Add(lineSeries); //Bar Chart DataSeries barSeries = new DataSeries(); barSeries.LegendLabel = "Expenses"; barSeries.Definition = new BarSeriesDefinition(); barSeries.Add(new DataPoint() { YValue = 45, XCategory = "Jan" }); barSeries.Add(new DataPoint() { YValue = 48, XCategory = "Feb" }); barSeries.Add(new DataPoint() { YValue = 53, XCategory = "Mar" }); barSeries.Add(new DataPoint() { YValue = 41, XCategory = "Apr" }); barSeries.Add(new DataPoint() { YValue = 32, XCategory = "May" }); barSeries.Add(new DataPoint() { YValue = 28, XCategory = "Jun" }); barSeries.Add(new DataPoint() { YValue = 63, XCategory = "Jul" }); barSeries.Add(new DataPoint() { YValue = 74, XCategory = "Aug" }); barSeries.Add(new DataPoint() { YValue = 77, XCategory = "Sep" }); barSeries.Add(new DataPoint() { YValue = 85, XCategory = "Oct" }); barSeries.Add(new DataPoint() { YValue = 89, XCategory = "Nov" }); barSeries.Add(new DataPoint() { YValue = 80, XCategory = "Dec" }); telerikChart.DefaultView.ChartArea.DataSeries.Add(barSeries); this.AddChild(telerikChart); }
private void button1_Click(object sender, RoutedEventArgs e) { if (comboBox2.SelectedValue != null) { example.Series[0].DataSeries = null; example.Series[1].DataSeries = null; example.Series[2].DataSeries = null; var query = new QueryDocument(); MongoServer server = MongoServer.Create(); MongoDatabase exerHist = server.GetDatabase("exerHist"); MongoCollection<BsonDocument> exercises = exerHist.GetCollection<BsonDocument>("exercises"); MongoCollection<BsonDocument> hostory = exerHist.GetCollection<BsonDocument>("hostory"); int b = 0; while (b < 200) { Random random = new Random(); int randomNumber1 = random.Next(0, 3); int randomNumber2 = random.Next(0, 3); int randomNumber3 = random.Next(0, 3); BsonDocument experiments = new BsonDocument { {"name", "Mehrad"}, {"exercise", "Squat"}, {"cc1",randomNumber1 } , {"cc2", randomNumber2}, {"cc3", randomNumber3}, {"time",RandomDay() }}; hostory.Insert(experiments); b++; } DataSeries<DateTime, double> cc1 = new DataSeries<DateTime, double>(comboBox1.Items[0].ToString()); DataSeries<DateTime, double> cc2 = new DataSeries<DateTime, double>(comboBox1.Items[1].ToString()); DataSeries<DateTime, double> cc3 = new DataSeries<DateTime, double>(comboBox1.Items[2].ToString()); // var sortBy = SortBy.Ascending("time"); // hostory.Find().SetSortOrder(sortBy.Descending("time")); IMongoSortBy sort = SortBy.Descending("time"); var querytest2 = Query.And(Query.EQ("exercise", comboBox2.SelectedValue.ToString()), Query.EQ("name", "Mehrad")); foreach (BsonDocument instance in hostory.Find(querytest2).SetSortOrder(sort)) { cc1.Add(new DataPoint<DateTime, double>() { Y = instance["cc1"].ToInt32(), X = instance["time"].AsDateTime }); cc2.Add(new DataPoint<DateTime, double>() { Y = instance["cc2"].ToInt32(), X = instance["time"].AsDateTime }); cc3.Add(new DataPoint<DateTime, double>() { Y = instance["cc3"].ToInt32(), X = instance["time"].AsDateTime }); } if (comboBox1.SelectedIndex == 0) example.Series[0].DataSeries = cc1; else if (comboBox1.SelectedIndex == 1) example.Series[1].DataSeries = cc2; else if (comboBox1.SelectedIndex == 2) example.Series[2].DataSeries = cc3; else { example.Series[0].DataSeries = cc1; example.Series[1].DataSeries = cc2; example.Series[2].DataSeries = cc3; } cc1 = null; cc2 = null; cc3 = null; } else { MessageBox.Show("Please select an exercise"); } }
public void refresh(ChartDataSerie serieData) { int count=0; switch (silverChartControl.XAxesType) { case XAxisTypeEnum.numeric: DataSeries<double,double> dataSeries=new DataSeries<double, double> { Title = Name }; foreach (ChartDataPoint point in serieData.Points) { dataSeries.Add(new DataPoint<double, double>(point.XValDouble, point.YVal)); count++; } if (Enabled) { Serie.DataSeries = dataSeries; } SeriesData = dataSeries; break; case XAxisTypeEnum.datetime: DataSeries<DateTime,double> dataSeriesDate=new DataSeries<DateTime, double> { Title = Name }; foreach (ChartDataPoint point in serieData.Points) { dataSeriesDate.Add(new DataPoint<DateTime, double>(point.XVal, point.YVal)); count++; } if (Enabled) { Serie.DataSeries = dataSeriesDate; } SeriesData = dataSeriesDate; break; } ShowToolTip=count<100; }
public void processSingleCran(int cranNumber,Chart CurrentChart,int cranVal) { Dictionary<DateTime, CranTaskInfo> crans = new Dictionary<DateTime, CranTaskInfo>(); foreach (CranTaskInfo task in CurrentFilter.Data) { DateTime date = task.NeedEndDate; if (task.Allowed) date = task.AllowDateEnd; if (task.CranNumber==cranNumber){ while (crans.ContainsKey(date)) date=date.AddMilliseconds(1); crans.Add(date,task); } } IEnumerable<KeyValuePair<DateTime,CranTaskInfo>> sorted= crans.OrderBy(task => task.Key); double diffA = 0; double diffD = 0.05; CranTaskInfo prevTaskA = null; CranTaskInfo prevTaskD = null; foreach (KeyValuePair<DateTime,CranTaskInfo> de in sorted) { CranTaskInfo task = de.Value; LineSeries serie = new LineSeries(); DataSeries<DateTime, double> Points = new DataSeries<DateTime, double>(); serie.Name = String.Format("order_{0}", task.Number); serie.MouseLeftButtonUp += serie_MouseLeftButtonUp; serie.LineStrokeThickness = 5; serie.PointShape = Visiblox.Charts.Primitives.ShapeType.Rectangle; serie.PointSize = 15; serie.ShowPoints = true; if (task.Allowed) { if (prevTaskA != null && task.AllowDateStart > prevTaskA.AllowDateEnd) { diffA = 0; } if (!task.Finished) { Points.Add(new DataPoint<DateTime, double>(task.AllowDateStart, cranVal + diffA)); Points.Add(new DataPoint<DateTime, double>(task.AllowDateEnd, cranVal + diffA)); } else { Points.Add(new DataPoint<DateTime, double>(task.RealDateStart, cranVal + diffA)); Points.Add(new DataPoint<DateTime, double>(task.RealDateEnd, cranVal + diffA)); } serie.LineStroke = new SolidColorBrush(!task.Finished?Colors.Green:Colors.Blue); serie.PointFill = new SolidColorBrush(!task.Finished ? Colors.Green : Colors.Blue); diffA += 0.05; prevTaskA = task; } else if (task.Denied) { if (prevTaskD != null && task.NeedStartDate > prevTaskD.NeedEndDate) { diffD = 0.05; } Points.Add(new DataPoint<DateTime, double>(task.NeedStartDate, cranVal - diffD)); Points.Add(new DataPoint<DateTime, double>(task.NeedEndDate, cranVal - diffD)); serie.LineStroke = new SolidColorBrush(Colors.Red); serie.PointFill = new SolidColorBrush(Colors.Red); diffD += 0.05; prevTaskD = task; } else if (task.Cancelled) { if (prevTaskD != null && task.NeedStartDate > prevTaskD.NeedEndDate) { diffD = 0.05; } Points.Add(new DataPoint<DateTime, double>(task.NeedStartDate, cranVal - diffD)); Points.Add(new DataPoint<DateTime, double>(task.NeedEndDate, cranVal - diffD)); serie.LineStroke = new SolidColorBrush(Colors.LightGray); serie.PointFill = new SolidColorBrush(Colors.LightGray); diffD += 0.05; prevTaskD = task; } else if (task.Finished) { if (prevTaskA != null && task.AllowDateStart > prevTaskA.AllowDateEnd) { diffA = 0; } Points.Add(new DataPoint<DateTime, double>(task.AllowDateStart, cranVal + diffA)); Points.Add(new DataPoint<DateTime, double>(task.AllowDateEnd, cranVal + diffA)); serie.LineStroke = new SolidColorBrush(Colors.Blue); serie.PointFill = new SolidColorBrush(Colors.Blue); diffA += 0.05; prevTaskA = task; } else { if (prevTaskD != null && task.NeedStartDate > prevTaskD.NeedEndDate) { diffD = 0.05; } Points.Add(new DataPoint<DateTime, double>(task.NeedStartDate, cranVal - diffD)); Points.Add(new DataPoint<DateTime, double>(task.NeedEndDate, cranVal - diffD)); serie.LineStroke = new SolidColorBrush(Colors.Gray); serie.PointFill = new SolidColorBrush(Colors.Gray); diffD += 0.05; prevTaskD = task; } serie.DataSeries = Points; CurrentChart.Series.Add(serie); } }
public static void FillWithSampleData(DataSeries series, int numberOfItems, int sum) { int localSum = 0; Random random = new Random((int)(series.GetHashCode() + DateTime.Now.Ticks)); for (int i = 0; i < numberOfItems; i++) { int randomNumber = 0; while (randomNumber <= 0) randomNumber = random.Next(sum / numberOfItems - 3, sum / numberOfItems + 3); if (localSum + randomNumber > sum) randomNumber = sum - localSum; if ((i == numberOfItems - 1) && (localSum + randomNumber < sum)) randomNumber = sum - localSum; localSum += randomNumber; DataPoint dataPoint = new DataPoint(); dataPoint.YValue = randomNumber; series.Add(dataPoint); } }
private void chartCurrent(string[] scores, DateTime dateTime) { MongoCollection<BsonDocument> history = exerHist.GetCollection<BsonDocument>("history"); // graph //We need one data series for each chart series DataSeries<int, double> cc1 = new DataSeries<int, double>(cc1legend); DataSeries<int, double> cc2 = new DataSeries<int, double>(cc2legend); DataSeries<int, double> cc3 = new DataSeries<int, double>(cc3legend); bool perfect1 = true; bool perfect2 = true; bool perfect3 = true; int j = 0; for(int i = 1; i <=10; i++) { double cc1v = double.Parse(scores[(i*3)-3]); double cc2v = double.Parse(scores[(i*3)-2]); double cc3v = double.Parse(scores[(i*3)-1]); if (cc1v == -1 | cc1v == -2) { j = i; break; } if (cc1v == 0) { cc1v = 0.05; } if (cc2v == 0) { cc2v = 0.05; } if (cc3v == 0) { cc3v = 0.05; } BsonDocument rep = new BsonDocument { { "name", user.Content.ToString() }, { "exercise", exercisesCB.SelectedValue.ToString() }, { "cc1", cc1v }, { "cc2", cc2v }, { "cc3", cc3v }, { "time", dateTime.AddSeconds(i)}, {"timeid", dateTime} }; var options = new MongoInsertOptions(history) { SafeMode = SafeMode.True }; history.Save(rep, options); if (perfect1 & (cc1v == 0.05 | cc1v == 1)) { perfect1 = false; } if (perfect2 & (cc2v == 0.05 | cc2v == 1)) { perfect2 = false; } if (perfect3 & (cc3v == 0.05 | cc3v == 1)) { perfect3 = false; } cc1.Add(new DataPoint<int, double>() { X = i, Y = cc1v }); cc2.Add(new DataPoint<int, double>() { X = i, Y = cc2v }); cc3.Add(new DataPoint<int, double>() { X = i, Y = cc3v }); } if (j == 1) { // plot nothing for (int k = 1; k <= 5; k++) { cc1.Add(new DataPoint<int, double>() { X = k, Y = 0 }); cc2.Add(new DataPoint<int, double>() { X = k, Y = 0 }); cc3.Add(new DataPoint<int, double>() { X = k, Y = 0 }); } criticalComponent1.Text = ""; criticalComponent1.Text = ""; criticalComponent1.Text = ""; date.Content = "N/A"; } else { if (perfect1) { criticalComponent1.Text = cc1legend + ": Excellent!"; buttoncc1.IsEnabled = false; } else { criticalComponent1.Text = criticalComponent1Feedback; buttoncc1.IsEnabled = true; } if (perfect2) { criticalComponent2.Text = cc2legend + ": Excellent!"; buttoncc2.IsEnabled = false; } else { criticalComponent2.Text = criticalComponent2Feedback; buttoncc2.IsEnabled = true; } if (perfect3) { criticalComponent3.Text = cc3legend + ": Excellent!"; buttoncc3.IsEnabled = false; } else { criticalComponent3.Text = criticalComponent3Feedback; buttoncc3.IsEnabled = true; } date.Content = dateTime.ToLongDateString() + " " + dateTime.ToShortTimeString(); ; } //Finally, associate the data series with the chart series userchart.Series[0].DataSeries = cc1; userchart.Series[1].DataSeries = cc2; userchart.Series[2].DataSeries = cc3; }
private void calendar2_SelectedDatesChanged(object sender, SelectionChangedEventArgs e) { if (comboBox2.SelectedValue != null) { DataSeries<int, int> Dcc1 = new DataSeries<int, int>(comboBox1.Items[0].ToString()); DataSeries<int, int> Dcc2 = new DataSeries<int, int>(comboBox1.Items[1].ToString()); DataSeries<int, int> Dcc3 = new DataSeries<int, int>(comboBox1.Items[2].ToString()); string connectionstring = "mongodb://CHEICS-PC"; MongoServer server = MongoServer.Create(connectionstring); MongoDatabase exerHist = server.GetDatabase("exerHist"); MongoCollection<BsonDocument> exercises = exerHist.GetCollection<BsonDocument>("exercises"); MongoCollection<BsonDocument> hostory = exerHist.GetCollection<BsonDocument>("hostory"); var query = new QueryDocument(); int cc11 = 0, cc12 = 0, cc10 = 0, cc20 = 0, cc21 = 0, cc22 = 0, cc30 = 0, cc31 = 0, cc32 = 0; var querytest1 = Query.And(Query.EQ("exercise", comboBox2.SelectedValue.ToString()), Query.EQ("name", "Mehrad")); foreach (BsonDocument instance in hostory.Find(querytest1)) { string date = null; string selecteddate = null; DateTime daymonth; DateTime selecteddaymonth; daymonth = instance["time"].AsDateTime; date = daymonth.Day.ToString() + "/" + daymonth.Month.ToString() + "/" + daymonth.Year.ToString(); selecteddaymonth = calendar2.SelectedDate.Value; selecteddate = selecteddaymonth.Day.ToString() + "/" + selecteddaymonth.Month.ToString() + "/" + selecteddaymonth.Year.ToString(); if (date == selecteddate) { if (instance["cc1"].ToInt32() == 0) cc10++; if (instance["cc1"].ToInt32() == 1) cc11++; if (instance["cc1"].ToInt32() == 2) cc12++; if (instance["cc2"].ToInt32() == 0) cc20++; if (instance["cc2"].ToInt32() == 1) cc21++; if (instance["cc2"].ToInt32() == 2) cc22++; if (instance["cc3"].ToInt32() == 0) cc30++; if (instance["cc2"].ToInt32() == 1) cc31++; if (instance["cc2"].ToInt32() == 2) cc32++; } } Dcc1.Add(new DataPoint<int, int>() { Y = cc10, X = 0 }); Dcc1.Add(new DataPoint<int, int>() { Y = cc11, X = 1 }); Dcc1.Add(new DataPoint<int, int>() { Y = cc12, X = 2 }); Dcc2.Add(new DataPoint<int, int>() { Y = cc20, X = 0 }); Dcc2.Add(new DataPoint<int, int>() { Y = cc21, X = 1 }); Dcc2.Add(new DataPoint<int, int>() { Y = cc22, X = 2 }); Dcc3.Add(new DataPoint<int, int>() { Y = cc30, X = 0 }); Dcc3.Add(new DataPoint<int, int>() { Y = cc31, X = 1 }); Dcc3.Add(new DataPoint<int, int>() { Y = cc32, X = 2 }); DataSeries<String, int> cc1 = new DataSeries<String, int>(); DataSeries<String, int> cc2 = new DataSeries<string, int>(); DataSeries<string, int> cc3 = new DataSeries<string, int>(); cc1.Add(new DataPoint<String, int>("Bad", cc10)); cc1.Add(new DataPoint<string, int>("Good", cc11)); cc1.Add(new DataPoint<string, int>("Perfect", cc12)); cc2.Add(new DataPoint<String, int>("Bad", cc20)); cc2.Add(new DataPoint<string, int>("Good", cc21)); cc2.Add(new DataPoint<string, int>("Perfect", cc22)); cc3.Add(new DataPoint<string, int>("Bad", cc30)); cc3.Add(new DataPoint<string, int>("Good", cc31)); cc3.Add(new DataPoint<string, int>("Perfect", cc32)); cc1chart.DataSeries = cc1; cc2chart.DataSeries = cc2; cc3chart.DataSeries = cc3; cc1chart.Title = comboBox1.Items[0].ToString(); cc2chart.Title = comboBox1.Items[1].ToString(); cc3chart.Title = comboBox1.Items[2].ToString(); cc1chart.ShowLabels = false; cc2chart.ShowLabels = false; cc3chart.ShowLabels = false; } else MessageBox.Show("Please select an exercise"); //MainChart.DataSeries = test1; //MainChart.Title = "random"; }
public void ExportBubbleGraph() { BubbleGraph.Width = 800; BubbleGraph.Height = 600; BubbleGraph.Measure(new System.Windows.Size(BubbleGraph.Width, BubbleGraph.Height)); BubbleGraph.Arrange(new System.Windows.Rect(BubbleGraph.DesiredSize)); BubbleGraph.DefaultView.ChartArea.EnableAnimations = false; BubbleGraph.DefaultView.ChartTitle.Content = onBeginSheet ? "Beginning of Semester Evaluation" : "End of Semester Evaluation"; BubbleGraph.DefaultView.ChartTitle.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; BubbleGraph.DefaultView.ChartLegend.UseAutoGeneratedItems = true; DataSeries bubbleSeries = new DataSeries(); bubbleSeries.LegendLabel = "Evaluation"; bubbleSeries.Definition = new BubbleSeriesDefinition(); foreach (BubblePoints b in AllPoints) { bubbleSeries.Add(new DataPoint() { XValue = b.X, YValue = b.Y, BubbleSize = b.total * .25 }); } BubbleGraph.DefaultView.ChartArea.DataSeries.Add(bubbleSeries); Dispatcher.BeginInvoke((Action)(() => { string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\Bubble Graphs\"; if (!Directory.Exists(filePath)) Directory.CreateDirectory(filePath); using (FileStream fs = File.Create(filePath + BubbleGraph.DefaultView.ChartTitle.Content.ToString() + ".png")) { if (importTwoGraphs && !SecondChartExported) { ExportSecondChart(); BubbleGraph.ExportToImage(fs, new PngBitmapEncoder()); } else BubbleGraph.ExportToImage(fs, new PngBitmapEncoder()); } }), DispatcherPriority.ApplicationIdle, null); }