كيفية إنشاء رسم بياني مختلط
سيناريوهات الاستخدام المحتملة
تتيح لك رسوم الكومبو في Excel الاستفادة من هذا الخيار لأنك يمكنك دمج نوعين أو أكثر من أنواع الرسوم البيانية بسهولة لجعل بياناتك مفهومة. تكون رسوم الكومبو مفيدة عندما تحتوي بياناتك على أنواع متعددة من القيم بما في ذلك السعر والحجم. علاوة على ذلك، تكون رسوم الكومبو ممكنة عندما تتغير أرقام بياناتك بشكل واسع من سلسلة إلى سلسلة. من خلال اعتبار مجموعة البيانات التالية كمثال، يمكننا ملاحظة أن هذه البيانات مشابهة تمامًا للبيانات المذكورة في VHCL. إذا كنا نريد تصوير series0، والتي تتوافق مع “إجمالي الإيرادات”، كرسم بياني خطي، فكيف يجب أن نقدم؟
رسم بياني مختلط
بعد تشغيل الرمز أدناه، سترون الرسم البياني المختلط كما هو موضح أدناه.
الكود المثالي
يقوم الرمز العيني التالي بتحميل [ملف Excel العيني] التالي(combo.xlsx) وإنتاج [ملف Excel الإخراج المعني] التالي(out.xlsx).
// Create the workbook | |
Workbook workbook = new Workbook("combo.xlsx"); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Add a stock vloume(VHLC) | |
int pieIdx = worksheet.Charts.Add(ChartType.StockVolumeHighLowClose, 15, 0, 34, 12); | |
// Retrieve the Chart object | |
Chart chart = worksheet.Charts[pieIdx]; | |
// Set the legend can be showed | |
chart.ShowLegend = true; | |
// Set the chart title name | |
chart.Title.Text = "Combo Chart"; | |
// Set the Legend at the bottom of the chart area | |
chart.Legend.Position = LegendPositionType.Bottom; | |
// Set data range | |
chart.SetChartDataRange("A1:E12", true); | |
// Set category data | |
chart.NSeries.CategoryData = "A2:A12"; | |
// Set the Series[1] Series[2] and Series[3] to different Marker Style | |
for (int j = 0; j < chart.NSeries.Count; j++) | |
{ | |
switch (j) | |
{ | |
case 1: | |
chart.NSeries[j].Marker.MarkerStyle = ChartMarkerType.Circle; | |
chart.NSeries[j].Marker.MarkerSize = 15; | |
chart.NSeries[j].Marker.Area.Formatting = FormattingType.Custom; | |
chart.NSeries[j].Marker.Area.ForegroundColor = Color.Pink; | |
chart.NSeries[j].Border.IsVisible = false; | |
break; | |
case 2: | |
chart.NSeries[j].Marker.MarkerStyle = ChartMarkerType.Dash; | |
chart.NSeries[j].Marker.MarkerSize = 15; | |
chart.NSeries[j].Marker.Area.Formatting = FormattingType.Custom; | |
chart.NSeries[j].Marker.Area.ForegroundColor = Color.Orange; | |
chart.NSeries[j].Border.IsVisible = false; | |
break; | |
case 3: | |
chart.NSeries[j].Marker.MarkerStyle = ChartMarkerType.Square; | |
chart.NSeries[j].Marker.MarkerSize = 15; | |
chart.NSeries[j].Marker.Area.Formatting = FormattingType.Custom; | |
chart.NSeries[j].Marker.Area.ForegroundColor = Color.LightBlue; | |
chart.NSeries[j].Border.IsVisible = false; | |
break; | |
} | |
} | |
// Set the chart type for Series[0] | |
chart.NSeries[0].Type = ChartType.Line; | |
// Set style for the border of first series | |
chart.NSeries[0].Border.Style = LineType.Solid; | |
// Set Color for the first series | |
chart.NSeries[0].Border.Color = Color.DarkBlue; | |
// Fill the PlotArea area with nothing | |
chart.PlotArea.Area.Formatting = FormattingType.None; | |
// Save the Excel file | |
workbook.Save("out.xlsx"); |