i whant join my control ultradatachart with my control ultraleyend yo show only 1 image of the code in my winform
private void Form1_Load(object sender, EventArgs e) { var data = CreateCharts2();
CreteGraphic(data, ultraDataChart1, ultraLegend1, "MS"); CreteGraphic(data, ultraDataChart2, ultraLegend2, "LIT"); CreteGraphic(data, ultraDataChart3, ultraLegend3, "MPR"); CreteGraphic(data, ultraDataChart4, ultraLegend4, "ALL");
}
private void CreteGraphic(DataSet data, UltraDataChart udChart, UltraLegend ultraLegend, string company) { var yAxis1 = new NumericYAxis { LabelLocation = AxisLabelsLocation.OutsideLeft, TickLength = 1, Stroke = new SolidColorBrush {Color = Color.Black}, LabelsVisible = true, }; var categoryXAxis0 = new CategoryXAxis { Label = "wk_nm", LabelLocation = AxisLabelsLocation.OutsideBottom, DataSource = data.Tables[0], Stroke = new SolidColorBrush { Color = Color.Black }, Strip = new SolidColorBrush { Color = Color.LightSkyBlue}, TickStrokeThickness = 3, Interval = .5, LabelAngle = 90 };
//1.this year client //2.this year non-client //3.this year client &non - client //4.last year client //5.last year non-client //6.last year client &non - client
ColumnSeries thisYearClient = CreteSeries( data.Tables[0], $"{company}_this_year_client", $"ThisYr{company}-Client", categoryXAxis0, yAxis1, ultraLegend);
ColumnSeries thisYearNonClient = CreteSeries( data.Tables[1], $"{company}_this_year_nonclient", $"ThisYr{company}-NonClient", categoryXAxis0, yAxis1, ultraLegend);
ColumnSeries thisYearAll = CreteSeries( data.Tables[2], $"{company}_this_year_all", $"ThisYr{company}-All", categoryXAxis0, yAxis1, ultraLegend);
ColumnSeries lastYearClient = CreteSeries( data.Tables[0], $"{company}_this_year_client", $"LastYr{company}-Client", categoryXAxis0, yAxis1, ultraLegend);
ColumnSeries lastYearNonClient = CreteSeries( data.Tables[1], $"{company}_last_year_nonclient", $"LastYr{company}-NonClient", categoryXAxis0, yAxis1, ultraLegend);
ColumnSeries lastYearAll = CreteSeries( data.Tables[2], $"{company}_last_year_all", $"LastYr{company}-All", categoryXAxis0, yAxis1, ultraLegend);
thisYearClient.Brush = new SolidColorBrush { Color = Color.Orange }; thisYearNonClient.Brush = new SolidColorBrush { Color = Color.Green }; thisYearAll.Brush = new SolidColorBrush { Color = Color.Purple }; lastYearClient.Brush = new SolidColorBrush { Color = Color.LightSalmon }; lastYearNonClient.Brush = new SolidColorBrush { Color = Color.LightGreen }; lastYearAll.Brush = new SolidColorBrush { Color = Color.Violet };
udChart.Series.Add(thisYearClient); udChart.Series.Add(thisYearNonClient); udChart.Series.Add(thisYearAll); udChart.Series.Add(lastYearClient); udChart.Series.Add(lastYearNonClient); udChart.Series.Add(lastYearAll);
udChart.Legend = ultraLegend; udChart.Legend.BorderStyle = BorderStyle.FixedSingle; udChart.Legend.Location = new Point(udChart.Right, udChart.Top); udChart.Legend.Size = new System.Drawing.Size(150, udChart.Height); udChart.Legend.BackColor = udChart.BackColor;
udChart.Axes.Add(categoryXAxis0); udChart.Axes.Add(yAxis1);
//udChart.Legend. = Bottom;
udChart.BackColor= new SolidColorBrush { Color =Color.Azure }; udChart.GridMode=GridMode.BehindSeries; udChart.VerticalZoomable = true; udChart.HorizontalZoomable = true; //this.ultraDataChart1.SaveTo(@"C:\Angelo\chart.png", ImageFormat.Png); }
private static ColumnSeries CreteSeries(DataTable data, string field, string title, CategoryXAxis x, NumericYAxis y, UltraLegend ultra) { var columnSeries = new ColumnSeries { DataSource = data, ValueMemberPath = field.ToLower(), Title = title, XAxis = x, YAxis = y, Legend = ultra, LegendItemVisibility = Visibility.Visible, Name = title, }; return columnSeries; }
this is the code i use to create independently
Hello Angelo,
From the code provided it seems that you are creating several UltraDataCharts together with UltraLegends. However, I am not sure what your issue is. In addition, I do not know what CreateCharts2 method does, therefore I am not able to test your code. Can you provide me information about what your aim is as well as what exactly you are not able to achieve? Also, what CreateCharts2 method does – if you can send me the body of this method it will be great.
Looking forward to your reply.
actually i had a control ultradatachart, in this control add 6 series, and in the same time this series feed other control (ultralegend), if you see is 2 controls individual, i want create o manage only 1 control (ultradatachart) and inside this control i wan to see the graphic of 6 series, and additional the legend, i want see the legend on right top of ultradatachart
that method is only for fill a dataset
private DataSet CreateCharts2() { //var query = "select WeekEnding,LastYrCumLIT,ThisYrCumLIT,LastYrCumMPR,ThisYrCumMPR,LastYrCumMS,ThisYrCumMS," + // "LastYrLIT,ThisYrLIT,LastYrMPR,ThisYrMPR,LastYrMS,ThisYrMS from mktweeklystats"; var query = "select CONVERT(VARCHAR(10), wk_nm, 103) as wk_nm," + "ms_this_year as ms_this_year_client," + "ms_last_year as ms_last_year_client," + "lit_this_year as lit_this_year_client," + "lit_last_year as lit_last_year_client," + "mpr_this_year as mpr_this_year_client," + "mpr_last_year as mpr_last_year_client," + "all_this_year as all_this_year_client," + "all_last_year as all_last_year_client " + "from angelod1" + ";select CONVERT(VARCHAR(10), wk_nm, 103) as wk_nm," + "ms_this_year as ms_this_year_nonclient," + "ms_last_year as ms_last_year_nonclient," + "lit_this_year as lit_this_year_nonclient," + "lit_last_year as lit_last_year_nonclient," + "mpr_this_year as mpr_this_year_nonclient," + "mpr_last_year as mpr_last_year_nonclient," + "all_this_year as all_this_year_nonclient," + "all_last_year as all_last_year_nonclient " + "from angelod2" + ";select CONVERT(VARCHAR(10), wk_nm, 103) as wk_nm," + "ms_this_year as ms_this_year_all," + "ms_last_year as ms_last_year_all," + "lit_this_year as lit_this_year_all," + "lit_last_year as lit_last_year_all," + "mpr_this_year as mpr_this_year_all," + "mpr_last_year as mpr_last_year_all," + "all_this_year as all_this_year_all," + "all_last_year as all_last_year_all " + "from angelod3"; DataSet oData = GetData(query); return oData;