public Legend(LegendType type = LegendType.Plain) { if (Show && type.Equals(LegendType.Scroll)) { //scrollDataIndex; } }
/// <summary> /// Import legend scheme from XML node /// </summary> /// <param name="LSNode">xml node</param> /// <param name="keepShape">if keep the legend shape type</param> public void ImportFromXML(XmlNode LSNode, bool keepShape) { LegendBreaks = new List <ColorBreak>(); if (!(LSNode.Attributes["FieldName"] == null)) { FieldName = LSNode.Attributes["FieldName"].InnerText; } LegendType = (LegendType)Enum.Parse(typeof(LegendType), LSNode.Attributes["LegendType"].InnerText, true); ShapeTypes aShapeType = (ShapeTypes)Enum.Parse(typeof(ShapeTypes), LSNode.Attributes["ShapeType"].InnerText, true); //BreakNum = Convert.ToInt32(LSNode.Attributes["BreakNum"].InnerText); HasNoData = Convert.ToBoolean(LSNode.Attributes["HasNoData"].InnerText); MinValue = Convert.ToDouble(LSNode.Attributes["MinValue"].InnerText); MaxValue = Convert.ToDouble(LSNode.Attributes["MaxValue"].InnerText); MissingValue = Convert.ToDouble(LSNode.Attributes["UNDEF"].InnerText); if (!keepShape) { ShapeType = aShapeType; } bool sameShapeType = (ShapeType == aShapeType); ImportBreaks(LSNode, sameShapeType); }
/// <summary> /// Create legend scheme from grid data /// </summary> /// <param name="aGridData">GridData</param> /// <param name="aLT">legend type</param> /// <param name="aST">shape type</param> /// <param name="hasNoData">ref if has undefine data</param> /// <returns>legend scheme</returns> public static LegendScheme CreateLegendSchemeFromGridData(GridData aGridData, LegendType aLT, ShapeTypes aST, ref Boolean hasNoData) { LegendScheme aLS = new LegendScheme(aST); double[] CValues; Color[] colors; double MinData = 0; double MaxData = 0; hasNoData = ContourDraw.GetMaxMinValue(aGridData.Data, aGridData.MissingValue, ref MinData, ref MaxData); CValues = CreateContourValues(MinData, MaxData); colors = CreateRainBowColors(CValues.Length + 1); //Generate lengendscheme if (aLT == LegendType.UniqueValue) { aLS = CreateUniqValueLegendScheme(CValues, colors, aST, MinData, MaxData, hasNoData, aGridData.MissingValue); } else { aLS = CreateGraduatedLegendScheme(CValues, colors, aST, MinData, MaxData, hasNoData, aGridData.MissingValue); } return(aLS); }
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer) { if (untypedValue == null) { serializer.Serialize(writer, null); return; } LegendType value = (LegendType)untypedValue; switch (value) { case LegendType.Gradient: serializer.Serialize(writer, "gradient"); return; case LegendType.Symbol: serializer.Serialize(writer, "symbol"); return; } throw new Exception("Cannot marshal type LegendType"); }
/// <summary> /// Configures the default settings of the legend item /// </summary> private void Configure() { _legendItemVisible = true; _isSelected = false; _isExpanded = false; _legendSymbolMode = SymbolMode.Symbol; _legendSymbolSize = new Size(16, 16); _isDragable = false; _legendType = LegendType.Symbol; }
private void CB_Field_SelectedIndexChanged(object sender, EventArgs e) { LegendType aLT = (LegendType)Enum.Parse(typeof(LegendType), CB_LegendType.Text, true); string fieldName = CB_Field.Text; if (fieldName != "<None>") { CreateLegendScheme(aLT, fieldName); } }
protected override ChartLegend CreateChartLegend(LegendType type) { var chartLegend = new ChartLegendByCategory(this); if (type == LegendType.PrimaryLegend) { chartLegend.LegendPosition = LegendPosition.Bottom; } return(chartLegend); }
protected override ChartLegend CreateChartLegend(LegendType type) { var chartLegend = base.CreateChartLegend(type); if (type == LegendType.PrimaryLegend) { chartLegend.LegendPosition = LegendPosition.Bottom; } return(chartLegend); }
/// <summary> /// Get legend view bounds. /// </summary> /// <returns></returns> protected virtual Rectangle GetLegendBounds(Rectangle plotViewBounds, LegendType type, LegendPosition position) { if (!this.showLegend) { return(new Rectangle(0, 0, 0, 0)); } var clientRect = this.ClientBounds; Size legendSize = Size.Zero; switch (type) { default: case LegendType.PrimaryLegend: legendSize = this.PrimaryLegend.GetPreferredSize(); break; } switch (position) { case LegendPosition.Left: return(new Rectangle(0, plotViewBounds.Y + (plotViewBounds.Height - legendSize.Height) / 2, legendSize.Width, legendSize.Height)); default: case LegendPosition.Right: return(new Rectangle(clientRect.Right - legendSize.Width, plotViewBounds.Y + (plotViewBounds.Height - legendSize.Height) / 2, legendSize.Width, legendSize.Height)); case LegendPosition.Top: return(new Rectangle(plotViewBounds.X + (plotViewBounds.Width - legendSize.Width) / 2, 0, legendSize.Width, legendSize.Height)); case LegendPosition.Bottom: return(new Rectangle(plotViewBounds.X + (plotViewBounds.Width - legendSize.Width) / 2, plotViewBounds.Bottom - legendSize.Height, legendSize.Width, legendSize.Height)); } }
/// <summary> /// Import legend scheme from an image color palette file /// </summary> /// <param name="aFile">file path</param> public void ImportFromPaletteFile_Unique(string aFile) { StreamReader sr = new StreamReader(aFile); this.ShapeType = ShapeTypes.Image; this.LegendType = LegendType.UniqueValue; this.LegendBreaks = new List <ColorBreak>(); ColorBreak aCB = new ColorBreak(); string[] dataArray; int lastNonEmpty, i; sr.ReadLine(); string aLine = sr.ReadLine(); while (aLine != null) { dataArray = aLine.Split(); lastNonEmpty = -1; List <int> dataList = new List <int>(); for (i = 0; i < dataArray.Length; i++) { if (dataArray[i] != string.Empty) { lastNonEmpty++; dataList.Add(int.Parse(dataArray[i])); } } Color aColor = Color.FromArgb(255, dataList[3], dataList[2], dataList[1]); aCB = new ColorBreak(); aCB.Color = aColor; aCB.StartValue = dataList[0]; aCB.EndValue = dataList[0]; aCB.Caption = aCB.StartValue.ToString(); this.LegendBreaks.Add(aCB); aLine = sr.ReadLine(); } sr.Close(); }
private void SetFieldByLegendType(LegendType aLT) { if (_mapLayer.LayerType == LayerTypes.VectorLayer) { VectorLayer aLayer = (VectorLayer)_mapLayer; switch (aLT) { case LegendType.SingleSymbol: CB_Field.Enabled = false; CB_Field.Text = "<None>"; CreateLegendScheme(aLT, ""); break; case LegendType.UniqueValue: CB_Field.Enabled = true; CB_Field.Items.Clear(); foreach (string fn in aLayer.GetFieldNameList()) { CB_Field.Items.Add(fn); } CB_Field.Text = "<None>"; break; case LegendType.GraduatedColor: CB_Field.Enabled = true; CB_Field.Items.Clear(); for (int i = 0; i < aLayer.NumFields; i++) { if (MIMath.IsNumeric(aLayer.GetField(i))) { CB_Field.Items.Add(aLayer.GetFieldName(i)); } } CB_Field.Text = "<None>"; break; } } }
/// <inheritdoc /> public Task <Legend> GetAsync(LegendType id, CancellationToken cancellationToken = default) => this.GetAsync(id.ToString(), cancellationToken);
public static Task <Legend> Legends(LegendType ID) { return(Builder.AddDirective("legends") .AddDirective(ID.ToString()) .RequestAsync <Legend>()); }
/// <summary> /// Creates and returns scatter chart legend instance. /// </summary> /// <returns>Instance of scatter chart legend.</returns> protected override ChartLegend CreateChartLegend(LegendType type) { return(new ScatterChartLegend(this)); }
private void CreateLegendScheme(LegendType aLT, string fieldName) { if (_ifCreateLegendScheme) { double min, max; ShapeTypes aST = _legendScheme.ShapeType; min = _legendScheme.MinValue; max = _legendScheme.MaxValue; switch (aLT) { case LegendType.SingleSymbol: Color aColor = Color.Black; switch (aST) { case ShapeTypes.Point: aColor = Color.Black; break; case ShapeTypes.Polyline: case ShapeTypes.PolylineZ: aColor = Color.Black; break; case ShapeTypes.Polygon: case ShapeTypes.Image: aColor = Color.FromArgb(255, 251, 195); break; } Single size = 0.1F; if (_legendScheme.ShapeType == ShapeTypes.Point) { size = 5; } _legendScheme = LegendManage.CreateSingleSymbolLegendScheme(_legendScheme.ShapeType, aColor, size); TSB_Add.Enabled = false; TSB_Del.Enabled = false; TSB_DelAll.Enabled = false; TSB_Down.Enabled = false; TSB_Up.Enabled = false; TSB_MakeBreaks.Enabled = false; TSB_Reverse.Enabled = false; break; case LegendType.UniqueValue: Color[] colors; List <string> valueList = new List <string>(); VectorLayer aLayer = (VectorLayer)_mapLayer; bool isDateField = false; Type colType = aLayer.AttributeTable.Table.Columns[fieldName].DataType; if (colType == typeof(DateTime)) { isDateField = true; } List <string> captions = new List <string>(); for (int i = 0; i < aLayer.AttributeTable.Table.Rows.Count; i++) { if (!valueList.Contains(aLayer.AttributeTable.Table.Rows[i][fieldName].ToString())) { valueList.Add(aLayer.AttributeTable.Table.Rows[i][fieldName].ToString()); if (isDateField) { captions.Add(((DateTime)aLayer.AttributeTable.Table.Rows[i][fieldName]).ToString("yyyy/M/d")); } } } if (valueList.Count == 1) { MessageBox.Show("The values of all shapes are same!", "Alarm"); break; } if (valueList.Count <= 13) { colors = LegendManage.CreateRainBowColors(valueList.Count); } else { colors = LegendManage.CreateRandomColors(valueList.Count); } List <Color> CList = new List <Color>(colors); CList.Insert(0, Color.White); colors = CList.ToArray(); if (isDateField) { _legendScheme = LegendManage.CreateUniqValueLegendScheme(valueList, captions, colors, aST, min, max, _legendScheme.HasNoData, _legendScheme.MissingValue); } else { _legendScheme = LegendManage.CreateUniqValueLegendScheme(valueList, colors, aST, min, max, _legendScheme.HasNoData, _legendScheme.MissingValue); } _legendScheme.FieldName = fieldName; TSB_Add.Enabled = true; TSB_Del.Enabled = true; TSB_DelAll.Enabled = true; TSB_Down.Enabled = true; TSB_Up.Enabled = true; TSB_MakeBreaks.Enabled = true; TSB_Reverse.Enabled = true; break; case LegendType.GraduatedColor: aLayer = (VectorLayer)_mapLayer; double[] S = new double[aLayer.AttributeTable.Table.Rows.Count]; for (int i = 0; i < S.Length; i++) { S[i] = double.Parse(aLayer.AttributeTable.Table.Rows[i][fieldName].ToString()); } MIMath.GetMaxMinValue(S, _legendScheme.MissingValue, ref min, ref max); if (min == max) { MessageBox.Show("The values of all shapes are same!", "Alarm"); break; } double[] CValues; CValues = LegendManage.CreateContourValues(min, max); colors = LegendManage.CreateRainBowColors(CValues.Length + 1); _legendScheme = LegendManage.CreateGraduatedLegendScheme(CValues, colors, aST, min, max, _legendScheme.HasNoData, _legendScheme.MissingValue); _legendScheme.FieldName = fieldName; TSB_Add.Enabled = true; TSB_Del.Enabled = true; TSB_DelAll.Enabled = true; TSB_Down.Enabled = true; TSB_Up.Enabled = true; TSB_MakeBreaks.Enabled = true; TSB_Reverse.Enabled = true; break; } //ShowLegendScheme(_legendScheme); //DataGridView1.Refresh(); legendView1.LegendScheme = _legendScheme; legendView1.Invalidate(); } }
/// <summary> /// Import legend scheme from an image color palette file /// </summary> /// <param name="aFile">file path</param> public void ImportFromPaletteFile_Graduated(string aFile) { StreamReader sr = new StreamReader(aFile); this.ShapeType = ShapeTypes.Image; this.LegendType = LegendType.GraduatedColor; this.LegendBreaks = new List <ColorBreak>(); List <Color> colorList = new List <Color>(); List <int> values = new List <int>(); ColorBreak aCB = new ColorBreak(); string[] dataArray; int lastNonEmpty, i; sr.ReadLine(); string aLine = sr.ReadLine(); while (aLine != null) { dataArray = aLine.Split(); lastNonEmpty = -1; List <int> dataList = new List <int>(); for (i = 0; i < dataArray.Length; i++) { if (dataArray[i] != string.Empty) { lastNonEmpty++; dataList.Add(int.Parse(dataArray[i])); } } Color aColor = Color.FromArgb(255, dataList[3], dataList[2], dataList[1]); if (colorList.Count == 0) { colorList.Add(aColor); } else { if (!colorList.Contains(aColor)) { aCB = new ColorBreak(); aCB.Color = aColor; aCB.StartValue = values.Min(); aCB.EndValue = values.Max(); if (aCB.StartValue.ToString() == aCB.EndValue.ToString()) { aCB.Caption = aCB.StartValue.ToString(); } else { if (this.LegendBreaks.Count == 0) { aCB.Caption = "< " + aCB.EndValue.ToString(); } else { aCB.Caption = aCB.StartValue.ToString() + " - " + aCB.EndValue.ToString(); } } this.LegendBreaks.Add(aCB); values.Clear(); colorList.Add(aColor); } } values.Add(dataList[0]); aLine = sr.ReadLine(); } sr.Close(); aCB = new ColorBreak(); aCB.Color = colorList[colorList.Count - 1]; aCB.StartValue = values.Min(); aCB.EndValue = values.Max(); aCB.Caption = "> " + aCB.StartValue.ToString(); this.LegendBreaks.Add(aCB); }
/// <summary> /// Creates and returns column line chart legend instance. /// </summary> /// <returns>Instance of column line chart legend.</returns> protected override ChartLegend CreateChartLegend(LegendType type) { return(new ColumnLineChartLegend(this)); }
//private LegendPosition primaryLegendPosition; //public LegendPosition PrimaryLegendPosition //{ // get // { // return this.primaryLegendPosition; // } // set // { // if (this.primaryLegendPosition != value) // { // this.primaryLegendPosition = value; // this.UpdateChart(); // this.Invalidate(); // } // } //} /// <summary> /// Create chart legend. /// </summary> /// <returns>Instance of chart legend.</returns> protected virtual ChartLegend CreateChartLegend(LegendType type) { return(new ChartLegend(this)); }
private void CB_LegendType_SelectedIndexChanged(object sender, EventArgs e) { LegendType aLT = (LegendType)Enum.Parse(typeof(LegendType), CB_LegendType.Text, true); SetFieldByLegendType(aLT); }