public static string GetMarkerPath(MarkerKind kind) { switch (kind) { case MarkerKind.Me: return myMarkerPath; case MarkerKind.Home: return homeMarkerPath; case MarkerKind.Work: return workMarkerPath; case MarkerKind.Search: return searchMarkerPath; case MarkerKind.Location: return locationMarkerPath; case MarkerKind.Destination: return destinationMarkerPath; case MarkerKind.Waypoint: return waypointMarkerPath; case MarkerKind.Repair: return repairMarkerPath; case MarkerKind.StopAuto: return stopautoMarkerPath; case MarkerKind.StopWalk: return stopwalkMarkerPath; case MarkerKind.Police: return policeMarkerPath; case MarkerKind.Camera: return cameraMarkerPath; case MarkerKind.Crash: return crashMarkerPath; case MarkerKind.BadRoad: return badroadMarkerPath; case MarkerKind.Pool: return poolMarkerPath; case MarkerKind.Ice: return iceMarkerPath; case MarkerKind.Chat: return chatMarkerPath; case MarkerKind.Mistake: return mistakeMarkerPath; case MarkerKind.Custom: return customMarkerPath; default: return noneMarkerPath; } }
private Series createPointSeries(ICurveDataSettings curve, MarkerKind markerKind) { var series = CreateSeries(curve, ViewType.Point); var pointView = series.View.DowncastTo <PointSeriesView>(); pointView.PointMarkerOptions.Kind = markerKind; pointView.PointMarkerOptions.Size = 5; return(series); }
private void TestMarker(string text, MarkerKind expectedKind) { var sc3String = SC3String.Deserialize(text); var marker = sc3String.Segments[0] as Marker; Assert.NotNull(marker); Assert.Equal(expectedKind, marker.MarkerKind); Assert.Equal(text, sc3String.ToString()); }
public void SetLineSeriesMarkerStyle(MarkerKind markerKind, int markerSize, Color markerColor) { if (TargetSeries.View is LineSeriesView) { LineSeriesView view = TargetSeries.View as LineSeriesView; view.MarkerVisibility = DevExpress.Utils.DefaultBoolean.True; view.LineMarkerOptions.Kind = markerKind; view.LineMarkerOptions.Size = markerSize; view.LineMarkerOptions.Color = markerColor; } }
private Series createPointSeries(string name, MarkerKind markerKind, params double[] points) { var series = new Series(name, ViewType.Point) { ArgumentScaleType = ScaleType.Numerical }; points.Each(p => series.Points.Add(new SeriesPoint(p, 0))); var view = series.View.DowncastTo <PointSeriesView>(); view.PointMarkerOptions.Kind = markerKind; _chart.Series.Add(series); return(series); }
private void PopularDadosGrafico() { ViewType[] ignorarOsTipos = new ViewType[] { ViewType.PolarArea, ViewType.PolarLine, ViewType.PolarPoint, //ViewType.SideBySideGantt, ViewType.SideBySideRangeBar, ViewType.RangeBar, //ViewType.Gantt, ViewType.Stock, ViewType.SwiftPlot, ViewType.CandleStick, //ViewType.SideBySideFullStackedBar, //ViewType.SideBySideFullStackedBar3D, //ViewType.SideBySideStackedBar, //ViewType.SideBySideStackedBar3D }; #region Layout Enum.GetValues(typeof(ViewType)) .OfType <ViewType>() .Where(w => !ignorarOsTipos.Contains(w)) .ToList() .ForEach(f => { BarCheckItem barCheckItem = new BarCheckItem(); barCheckItem.Caption = f.ToString(); barCheckItem.Tag = f; barCheckItem.ItemClick += delegate(object senderItemClick, ItemClickEventArgs eItemClick) { if ((eItemClick.Item as BarCheckItem).Checked) { // Procura e desmarca o item selecionado this.brMngrCustomGrid.Items .OfType <BarCheckItem>() .Where(w => w.Tag != null && w.Tag is ViewType && eItemClick.Item != w && w.Checked) .Update(u => u.Checked = false); this.chtCtrlVisualizacoes.SeriesTemplate.ChangeView((ViewType)eItemClick.Item.Tag); this.chtCtrlVisualizacoes.Legend.Visible = this.brChckItmLegenda.Checked; this.pvtGrdVisualizacoes.OptionsChartDataSource.ProvideDataByColumns = this.brChckItmAlterarLinhasPorColunas.Checked; this.pvtGrdVisualizacoes.OptionsChartDataSource.SelectionOnly = this.brChckItmSomenteOSelecionado.Checked; this.pvtGrdVisualizacoes.OptionsChartDataSource.ProvideColumnGrandTotals = this.brChckItmMostrarTotalColuna.Checked; this.pvtGrdVisualizacoes.OptionsChartDataSource.ProvideRowGrandTotals = this.brChckItmMostrarTotalLinha.Checked; this.chtCtrlVisualizacoes.Legend.Visible = this.brChckItmLegenda.Checked; if (this.chtCtrlVisualizacoes.SeriesTemplate.Label != null) { this.chtCtrlVisualizacoes.SeriesTemplate.Label.Visible = this.brChckItmValor.Checked; } if (this.Diagram3D != null) { this.Diagram3D.RuntimeRotation = true; this.Diagram3D.RuntimeZooming = true; this.Diagram3D.RuntimeScrolling = true; } else if (this.XyDiagram != null) { this.XyDiagram.AxisX.Visible = this.brChckItmEixoX.Checked; this.XyDiagram.AxisX.Title.Visible = true; this.XyDiagram.AxisX.Range.MaxValue = 20; this.XyDiagram.AxisX.Range.Auto = true; this.XyDiagram.AxisX.Range.SideMarginsEnabled = true; this.XyDiagram.AxisY.Visible = this.brChckItmEixoY.Checked; this.XyDiagram.AxisY.Title.Visible = true; this.XyDiagram.AxisY.Range.MaxValue = 20; this.XyDiagram.AxisY.Range.Auto = true; this.XyDiagram.AxisY.Range.SideMarginsEnabled = true; this.XyDiagram.Rotated = this.brChckItmVirar.Checked; this.XyDiagram.DefaultPane.EnableAxisXScrolling = DevExpress.Utils.DefaultBoolean.True; } this.chtCtrlVisualizacoes.Series .OfType <Series>() .ToList() .ForEach(f1 => { ISupportTransparency supportTransparency = f1.View as ISupportTransparency; if (supportTransparency != null && (f1.View is AreaSeriesView || f1.View is Area3DSeriesView || f1.View is RadarAreaSeriesView || f1.View is Bar3DSeriesView)) { supportTransparency.Transparency = 135; } }); Series series = this.chtCtrlVisualizacoes.Series .OfType <Series>() .FirstOrDefault(); if (series != null && series.View != null) { this.brSbItmTipo.Enabled = series.View is PointSeriesView; this.brMngrCustomGrid.Items .OfType <BarCheckItem>() .Where(w => w.Checked) .FirstOrDefault() .PerformClick(); } } else { (eItemClick.Item as BarCheckItem).Checked = true; } }; if (f.ToString().ToUpper().IndexOf("RADAR") != -1) { this.brSbItmRadar.AddItem(barCheckItem); } else if (f.ToString().ToUpper().IndexOf("BAR") != -1) { this.brSbItmBarra.AddItem(barCheckItem); } else if (f.ToString().ToUpper().IndexOf("LINE") != -1) { this.brSbItmLinha.AddItem(barCheckItem); } else if (f.ToString().ToUpper().IndexOf("AREA") != -1) { this.brSbItmArea.AddItem(barCheckItem); } else if (f.ToString().ToUpper().IndexOf("PIE") != -1 || f.ToString().ToUpper().IndexOf("DOUGHNUT") != -1) { this.brSbItmPizza.AddItem(barCheckItem); } else { this.brSbItmOutros.AddItem(barCheckItem); } }); #endregion #region Tipo Enum.GetValues(typeof(MarkerKind)) .OfType <MarkerKind>() .ToList() .ForEach(u => { BarCheckItem barCheckItem = new BarCheckItem(); barCheckItem.Caption = u.ToString(); barCheckItem.Tag = u; barCheckItem.ItemClick += delegate(object senderItemClick, ItemClickEventArgs eItemClick) { if ((eItemClick.Item as BarCheckItem).Checked) { // Procura e desmarca o item selecionado this.brSbItmTipo.LinksPersistInfo .OfType <LinkPersistInfo>() .Where(w => eItemClick.Item != w.Item && (w.Item as BarCheckItem).Checked) .Update(u1 => (u1.Item as BarCheckItem).Checked = false); // Altera o Kind de todas series MarkerKind markerKind = (MarkerKind)eItemClick.Item.Tag; this.chtCtrlVisualizacoes.Series .OfType <Series>() .ToList() .ForEach(f1 => { PointSeriesView pointSeriesView = f1.View as PointSeriesView; if (pointSeriesView != null) { pointSeriesView.PointMarkerOptions.Kind = markerKind; pointSeriesView.PointMarkerOptions.BorderVisible = false; } }); } else { (eItemClick.Item as BarCheckItem).Checked = true; } }; this.brSbItmTipo.AddItem(barCheckItem); }); #endregion this.chtCtrlVisualizacoes.DataSource = this.pvtGrdVisualizacoes; this.chtCtrlVisualizacoes.RefreshData(); this.brMngrCustomGrid.Items .OfType <BarCheckItem>() .Where(w => w.Tag != null && w.Tag.Equals(ViewType.Line)) .FirstOrDefault() .PerformClick(); this.brMngrCustomGrid.Items .OfType <BarCheckItem>() .Where(w => w.Tag != null && w.Tag.Equals(MarkerKind.Circle)) .FirstOrDefault() .PerformClick(); }
internal Marker(MarkerKind markerKind) { MarkerKind = markerKind; }
public void CreateLineplot(DataTable mydt) { _coloroverride = -1; string seriesby = _settings.seriesby; string colorsby = _settings.colorvar; Color myseriescolor; DataTable dataxy_all = DataTableExtensions.Data_SelectColumnXY(mydt, _settings.xaxisvar, _settings.yaxisvar, seriesby, colorsby); List <string> series_levels = dataxy_all.AsEnumerable().Select(x => x.Field <string>("seriesby")).Distinct().ToList(); List <string> colors_levels = dataxy_all.AsEnumerable().Select(x => x.Field <string>("colorsby")).Distinct().ToList(); colors_levels.Sort(); _colorLevels = colors_levels; //use this to create a manual legend later if needed List <string> seriesIDs = new List <string>(); if (seriesby == "id") { seriesIDs = dataxy_all.AsEnumerable().Select(x => x.Field <string>("id")).Distinct().ToList(); } else { seriesIDs = dataxy_all.AsEnumerable().Select(x => x.Field <string>("seriesby")).Distinct().ToList(); } int _nall = dataxy_all.Rows.Count; if (_nall > 0) { List <Series> list_o_series = new List <Series>(); //foreach (string s in seriesIDs) for (int s = 0; s < seriesIDs.Count; s++) { for (int s_color = 0; s_color < colors_levels.Count; s_color++) { dataxy_all.DefaultView.Sort = "seriesby ASC, colorsby ASC, x ASC"; dataxy_all.DefaultView.ApplyDefaultSort = true; DataView vw = dataxy_all.AsDataView(); string rowfilter = (seriesby == "id") ? String.Format("{0}='{1}' and colorsby='{2}'", seriesby, seriesIDs[s], colors_levels[s_color]) : String.Format("{0}='{1}' and colorsby='{2}'", "seriesby", seriesIDs[s], colors_levels[s_color]); //string rowfilter = (seriesby == "id") ? // String.Format("{0}='{1}'", seriesby, seriesIDs[s]) : // String.Format("{0}='{1}'", "seriesby", seriesIDs[s]); vw.RowFilter = rowfilter; //vw.Sort = String.Format("{0} {1}", "x", "ASC"); //sort by the x variable //vw.ApplyDefaultSort = true; DataTable dataxy = vw.ToTable(); dataxy.DefaultView.Sort = "x ASC"; dataxy.DefaultView.ApplyDefaultSort = true; n = dataxy.Rows.Count; if (n > 0) { string current_colorlevel = dataxy.AsEnumerable().Select(f => f.Field <string>("colorsby")).Min().ToString(); List <string> series_colors = dataxy.AsEnumerable().Select(f => f.Field <string>("colorsby")).ToList(); //Switch to alternate geom if needed if (_settings.vars_for_altgeom.Contains(current_colorlevel)) { _settings.activegeom = _settings.altgeom; } else { _settings.activegeom = _settings.geom; } int colorindex = 0; //Get the correct color if (colorsby != "none") { for (int c = 0; c < colors_levels.Count; c++) { if (current_colorlevel == colors_levels[c]) { colorindex = c; } } } myseriescolor = _settings.color(colorindex % 15); if (_coloroverride >= 0) { myseriescolor = _settings.color(_coloroverride % 15); } SeriesPoint[] seriesPoints = CreateSeriesPoints(dataxy, colorsby, colors_levels, series_colors, colorindex, myseriescolor); //TOFIX SeriesPoint[] seriesPoints = new DxSeriesPoints(dataxy, "x", "y", colorsby, colors_levels, series_colors, colorindex, myseriescolor); Series series = new Series(); SideBySideBarSeriesView barSeriesView = new SideBySideBarSeriesView(); LineSeriesView lineSeriesView = new LineSeriesView(); PointSeriesView pointSeriesView = new PointSeriesView(); if (_settings.activegeom == LineplotGeom.Bar) { //barSeriesView = new SideBySideBarSeriesView() ; } else if (_settings.activegeom == LineplotGeom.Line) { //lineSeriesView = new LineSeriesView(); lineSeriesView.LineMarkerOptions.FillStyle.FillMode = FillMode.Solid; lineSeriesView.LineMarkerOptions.Kind = _markers[s % _markers.Count]; } else { pointSeriesView.PointMarkerOptions.FillStyle.FillMode = FillMode.Solid; MarkerKind mymarker = new MarkerKind(); if (_settings.activegeom == LineplotGeom.Circle) { mymarker = MarkerKind.Circle; } if (_settings.activegeom == LineplotGeom.Square) { mymarker = MarkerKind.Square; } if (_settings.activegeom == LineplotGeom.Cross) { mymarker = MarkerKind.Cross; } if (_settings.activegeom == LineplotGeom.Star) { mymarker = MarkerKind.Star; } pointSeriesView.PointMarkerOptions.Kind = mymarker; pointSeriesView.PointMarkerOptions.Size = _settings.markersize; if (_settings.activegeom == LineplotGeom.Star) { pointSeriesView.PointMarkerOptions.StarPointCount = 6; } } if (_settings.xaxis_is_date) { this.xydiagram.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Continuous; this.xydiagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Month; this.xydiagram.AxisX.Label.TextPattern = "{A:dd-MMM-yy}"; series.ToolTipPointPattern = "x={A:dd-MMM-yy} y={V:F2} {HINT}"; } else { series.ToolTipPointPattern = "x={A:F2} y={V:F2} {HINT}"; } ToolTipRelativePosition pos = new ToolTipRelativePosition(); pos.OffsetX = -10; pos.OffsetY = -10; chart.ToolTipOptions.ToolTipPosition = pos; if (_settings.activegeom == LineplotGeom.Bar) { series.View = barSeriesView; } else if (_settings.activegeom == LineplotGeom.Line) { series.View = lineSeriesView; } else { series.View = pointSeriesView; } series.Points.AddRange(seriesPoints); list_o_series.Add(series); } } } //Add the series to the chart int max_pts = list_o_series.Select(s => s.Points.Count).Max(); foreach (Series s in list_o_series) { //first add those with the max number of points if (s.Points.Count == max_pts) { chart.Series.Add(s); } } foreach (Series s in list_o_series) { //then add those with fewer points if (s.Points.Count != max_pts) { chart.Series.Add(s); } } // consider adding N=??, intrcpt=, slope= string mytitle = ""; string mainTitleText = String.Format("{0}", mytitle); //, seriesPoints.Count()); chart.Width = _settings.W; chart.Height = _settings.H; this.AddTitles(mainTitleText, "", _settings.xaxisvar, _settings.yaxisvar); chart.BorderOptions.Color = Color.White; chart.CustomDrawSeriesPoint += Lineplot_TransparentPoint; chart.CustomDrawSeries += Lineplot_TransparentLine; //chart.CustomCallback += _dxcharts.Mychart_CustomCallback; chart.ToolTipEnabled = DevExpress.Utils.DefaultBoolean.True; chart.ToolTipOptions.ShowForSeries = true; chart.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.False; if (colorsby != "none") { for (int lev = 0; lev < colors_levels.Count; lev++) { // Create a new custom item. CustomLegendItem item = new CustomLegendItem(); chart.Legend.CustomItems.Add(item); // Specify its text and marker. item.Text = colors_levels[lev]; int coloridx = (_coloroverride >= 0) ? _coloroverride : lev; item.MarkerColor = _settings.colors[coloridx % _settings.colors.Count]; //item. } } chart.Legend.Visibility = (_settings.showLegend) ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False; LegendAlignmentHorizontal legend_h = new LegendAlignmentHorizontal(); LegendAlignmentVertical legend_v = new LegendAlignmentVertical(); if (_settings.legend_pos_h == "Right") { legend_h = LegendAlignmentHorizontal.Right; } else if (_settings.legend_pos_h == "RightOutside") { legend_h = LegendAlignmentHorizontal.RightOutside; } else if (_settings.legend_pos_h == "Left") { legend_h = LegendAlignmentHorizontal.Left; } else if (_settings.legend_pos_h == "LeftOutside") { legend_h = LegendAlignmentHorizontal.LeftOutside; } else if (_settings.legend_pos_h == "Center") { legend_h = LegendAlignmentHorizontal.Center; } if (_settings.legend_pos_v == "Top") { legend_v = LegendAlignmentVertical.Top; } else if (_settings.legend_pos_v == "TopOutside") { legend_v = LegendAlignmentVertical.TopOutside; } else if (_settings.legend_pos_v == "Bottom") { legend_v = LegendAlignmentVertical.Bottom; } else if (_settings.legend_pos_v == "BottomOutside") { legend_v = LegendAlignmentVertical.BottomOutside; } else if (_settings.legend_pos_v == "Center") { legend_v = LegendAlignmentVertical.Center; } chart.Legend.AlignmentHorizontal = legend_h; chart.Legend.AlignmentVertical = legend_v; // Set a value indicating that both autogenerated and custom items are displayed. chart.Legend.ItemVisibilityMode = LegendItemVisibilityMode.AutoGeneratedAndCustom; } else { //_emptymsg = String.Format("0 cases for{3}{0}{3}{1} by {2}", mytitle, xvar, yvar, Environment.NewLine); //return null; } }
/* * функция загружает нужную иконку маркера, * создает объект маркера и добавляет его на слой карты. * Аргумент index используется для ссылки на объект маркера из списка. */ private void DrawMapMarker(GeoCoordinate coordinate, MarkerKind markerKind, MapLayer mapLayer, int index = 0) { // создание маркера Image marker = new Image(); BitmapImage markerIcon = new BitmapImage(new Uri(MarkerStore.GetMarkerPath(markerKind), UriKind.RelativeOrAbsolute)); marker.Source = markerIcon; // позволяем взаимодействие с маркером switch (markerKind) { /* * В совйство Tag записывается строка, состоящая из 2-х частей, разделенных символом '_'. * В первой части записываеся тип маркера - число перечисления MarkerKind, * а во второй - информация о маркере (обычно ссылка на элемент соответствующего списка) */ case MarkerKind.Me: marker.Tag = (int)markerKind + "_" + "Я здесь"; break; case MarkerKind.Home: marker.Tag = (int)markerKind + "_" + "Здесь мой дом"; break; case MarkerKind.Work: marker.Tag = (int)markerKind + "_" + "Здесь моя работа"; break; case MarkerKind.Search: marker.Tag = (int)markerKind + "_" + index; break; case MarkerKind.Location: break; case MarkerKind.Destination: break; case MarkerKind.Waypoint: break; default: // подразумевается POI // загружаем структуру для макера POI break; } marker.Tap += marker_Tap; // создание объекта маркера на слое карты MapOverlay overlay = new MapOverlay(); overlay.Content = marker; overlay.GeoCoordinate = new GeoCoordinate(coordinate.Latitude, coordinate.Longitude); overlay.PositionOrigin = new Point(0.5, 1.0); mapLayer.Add(overlay); }
/// <summary> /// 创建图表的第二坐标系 /// </summary> /// <param name="series">Series对象</param> /// <returns></returns> private SecondaryAxisY CreateAxisY(Series series, ChartControl chartcontrol, MarkerKind type, bool label, int i) { if (newAxisYList.Count < 3 && oldAxisYList.Count < 3) { myAxis = new SecondaryAxisY(series.Name); ((XYDiagram)chartcontrol.Diagram).SecondaryAxesY.Add(myAxis); ((XYDiagram)chartcontrol.Diagram).EnableAxisXZooming = true; ((LineSeriesView)series.View).AxisY = myAxis; //定义线条上点的标识形状是否需要 ((LineSeriesView)series.View).LineMarkerOptions.Visible = true; //定义线条上点的标识形状 ((LineSeriesView)series.View).LineMarkerOptions.Kind = type; //显示X、Y轴上面的交点的值 ((PointSeriesLabel)series.Label).Visible = label; //线条的类型,虚线,实线 ((LineSeriesView)series.View).LineStyle.DashStyle = DashStyle.Solid; myAxis.Title.Text = series.Name; myAxis.Title.Alignment = StringAlignment.Far; //顶部对齐 myAxis.Title.Visible = true; //显示标题 myAxis.Title.Font = new Font("宋体", 9.0f); Color color = series.View.Color;//设置坐标的颜色和图表线条颜色一致 myAxis.Title.TextColor = color; myAxis.Label.TextColor = color; myAxis.Color = color; switch (chartcontrol.Name.ToString()) { case "chartControl1": newAxisYList.Add(myAxis); break; case "chartControl2": oldAxisYList.Add(myAxis); break; default: break; } } else { switch (chartcontrol.Name.ToString()) { case "chartControl1": ((LineSeriesView)series.View).AxisY = newAxisYList[i]; //定义线条上点的标识形状是否需要 ((LineSeriesView)series.View).LineMarkerOptions.Visible = true; //定义线条上点的标识形状 ((LineSeriesView)series.View).LineMarkerOptions.Kind = MarkerKind.Circle; //显示X、Y轴上面的交点的值 ((PointSeriesLabel)series.Label).Visible = true; //线条的类型,虚线,实线 ((LineSeriesView)series.View).LineStyle.DashStyle = DashStyle.Solid; break; case "chartControl2": ((LineSeriesView)series.View).AxisY = oldAxisYList[i]; //定义线条上点的标识形状是否需要 ((LineSeriesView)series.View).LineMarkerOptions.Visible = true; //定义线条上点的标识形状 ((LineSeriesView)series.View).LineMarkerOptions.Kind = MarkerKind.Circle; //显示X、Y轴上面的交点的值 ((PointSeriesLabel)series.Label).Visible = true; //线条的类型,虚线,实线 ((LineSeriesView)series.View).LineStyle.DashStyle = DashStyle.Solid; break; default: break; } } return(myAxis); }
private Series createExtremSeries(ObservedCurveData observedCurveData, Func <ObservedDataYValue, float> extremValue, MarkerKind markerKind) { var series = CreateSeries(observedCurveData, ViewType.Point) .WithPoints(CreateSeriesPoints(observedCurveData, extremValue)); var pointView = series.View.DowncastTo <PointSeriesView>(); pointView.PointMarkerOptions.Kind = markerKind; pointView.PointMarkerOptions.Size = 4; return(series); }