تخصيص الرسوم البيانية
إنشاء الرسوم البيانية المخصصة
حتى الآن ، عندما ناقشنا المخططات ، نظرنا إلى المخططات القياسية التي تحتوي على إعدادات التنسيق القياسية الخاصة بها. نحن نحدد مصدر البيانات فقط ، ونعين بعض الخصائص ، ويتم إنشاء المخطط باستخدام إعدادات التنسيق الافتراضية الخاصة به. لكن Aspose.Cells APIs تدعم أيضًا إنشاء مخططات مخصصة تسمح للمطورين بإنشاء مخططات باستخدام إعدادات التنسيق الخاصة بهم.
يمكن للمطورين إنشاء مخططات مخصصة في وقت التشغيل باستخدام Aspose.Cells.
يتكون المخطط من سلسلة بيانات. يتم تمثيل كل سلسلة بيانات في Aspose.Cells بواسطة أمسلسل كائن في حينالسلسلة الكائن بمثابة مجموعة منمسلسلأشياء. عند إنشاء مخطط مخصص ، يتمتع المطورون بحرية استخدام أنواع مختلفة من المخططات لسلسلة بيانات مختلفة (مجمعة في ملفالسلسلةموضوع).
يوضح رمز المثال أدناه كيفية إنشاء مخططات مخصصة. في هذا المثال ، سنستخدم مخططًا عموديًا لسلسلة البيانات الأولى ومخطط خطي للسلسلة الثانية. والنتيجة هي أننا نضيف مخططًا عموديًا ، جنبًا إلى جنب مع مخطط خطي ، إلى ورقة العمل.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Adding a new worksheet to the Workbook object | |
int sheetIndex = workbook.Worksheets.Add(); | |
// Obtaining the reference of the newly added worksheet by passing its sheet index | |
Worksheet worksheet = workbook.Worksheets[sheetIndex]; | |
// Adding sample values to cells | |
worksheet.Cells["A1"].PutValue(50); | |
worksheet.Cells["A2"].PutValue(100); | |
worksheet.Cells["A3"].PutValue(150); | |
worksheet.Cells["A4"].PutValue(110); | |
worksheet.Cells["B1"].PutValue(260); | |
worksheet.Cells["B2"].PutValue(12); | |
worksheet.Cells["B3"].PutValue(50); | |
worksheet.Cells["B4"].PutValue(100); | |
// Adding a chart to the worksheet | |
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5); | |
// Accessing the instance of the newly added chart | |
Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex]; | |
// Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4" | |
chart.NSeries.Add("A1:B4", true); | |
// Setting the chart type of 2nd NSeries to display as line chart | |
chart.NSeries[1].Type = Aspose.Cells.Charts.ChartType.Line; | |
// Saving the Excel file | |
workbook.Save(dataDir + "output.xls"); |
يدعم Aspose.Cells حاليًا المخططات المخصصة فقط التي تجمع المخططات الدائرية والخطية والعمودية والمكدسة العمودية ولكن سيتم دعم المزيد من المخططات في الإصدارات المستقبلية.