public void AddLineChart(string name_, string[] xAxis_, double[] yAxis_) { DataTable d = new DataTable(); d.Columns.Add("Heading", typeof(string)); d.Columns.Add(name_, typeof(double)); for (int i = 0; i < xAxis_.Length; ++i) d.LoadDataRow(new object[] { xAxis_[i], yAxis_[i] }, true); ChartLayerAppearance chart; NumericSeries series; LineChartAppearance lcApp; series = new NumericSeries(); series.Data.LabelColumn = "Heading"; series.Data.ValueColumn = name_; series.Key = name_; series.Label = name_; series.PEs.Add(new PaintElement(ColorAttribute.GetColor(ultraChart.CompositeChart.Series.Count))); ultraChart.CompositeChart.Series.Add(series); chart = new ChartLayerAppearance(); chart.ChartComponent = ultraChart; chart.ChartArea = ultraChart.CompositeChart.ChartAreas[0]; chart.AxisX = chart.ChartArea.Axes.FromKey("xAxis_Line"); chart.AxisY = chart.ChartArea.Axes.FromKey("yAxis_Line"); chart.ChartType = ChartType.LineChart; lcApp = (LineChartAppearance)chart.ChartTypeAppearance; lcApp.Thickness = 2; lcApp.MidPointAnchors = false; lcApp.NullHandling = NullHandling.InterpolateSimple; chart.Key = string.Format("{0}_chart", name_); ultraChart.CompositeChart.ChartLayers.Add(chart); chart.Series.Add(series); series.Data.DataSource = d; series.DataBind(); m_datatables.Add(dt); ultraChart.InvalidateLayers(); }
private void addAreas() { if (ultraChart.CompositeChart.ChartAreas.Count > 2) return; ultraChart.CompositeChart.ChartAreas.Clear(); for (int i = 0; i < 12; ++i) { ChartArea area = new ChartArea(); AxisItem xAxis = new AxisItem(); AxisItem yAxis = new AxisItem(); Months month = (Months)(i + 1); xAxis.Key = string.Format("xAxis_{0}", i.ToString()); xAxis.DataType = Infragistics.UltraChart.Shared.Styles.AxisDataType.String; xAxis.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing; xAxis.Labels.ItemFormat = Infragistics.UltraChart.Shared.Styles.AxisItemLabelFormat.Custom; xAxis.Labels.ItemFormatString = "<ITEM_LABEL>"; xAxis.MajorGridLines.Visible = true; xAxis.OrientationType = Infragistics.UltraChart.Shared.Styles.AxisNumber.X_Axis; xAxis.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries; xAxis.Extent = 35; yAxis.Key = string.Format("yAxis_{0}", i.ToString()); yAxis.DataType = Infragistics.UltraChart.Shared.Styles.AxisDataType.Numeric; yAxis.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal; yAxis.Labels.ItemFormat = Infragistics.UltraChart.Shared.Styles.AxisItemLabelFormat.Custom; yAxis.Labels.ItemFormatString="<DATA_VALUE:#,###>"; yAxis.Labels.Font = new Font(yAxis.Labels.Font.FontFamily, 6.0f); yAxis.MajorGridLines.Visible = true; yAxis.OrientationType = Infragistics.UltraChart.Shared.Styles.AxisNumber.Y_Axis; yAxis.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries; yAxis.Extent = 18; area.Axes.Add(xAxis); area.Axes.Add(yAxis); area.Key=string.Format("area_{0}",i.ToString()); int x=i, y=i; x = i; if (i > 7) x -= 4; if (i > 3) x -= 4; y = 0; if (i > 3) ++y; if (i > 7) ++y; area.Bounds = new Rectangle(25 * x, 33 * y, 25, 33); area.BoundsMeasureType = Infragistics.UltraChart.Shared.Styles.MeasureType.Percentage; ultraChart.CompositeChart.ChartAreas.Add(area); DataTable d = new DataTable(); d.Columns.Add("Date", typeof(string)); d.Columns.Add(string.Format("{0} Perf",month.ToString()), typeof(double)); NumericSeries ns = new NumericSeries { Data = {LabelColumn = "Date", ValueColumn = string.Format("{0} Perf", month.ToString())}, Label = string.Format("{0} value", month.ToString()), Key = string.Format("series_{0}", i.ToString()) }; ultraChart.CompositeChart.Series.Add(ns); ChartLayerAppearance chart = new ChartLayerAppearance { ChartComponent = ultraChart, ChartArea = area, AxisX = area.Axes[0], AxisY = area.Axes[1], ChartType = ChartType.ColumnChart, Key = string.Format("chart_{0}", i.ToString()) }; ultraChart.CompositeChart.ChartLayers.Add(chart); chart.Series.Add(ns); ns.Data.DataSource = d; chart.SeriesList = string.Format("{0}", ns.Key); ns.DataBind(); ns.PEs.Add(new PaintElement(ColorAttribute.GetColor(i))); dts.Add(d); } }
private void setup(ReturnsEval.DataSeriesEvaluator eval_) { if (doneSetup) return; doneSetup = true; setuptooltip(); // add the columns dt.Columns.Add("Date", typeof(DateTime)); dt.Columns.Add(eval_.Name, typeof(double)); for (int i = 0; i < eval_.InnerSeries.Count; ++i) dt.Columns.Add(eval_.InnerSeries[i].Name, typeof(double)); ChartLayerAppearance chart; NumericTimeSeries series; LineChartAppearance lcApp; // example of adding layer in code // add numeric series for top series = new NumericTimeSeries(); series.Data.TimeValueColumn = "Date"; series.Data.ValueColumn = eval_.Name; series.Key = eval_.Name; series.Label = eval_.Name; ultraChart.CompositeChart.Series.Add(series); // add a layer for the overall cumulative at the top chart = new ChartLayerAppearance(); chart.ChartComponent = ultraChart; chart.ChartArea = ultraChart.CompositeChart.ChartAreas.FromKey("areaTop"); chart.AxisX = chart.ChartArea.Axes.FromKey("areaTopX"); chart.AxisY = chart.ChartArea.Axes.FromKey("areaTopY"); chart.ChartType = ChartType.LineChart; lcApp = (LineChartAppearance)chart.ChartTypeAppearance; lcApp.Thickness = 1; lcApp.MidPointAnchors = false; chart.Key = string.Concat("chart_", eval_.Name); ultraChart.CompositeChart.ChartLayers.Add(chart); // link them all up chart.Series.Add(series); series.Data.DataSource = dt; chart.SeriesList = eval_.Name; series.DataBind(); for (int i = 0; i < eval_.InnerSeries.Count; ++i) { series = new NumericTimeSeries(); series.Data.TimeValueColumn = "Date"; series.Data.ValueColumn = eval_.InnerSeries[i].Name; series.Key = eval_.InnerSeries[i].Name; series.Label = eval_.InnerSeries[i].Name; ultraChart.CompositeChart.Series.Add(series); chart = new ChartLayerAppearance(); chart.ChartComponent = ultraChart; chart.ChartArea = ultraChart.CompositeChart.ChartAreas.FromKey("areaBottom"); chart.AxisX = chart.ChartArea.Axes.FromKey("areaBottomX"); chart.AxisY = chart.ChartArea.Axes.FromKey("areaBottomY"); chart.ChartType = ChartType.LineChart; lcApp = (LineChartAppearance)chart.ChartTypeAppearance; lcApp.Thickness = 1; lcApp.MidPointAnchors = false; chart.Key = string.Concat("chart_", eval_.InnerSeries[i].Name); ultraChart.CompositeChart.ChartLayers.Add(chart); // link them all up chart.Series.Add(series); chart.SeriesList = eval_.InnerSeries[i].Name; series.Data.DataSource = dt; series.DataBind(); if (i < COLOURS.Length) series.PEs.Add(new PaintElement(COLOURS[i])); ultraChart.CompositeChart.Legends[0].ChartLayers.Add(chart); } }
public void Create(ConstructGen<double> wts_, FXGroup[] groups_) { ConstructGen<double> groupConv = new ConstructGen<double>(groups_.Length); groupConv.ColumnHeadings = groups_.Select(x => x.ToString()).ToArray(); Currency[] ccys = wts_.ColumnHeadings.Select(x => Singleton<FXIDs>.Instance[x]).ToArray(); List<int[]> indicies =new List<int[]>(); foreach(FXGroup group in groups_) { List<int> groupIndicies=new List<int>(); for(int i=0;i<ccys.Length;++i) if(ccys[i].IsGroup(group)) groupIndicies.Add(i); indicies.Add(groupIndicies.ToArray()); } foreach (DateTime date in wts_.Dates) { double[] dateWeights = wts_.GetValues(date); double[] buckets = new double[groups_.Length]; for(int g=0;g<groups_.Length;++g) foreach (int index in indicies[g]) buckets[g] += dateWeights[index]; groupConv.SetValues(date, buckets); } DataTable dt1 = groupConv.ToDataTable(groupConv.ColumnHeadings, "Date", "dd-MMM-yyyy"); Chart.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.Composite; ChartArea area = new ChartArea(); Chart.CompositeChart.ChartAreas.Add(area); AxisItem axisY = new AxisItem(); axisY.Extent = 50; axisY.DataType = AxisDataType.Numeric; axisY.OrientationType = AxisNumber.Y_Axis; axisY.LineColor = Color.Blue; axisY.Labels.Visible = true; area.Axes.Add(axisY); AxisItem axisX = new AxisItem(); axisX.DataType = AxisDataType.String; axisX.Extent = 80; axisX.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries; axisX.OrientationType = AxisNumber.X_Axis; axisX.LineColor = Color.Blue; axisX.Labels.Orientation = TextOrientation.VerticalLeftFacing; axisX.Labels.SeriesLabels.Orientation = TextOrientation.VerticalLeftFacing; area.Axes.Add(axisX); AxisItem axisX2 = new AxisItem(); axisX2.DataType = AxisDataType.String; axisX2.Extent = 80; axisX2.OrientationType = AxisNumber.X_Axis; axisX2.LineColor = Color.Blue; axisX2.Labels.Orientation = TextOrientation.VerticalLeftFacing; axisX2.Labels.SeriesLabels.Orientation = TextOrientation.VerticalLeftFacing; axisX2.SetLabelAxisType = SetLabelAxisType.ContinuousData; area.Axes.Add(axisX2); ChartLayerAppearance myColumnLayer = new ChartLayerAppearance(); myColumnLayer.ChartType = ChartType.StackColumnChart; myColumnLayer.ChartArea = area; foreach (FXGroup group in groups_) { NumericSeries series1 = new NumericSeries(); series1.Key = group.ToString(); series1.DataBind(dt1, group.ToString(), "Date"); series1.PEs.Add(new PaintElement(ColorAttribute.GetAttribute(group).Color)); myColumnLayer.Series.Add(series1); Chart.CompositeChart.Series.Add(series1); } DataTable dt2 = wts_.SumRows().ToDataTable(format_:"dd-MMM-yyyy"); ChartLayerAppearance myColumnLayer2 = new ChartLayerAppearance(); myColumnLayer2.ChartType = ChartType.LineChart; myColumnLayer2.ChartArea = area; NumericSeries seriesA = new NumericSeries(); seriesA.Key = "Sum of Wts"; seriesA.DataBind(dt2, "Value", "Date"); seriesA.PEs.Add(new PaintElement(Color.Orange)); myColumnLayer2.Series.Add(seriesA); Chart.CompositeChart.Series.Add(seriesA); LineChartAppearance la = new LineChartAppearance(); la.Thickness = 4; myColumnLayer2.ChartTypeAppearance = la; myColumnLayer.AxisX = axisX; myColumnLayer.AxisY = axisY; myColumnLayer2.AxisX = axisX2; myColumnLayer2.AxisY = axisY; myColumnLayer.SwapRowsAndColumns = true; this.Chart.CompositeChart.ChartLayers.Add(myColumnLayer); this.Chart.CompositeChart.ChartLayers.Add(myColumnLayer2); EstablishDefaultTooltip(); m_wts = wts_; m_groups = groups_; pbSplitIntoYears.BringToFront(); }
public ChartLayerAppearance AddScatterSeries(string desc_, string[] xAxis_, double[] yAxis_, Color color_, NullHandling nullHandling_ = NullHandling.DontPlot, SymbolIcon icon = SymbolIcon.Circle) { var d = new DataTable(); d.Columns.Add("Heading", typeof(string)); d.Columns.Add(desc_, typeof(double)); for (int i = 0; i < xAxis_.Length; ++i) { d.LoadDataRow(!double.IsNaN(yAxis_[i]) ? new object[] {xAxis_[i], yAxis_[i]} : new object[] {xAxis_[i]}, true); } var series = new NumericSeries { Key = desc_, Label = desc_, Data = { LabelColumn = "Heading", ValueColumn = desc_ } }; series.PEs.Add(new PaintElement(color_)); ultraChart.CompositeChart.Series.Add(series); var chart = new ChartLayerAppearance { ChartComponent = ultraChart, ChartArea = ultraChart.CompositeChart.ChartAreas[0], ChartType = ChartType.LineChart, Key = string.Format("{0}_chart", desc_), }; chart.Series.Add(series); series.Data.DataSource = d; series.DataBind(); chart.AxisX = chart.ChartArea.Axes.FromKey("xAxis_Line"); chart.AxisY = chart.ChartArea.Axes.FromKey("yAxis_Line"); var lcApp = (LineChartAppearance)chart.ChartTypeAppearance; { lcApp.EndStyle = LineCapStyle.Round; lcApp.DrawStyle = LineDrawStyle.Dot; lcApp.Thickness = 7; lcApp.MidPointAnchors = true; //lcApp.ConnectWithLines = false; //lcApp.Icon = icon; //lcApp.IconSize = SymbolIconSize.Medium; lcApp.NullHandling = nullHandling_; } ultraChart.CompositeChart.ChartLayers.Add(chart); m_datatables.Add(desc_, d); ultraChart.InvalidateLayers(); return chart; }
public void AddColumnChart(string name_, string[] xAxis_, double[] yAxis_, double maxValue_) { DataTable d = new DataTable(); d.Columns.Add("Heading", typeof(string)); d.Columns.Add(name_, typeof(double)); for (int i = 0; i < xAxis_.Length; ++i) d.LoadDataRow(new object[] { xAxis_[i], yAxis_[i] }, true); var series = new NumericSeries {Data = {LabelColumn = "Heading", ValueColumn = name_}, Key = name_, Label = name_}; series.PEs.Add(new PaintElement(Color.White, Color.Transparent, 200, 200, GradientStyle.ForwardDiagonal, PaintElementType.Gradient)); ultraChart.CompositeChart.Series.Add(series); var chart = new ChartLayerAppearance { ChartComponent = ultraChart, ChartArea = ultraChart.CompositeChart.ChartAreas[0], ChartType = ChartType.ColumnChart, Key = string.Format("{0}_chart", name_) }; chart.AxisX = chart.ChartArea.Axes.FromKey("xAxis_Column"); chart.AxisY = chart.ChartArea.Axes.FromKey("yAxis_Column"); chart.AxisY.Labels.ItemFormat = AxisItemLabelFormat.Custom; chart.AxisY.Labels.ItemFormatString = "<DATA_VALUE:##0.0%>"; ultraChart.CompositeChart.ChartLayers.Add(chart); chart.Series.Add(series); series.Data.DataSource = d; series.DataBind(); { var axis = ultraChart.CompositeChart.ChartAreas[0].Axes.FromKey("yAxis_Column"); double max = yAxis_.Select(x => Math.Abs(x)).Max(); axis.RangeType = AxisRangeType.Custom; axis.RangeMin = -maxValue_; axis.RangeMax = maxValue_; axis.TickmarkStyle = AxisTickStyle.Percentage; axis.TickmarkPercentage = 10d; } //m_datatables.Add(dt); ultraChart.InvalidateLayers(); }
public void AddLineChart(string name_, string[] xAxis_, double[] yAxis_) { var d = new DataTable(); d.Columns.Add("Heading", typeof(string)); d.Columns.Add(name_, typeof(double)); for (int i = 0; i < xAxis_.Length; ++i) { if (double.IsNaN(yAxis_[i]) == false) d.LoadDataRow(new object[] { xAxis_[i], yAxis_[i] }, true); else d.LoadDataRow(new object[] { xAxis_[i] }, true); } var series = new NumericSeries {Data = {LabelColumn = "Heading", ValueColumn = name_}, Key = name_, Label = name_}; series.PEs.Add(new PaintElement(ColorAttribute.GetColor(ultraChart.CompositeChart.Series.Count))); ultraChart.CompositeChart.Series.Add(series); var chart = new ChartLayerAppearance { ChartComponent = ultraChart, ChartArea = ultraChart.CompositeChart.ChartAreas[0] }; chart.AxisX = chart.ChartArea.Axes.FromKey("xAxis_Line"); chart.AxisY = chart.ChartArea.Axes.FromKey("yAxis_Line"); chart.ChartType = ChartType.LineChart; var lcApp = (LineChartAppearance)chart.ChartTypeAppearance; lcApp.Thickness = 3; lcApp.MidPointAnchors = false; lcApp.NullHandling = NullHandling.DontPlot; lcApp.HighLightLines = true; chart.Key = string.Format("{0}_chart", name_); ultraChart.CompositeChart.ChartLayers.Add(chart); chart.Series.Add(series); series.Data.DataSource = d; series.DataBind(); m_datatables.Add(name_, d); ultraChart.InvalidateLayers(); }
private void ultraChart1_Load(object sender, EventArgs e) { this.ultraChart1.Tooltips.HighlightDataPoint = false; ultraChart1.ChartType = ChartType.Composite; ultraChart1.Data.ZeroAligned = true; ChartArea myChartArea = new ChartArea(); this.ultraChart1.CompositeChart.ChartAreas.Add(myChartArea); AxisItem axisX = new AxisItem(); AxisItem axisY = new AxisItem(); //Line axisX.OrientationType = AxisNumber.X_Axis; axisX.DataType = AxisDataType.String; axisX.SetLabelAxisType = SetLabelAxisType.ContinuousData; axisX.Labels.ItemFormatString = "<ITEM_LABEL:M/d>"; //axisX.Labels.ItemFormatString = "< MY_VALUE >"; axisX.Labels.Orientation = TextOrientation.VerticalLeftFacing; axisX.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.None; axisX.LineThickness = 1; //axisX.Extent = 40; axisX.Labels.Visible = true; axisX.Labels.Font = ultraChart1.Axis.X.Labels.SeriesLabels.Font; axisX.Labels.FontColor = ultraChart1.Axis.X.Labels.SeriesLabels.FontColor; //axisX.ScrollScale.Visible = true; axisY.OrientationType = AxisNumber.Y_Axis; axisY.Labels.HorizontalAlign = StringAlignment.Far; axisY.DataType = AxisDataType.Numeric; axisY.Labels.ItemFormatString = "<DATA_VALUE:##.#>"; //axisY.Labels.ItemFormatString = "< MY_VALUE >"; axisY.TickmarkStyle = AxisTickStyle.Smart; axisY.LineThickness = 1; //axisY.Extent = 10; axisY.RangeType = AxisRangeType.Custom; axisY.RangeMin = 0; axisY.RangeMax = 600; axisY.Labels.Font = ultraChart1.Axis.Y.Labels.Font; axisY.Labels.FontColor = ultraChart1.Axis.Y.Labels.FontColor; myChartArea.Axes.Add(axisX); myChartArea.Axes.Add(axisY); ChartLayerAppearance myLineLayer1 = new ChartLayerAppearance(); myLineLayer1.ChartType = ChartType.LineChart; myLineLayer1.ChartArea = myChartArea; myLineLayer1.AxisX = axisX; myLineLayer1.AxisY = axisY; ((LineChartAppearance)myLineLayer1.ChartTypeAppearance).Thickness = 1; DataTable table = new DataTable(); table = GetLineData(); for (int iC = 0; iC < table.Columns.Count - 1; iC++) { NumericSeries series = new NumericSeries(); series.Data.DataSource = table; series.Data.LabelColumn = table.Columns[0].Caption.ToString(); series.Data.ValueColumn = table.Columns[iC + 1].Caption.ToString(); series.Label = table.Columns[iC + 1].Caption.ToString(); series.DataBind(); myLineLayer1.Series.Add(series); } ultraChart1.CompositeChart.ChartLayers.Add(myLineLayer1); ultraChart1.Tooltips.Format = TooltipStyle.DataValue; //ultraChart1.Tooltips.FormatString = "<DATA_VALUE:0> <ITEM_LABEL> <SERIES_LABEL>"; ultraChart1.Tooltips.FormatString = "<DATA_VALUE>"; CompositeLegend myLegend = new CompositeLegend(); myLegend.ChartLayers.Add(myLineLayer1); myLegend.Bounds = new Rectangle(0, 1, 10, 50); myLegend.BoundsMeasureType = MeasureType.Percentage; myLegend.PE.ElementType = PaintElementType.None; myLegend.PE.FillGradientStyle = GradientStyle.ForwardDiagonal; myLegend.PE.FillStopColor = Color.Transparent; myLegend.Border.CornerRadius = 0; myLegend.Border.Thickness = 2; ultraChart1.CompositeChart.Legends.Add(myLegend); Hashtable MyLabelHashTable = new Hashtable(); MyLabelHashTable.Add("MY_VALUE", new MyLabelRenderer()); this.ultraChart1.LabelHash = MyLabelHashTable; this.ultraChart1.Tooltips.Format = TooltipStyle.Custom; this.ultraChart1.Tooltips.FormatString = "<MY_VALUE>"; this.ultraChart1.Tooltips.Overflow = TooltipOverflow.ChartArea; }
public ChartLayerAppearance AddScatterSeries(string areaKey_, double[] xValues_, double[] yValues_, string[] pointNames_, string desc_, Color[] colors_, string yLabelFormat_) { if (xValues_ == null || xValues_.Length == 0) return null; //DataTable d = new DataTable(); //d.Columns.Add("Label", typeof (string)); //d.Columns.Add("XValue", typeof (double)); //d.Columns.Add("YValue", typeof (double)); //for (int i = 0; i < xValues_.Length; ++i) //{ // d.LoadDataRow(new object[] // { // pointNames_[i], // xValues_[i], // yValues_[i] // }, true); //} var chart = new ChartLayerAppearance { ChartComponent = ultraChart1, ChartArea = ultraChart1.CompositeChart.ChartAreas.FromKey(areaKey_), ChartType = ChartType.ScatterChart, }; chart.AxisX = chart.ChartArea.Axes[0]; chart.AxisY = chart.ChartArea.Axes[1]; for (int i = 0; i < pointNames_.Length; ++i) { var series = new XYSeries { Key = string.Format("{0}_{1}", areaKey_, pointNames_[i]), Label = string.Format("{0}_{1}", areaKey_, pointNames_[i]) }; series.Points.Add(new XYDataPoint(xValues_[i], yValues_[i], pointNames_[i], false)); series.PEs.Add(new PaintElement(colors_[i])); ultraChart1.CompositeChart.Series.Add(series); chart.Series.Add(series); } var lcApp = (ScatterChartAppearance)chart.ChartTypeAppearance; lcApp.ConnectWithLines = false; lcApp.Icon = SymbolIcon.Diamond; lcApp.IconSize = SymbolIconSize.Medium; //lcApp.ChartText.Add(new ChartTextAppearance() //{ // Row = -2, // Column = -2, // ItemFormatString = "<ITEM_LABEL>", // Visible = true, // FontColor=Color.White //}); //lcApp.NullHandling = nullHandling_; chart.Key = string.Format("{0}_chart", desc_); ultraChart1.CompositeChart.ChartLayers.Add(chart); return chart; }
public ChartLayerAppearance AddBottomSeries(DateTime[] dates_, double[] values_, string desc_, Color lineColor_, object nanReplaceValue = null, NullHandling nullHandling_ = NullHandling.Zero) { if (dates_ == null || dates_.Length == 0) return null; DataTable d = new DataTable(); d.Columns.Add("Date", typeof(DateTime)); d.Columns.Add(desc_, typeof(double)); for (int i = 0; i < dates_.Length; ++i) { if (double.IsNaN(values_[i])) d.LoadDataRow(new object[] { dates_[i], nanReplaceValue }, true); else d.LoadDataRow(new object[] { dates_[i], values_[i] }, true); } var series = new NumericTimeSeries(); series.Data.TimeValueColumn = "Date"; series.Data.ValueColumn = desc_; series.Key = desc_; series.Label = desc_; series.PEs.Add(new PaintElement(lineColor_)); ultraChart1.CompositeChart.Series.Add(series); var chart = new ChartLayerAppearance(); chart.ChartComponent = ultraChart1; chart.ChartArea = ultraChart1.CompositeChart.ChartAreas.FromKey("areaBottom"); chart.AxisX = chart.ChartArea.Axes[0]; chart.AxisY = chart.ChartArea.Axes[1]; chart.ChartType = ChartType.LineChart; var lcApp = (LineChartAppearance)chart.ChartTypeAppearance; lcApp.Thickness = 2; lcApp.MidPointAnchors = false; lcApp.NullHandling = nullHandling_; chart.Key = string.Format("{0}_chart", desc_); ultraChart1.CompositeChart.ChartLayers.Add(chart); chart.Series.Add(series); series.Data.DataSource = d; series.DataBind(); m_datatables.Add(desc_, d); return chart; }
public ChartLayerAppearance AddSeries(int areaIndex_, DateTime[] dates_, double[] values_, string desc_, object nanReplaceValue = null, NullHandling nullHandling_ = NullHandling.Zero, int yAxisExtent_=15, string yAxisFormat_=null) { DataTable d = new DataTable(); d.Columns.Add("Date", typeof(DateTime)); d.Columns.Add(desc_, typeof(double)); for (int i = 0; i < dates_.Length; ++i) { if (double.IsNaN(values_[i])) d.LoadDataRow(new object[] { dates_[i], nanReplaceValue }, true); else d.LoadDataRow(new object[] { dates_[i], values_[i] }, true); } ChartLayerAppearance chart; NumericTimeSeries series; LineChartAppearance lcApp; series = new NumericTimeSeries(); series.Data.TimeValueColumn = "Date"; series.Data.ValueColumn = desc_; series.Key = desc_; series.Label = desc_; series.PEs.Add(new PaintElement(ColorAttribute.GetColor(ultraChart.CompositeChart.Series.Count))); ultraChart.CompositeChart.Series.Add(series); chart = new ChartLayerAppearance(); chart.ChartComponent = ultraChart; chart.ChartArea = ultraChart.CompositeChart.ChartAreas[areaIndex_]; chart.AxisX = chart.ChartArea.Axes[0]; chart.AxisY = findYAxis(areaIndex_, yAxisExtent_, yAxisFormat_ == null ? m_yAxisLabelFormatString : yAxisFormat_); chart.ChartType = ChartType.LineChart; lcApp = (LineChartAppearance)chart.ChartTypeAppearance; lcApp.Thickness = 2; lcApp.MidPointAnchors = false; lcApp.NullHandling = nullHandling_; chart.Key = string.Format("{0}_{1}_chart_l",areaIndex_, desc_); ultraChart.CompositeChart.ChartLayers.Add(chart); chart.Series.Add(series); series.Data.DataSource = d; chart.Series.Add(series); series.DataBind(); return chart; }
public ChartLayerAppearance AddScatterSeries(int areaIndex_, DateTime[] dates_, double[] values_, string desc_, Color color_, object nanREplaceValue_ = null, NullHandling nullHandling_ = NullHandling.Zero) { DataTable d = new DataTable(); d.Columns.Add("Date", typeof(DateTime)); d.Columns.Add(desc_, typeof(double)); for (int i = 0; i < dates_.Length; ++i) if (double.IsNaN(values_[i])) d.LoadDataRow(new object[] { dates_[i], nanREplaceValue_ }, true); else d.LoadDataRow(new object[] { dates_[i], values_[i] }, true); ChartLayerAppearance chart; NumericTimeSeries series; ScatterChartAppearance lcApp; series = new NumericTimeSeries(); series.Data.TimeValueColumn = "Date"; series.Data.ValueColumn = desc_; series.Key = string.Format("{0}_{1}_sc", areaIndex_, desc_); ; series.Label = desc_; series.PEs.Add(new PaintElement(color_)); ultraChart.CompositeChart.Series.Add(series); chart = new ChartLayerAppearance(); chart.ChartComponent = ultraChart; chart.ChartArea = ultraChart.CompositeChart.ChartAreas[areaIndex_]; chart.AxisX = chart.ChartArea.Axes[0]; chart.AxisY = chart.ChartArea.Axes[1]; chart.ChartType = ChartType.ScatterChart; lcApp = (ScatterChartAppearance)chart.ChartTypeAppearance; lcApp.ConnectWithLines = false; lcApp.Icon = SymbolIcon.Circle; lcApp.IconSize = SymbolIconSize.Medium; lcApp.NullHandling = nullHandling_; chart.Key = string.Format("{0}_{1}_sc_chart", areaIndex_, desc_); ultraChart.CompositeChart.ChartLayers.Add(chart); chart.Series.Add(series); series.Data.DataSource = d; chart.Series.Add(series); series.DataBind(); dts.Add(d); //m_yAxisDescriptionToFormat[desc_] = yLabelFormat_; return chart; }
private void addAreas() { if (ultraChart.CompositeChart.ChartAreas.Count > 2) return; ultraChart.CompositeChart.ChartAreas.Clear(); int areaWidth = (int)100 / m_cols; int areaHeight = (int)100 / m_rows; for (int i = 0; i < m_data.Count(); ++i) { Label l = new Label(); l.Font = new Font("Tahoma", 5.75F, FontStyle.Regular); l.Text = m_data[i].Item1; l.ForeColor = Color.White; Controls.Add(l); l.BringToFront(); l.BackColor = Color.White; l.AutoSize = true; lbls.Add(l); ChartArea area = new ChartArea(); AxisItem xAxis = new AxisItem(); AxisItem yAxis = new AxisItem(); xAxis.Key = string.Format("xAxis_{0}", i.ToString()); xAxis.DataType = Infragistics.UltraChart.Shared.Styles.AxisDataType.Time; xAxis.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing; xAxis.Labels.ItemFormat = Infragistics.UltraChart.Shared.Styles.AxisItemLabelFormat.Custom; xAxis.Labels.ItemFormatString = string.Format("<ITEM_LABEL:{0}>",m_xAxisLabelFormatString); xAxis.Labels.Font = new Font("Tahoma", 5.75F); xAxis.MajorGridLines.Visible = true; xAxis.OrientationType = Infragistics.UltraChart.Shared.Styles.AxisNumber.X_Axis; xAxis.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries; xAxis.Extent = 20; yAxis.Key = string.Format("yAxis_{0}", i.ToString()); yAxis.DataType = Infragistics.UltraChart.Shared.Styles.AxisDataType.Numeric; yAxis.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal; yAxis.Labels.ItemFormat = Infragistics.UltraChart.Shared.Styles.AxisItemLabelFormat.Custom; yAxis.Labels.HorizontalAlign = StringAlignment.Near; yAxis.Labels.Font = new Font("Tahoma", 5.75F); yAxis.Labels.ItemFormatString = string.Format("<DATA_VALUE:{0}>", m_yAxisLabelFormatString); yAxis.MajorGridLines.Visible = true; yAxis.OrientationType = Infragistics.UltraChart.Shared.Styles.AxisNumber.Y_Axis; yAxis.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries; yAxis.Extent = 15; area.Axes.Add(xAxis); area.Axes.Add(yAxis); area.Key = string.Format("area_{0}", i.ToString()); int x = i, y = 0; while (x > (m_cols-1)) { ++y; x -= m_cols; } area.Bounds = new Rectangle(areaWidth * x, areaHeight * y, areaWidth, areaHeight); area.BoundsMeasureType = Infragistics.UltraChart.Shared.Styles.MeasureType.Percentage; ultraChart.CompositeChart.ChartAreas.Add(area); for (int j = 0; j < 1; ++j) { DataTable d = new DataTable(); d.Columns.Add("Date", typeof(DateTime)); d.Columns.Add("Px", typeof(double)); NumericTimeSeries ns = new NumericTimeSeries(); ns.Data.TimeValueColumn = "Date"; ns.Data.ValueColumn = "Px"; ns.Key = string.Format("series_{0}_{1}", i.ToString(), j.ToString()); ultraChart.CompositeChart.Series.Add(ns); ChartLayerAppearance chart = new ChartLayerAppearance(); chart.ChartComponent = ultraChart; chart.ChartArea = area; chart.AxisX = area.Axes[0]; chart.AxisY = area.Axes[1]; chart.ChartType = ChartType.LineChart; chart.Key = string.Format("chart_{0}_{1}", i.ToString(), j.ToString()); LineChartAppearance lca = (LineChartAppearance)chart.ChartTypeAppearance; lca.Thickness = 1; lca.MidPointAnchors = false; lca.EndStyle = LineCapStyle.NoAnchor; ultraChart.CompositeChart.ChartLayers.Add(chart); chart.Series.Add(ns); ns.Data.DataSource = d; chart.SeriesList = ns.Key; ns.DataBind(); ns.PEs.Add(new PaintElement(Color.LightGray)); dts.Add(d); } } }
private void AlimentaGraficos() { //http://help.infragistics.com/Help/Doc/WinForms/2012.1/CLR2.0/html/Chart_Creating_a_Composite_Chart_in_Code_Part_1_of_2.html //http://help.infragistics.com/Help/Doc/WinForms/2012.1/CLR2.0/html/Chart_Creating_a_Composite_Chart_in_Code_Part_2_of_2.html //Aqui define o tipo de gráfico que será realizado. //https://www.infragistics.com/help/winforms/chart-2d-charts this.ultraChart1.ChartType = ChartType.Composite; ChartArea myChartArea = new ChartArea(); this.ultraChart1.CompositeChart.ChartAreas.Add(myChartArea); AxisItem axisX = new AxisItem(); axisX.OrientationType = AxisNumber.X_Axis; axisX.DataType = AxisDataType.String; axisX.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries; axisX.Labels.ItemFormatString = "<ITEM_LABEL>"; axisX.Labels.Orientation = TextOrientation.VerticalLeftFacing; AxisItem axisY = new AxisItem(); axisY.OrientationType = AxisNumber.Y_Axis; axisY.DataType = AxisDataType.Numeric; axisY.Labels.ItemFormatString = "<DATA_VALUE:0.#>"; //Adiciona os gráficos myChartArea.Axes.Add(axisX); myChartArea.Axes.Add(axisY); //Adiciona as séries na interface NumericSeries seriesA = GetNumericSeriesBound(); NumericSeries seriesB = GetNumericSeriesUnBound(); this.ultraChart1.CompositeChart.Series.Add(seriesA); this.ultraChart1.CompositeChart.Series.Add(seriesB); //Cria a aparência das colunas ChartLayerAppearance myColumnLayer = new ChartLayerAppearance(); myColumnLayer.ChartType = ChartType.ColumnChart; myColumnLayer.ChartArea = myChartArea; myColumnLayer.AxisX = axisX; myColumnLayer.AxisY = axisY; myColumnLayer.Series.Add(seriesA); myColumnLayer.Series.Add(seriesB); this.ultraChart1.CompositeChart.ChartLayers.Add(myColumnLayer); //Cria a legenda CompositeLegend myLegend = new CompositeLegend(); myLegend.ChartLayers.Add(myColumnLayer); myLegend.Bounds = new Rectangle(0, 75, 20, 25); myLegend.BoundsMeasureType = MeasureType.Percentage; myLegend.PE.ElementType = PaintElementType.Gradient; myLegend.PE.FillGradientStyle = GradientStyle.ForwardDiagonal; myLegend.PE.Fill = Color.CornflowerBlue; myLegend.PE.FillStopColor = Color.Transparent; myLegend.Border.CornerRadius = 10; myLegend.Border.Thickness = 0; this.ultraChart1.CompositeChart.Legends.Add(myLegend); }
public void Create(DatedDataCollectionGen<double> values_, DatedDataCollectionGen<double> zoneLookup_, IList<ZoneDefinition> zones_) { while (ultraChart.CompositeChart.ChartAreas.Count > 1) ultraChart.CompositeChart.ChartAreas.RemoveAt(1); ultraChart.Dock = DockStyle.None; ultraChart.Anchor=AnchorStyles.Bottom|AnchorStyles.Top|AnchorStyles.Right|AnchorStyles.Left; ultraChart.Location=new Point(0,0); ultraChart.Size=new Size(Size.Width,Size.Height-40); if (flp == null) { flp = new FlowLayoutPanel(); flp.Size = new Size(Width, 40); flp.Dock = DockStyle.Bottom; Controls.Add(flp); } flp.Controls.Clear(); ultraChart.CompositeChart.ChartLayers.Clear(); ultraChart.CompositeChart.Series.Clear(); ultraChart.CompositeChart.Legends[0].ChartLayers.Clear(); dt.Rows.Clear(); dt.Columns.Clear(); // add columns into datatable dt.Columns.Add("Date", typeof(DateTime)); for (int i = 0; i < zones_.Count; ++i) { dt.Columns.Add(zones_[i].Name, typeof(double)); zones_[i].Index = i; } // add first row DataRow row = dt.NewRow(); row[0] = zoneLookup_.Dates[0]; dt.Rows.Add(row); double prevPrice = values_.ValueOnDate(zoneLookup_.Dates[0]); double low = double.MaxValue; double high = double.MinValue; for (int d = 1; d < zoneLookup_.Length; ++d) { DateTime date = zoneLookup_.Dates[d]; DataRow newRow = dt.NewRow(); newRow[0] = date; double px = values_.ValueOnDate(date); double score = zoneLookup_.ValueOnDate(date); low = Math.Min(low, px); high = Math.Max(high, px); for (int i = 0; i < zones_.Count; ++i) { if (zones_[i].Matches(score)) { newRow[i + 1] = px; dt.Rows[dt.Rows.Count - 1][i + 1] = prevPrice; break; } } prevPrice = px; dt.Rows.Add(newRow); } // create the layers for each heading for(int j=0;j<zones_.Count;++j) { string heading = zones_[j].Name; NumericTimeSeries nts = new NumericTimeSeries(); nts.Key = string.Format("Series{0}",heading); nts.Label = heading; nts.PEs.Add(new PaintElement(zones_[j].LineColour)); ultraChart.CompositeChart.Series.Add(nts); nts.Data.TimeValueColumn = "Date"; nts.Data.ValueColumn = heading; LineChartAppearance lca = new LineChartAppearance(); ChartLayerAppearance cla = new ChartLayerAppearance(); cla.AxisXKey = "axis1"; cla.AxisYKey = "axis2"; cla.ChartAreaKey = "area1"; cla.ChartType = ChartType.LineChart; lca.EndStyle = m_capStyle; lca.StartStyle = m_capStyle; lca.NullHandling=NullHandling.DontPlot; lca.Thickness = LineThickness; cla.ChartTypeAppearance = lca; cla.Key = string.Format("chartLayer{0}",j.ToString()); cla.SeriesList = nts.Key; ultraChart.CompositeChart.ChartLayers.Add(cla); AxisItem ai = ultraChart.CompositeChart.ChartAreas[0].Axes.FromKey("axis2"); { ai.RangeType = AxisRangeType.Custom; ai.RangeMin = low; ai.RangeMax = high; } nts.Data.DataSource = dt; nts.DataBind(); System.Windows.Forms.CheckBox cb = new System.Windows.Forms.CheckBox(); cb.Text = heading; cb.AutoSize = true; cb.Margin = new Padding(1, 1, 1, 1); cb.Tag = j; flp.Controls.Add(cb); cb.Checked = true; cb.CheckedChanged += handleCheckedChanged; cb.ForeColor = zones_[j].LineColour; cb.BackColor = Color.FromArgb(15,15,15); //ultraChart.CompositeChart.ChartLayers.Add(cla); ultraChart.CompositeChart.Legends[0].ChartLayers.Add(cla); } ultraChart.InvalidateLayers(); }
public void AddSeries(DatedDataCollectionGen<double> series_, string heading_, Color color_, int extent_, string yLabelFormat_) { DataTable table = series_.ToDataTable(); NumericTimeSeries nts = new NumericTimeSeries(); nts.Key = string.Format("Series{0}", heading_); nts.Label = heading_; nts.PEs.Add(new PaintElement(color_)); ultraChart.CompositeChart.Series.Add(nts); nts.Data.TimeValueColumn = "Date"; nts.Data.ValueColumn = "Value"; LineChartAppearance lca = new LineChartAppearance(); ChartLayerAppearance cla = new ChartLayerAppearance(); int j = ultraChart.CompositeChart.ChartLayers.Count; cla.AxisXKey = "axis1"; cla.AxisY = findYAxis(extent_, yLabelFormat_); //cla.AxisYKey = "axis2"; cla.ChartAreaKey = "area1"; cla.ChartType = ChartType.LineChart; lca.EndStyle = m_capStyle; lca.StartStyle = m_capStyle; lca.NullHandling = NullHandling.DontPlot; lca.Thickness = LineThickness; cla.ChartTypeAppearance = lca; cla.Key = string.Format("chartLayer{0}", j.ToString()); cla.SeriesList = nts.Key; ultraChart.CompositeChart.ChartLayers.Add(cla); nts.Data.DataSource = table; nts.DataBind(); System.Windows.Forms.CheckBox cb = new System.Windows.Forms.CheckBox(); cb.Text = heading_; cb.AutoSize = true; cb.Margin = new Padding(1, 1, 1, 1); cb.Tag = j; flp.Controls.Add(cb); cb.Checked = true; cb.CheckedChanged += handleCheckedChanged; cb.ForeColor = color_; cb.BackColor = Color.FromArgb(15, 15, 15); ultraChart.CompositeChart.Legends[0].ChartLayers.Add(cla); ultraChart.InvalidateLayers(); }
private static void SetYAxisForChart(LineChartDataDisplay chart, ChartLayerAppearance chartAppearance) { chartAppearance.AxisY = chart.FindYAxis(40, "##0.000", AxisNumber.Y2_Axis); chartAppearance.AxisY.RangeType = AxisRangeType.Custom; var max = (double) chartAppearance.Series.GetDataMaximum(AxisDataType.Numeric); var min = (double) chartAppearance.Series.GetDataMinimum(AxisDataType.Numeric); chartAppearance.AxisY.RangeMax = max + (max - min)*0.1; chartAppearance.AxisY.RangeMin = min - (max - min)*0.1; }