Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
ultradatachar + ultralegend
posted

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

Parents
  • 21795
    Offline posted

    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.

Reply Children