Chart
aspose-cells-foss worksheets में charts एम्बेड करने का समर्थन करता है। charts को के माध्यम से प्रबंधित किया जाता है ws.charts, एक ChartCollection प्रत्येक से जुड़ा हुआ Worksheet. Series data को के माध्यम से जोड़ा जाता है chart.n_series, एक NSeries collection।.
Example: aspose.cells_foss
from aspose.cells_foss import ChartTypeChartType
ChartType एक है IntEnum जो chart type को पहचानता है।.
| Name | Type | Access | Description |
|---|---|---|---|
type | `` | Read | Gets the type. |
title | `` | Read/Write | Gets or sets the title. |
category_data | `` | Read/Write | Gets or sets the category data. |
show_legend | `` | Read/Write | Gets or sets the show legend. |
legend_position | `` | Read/Write | Gets or sets the legend position. |
smooth | `` | Read/Write | Gets or sets the smooth. |
n_series | `` | Read | Gets the n series. |
NSeries | `` | Read | PascalCase alias of n_series. |
grouping | `` | Read/Write | Gets or sets the grouping. |
bar_direction | `` | Read/Write | Gets or sets the bar direction. |
gap_width | `` | Read/Write | Gets or sets the gap width. |
overlap | `` | Read/Write | Gets or sets the overlap. |
vary_colors | `` | Read/Write | Gets or sets the vary colors. |
first_slice_angle | `` | Read/Write | Gets or sets the first slice angle. |
is_of_pie | `` | Read/Write | Gets or sets the is of pie. |
of_pie_type | `` | Read/Write | Gets or sets the of pie type. |
second_pie_size | `` | Read/Write | Gets or sets the second pie size. |
quartile_method | `` | Read/Write | Gets or sets the quartile method. |
box_show_mean_line | `` | Read/Write | Gets or sets the box show mean line. |
box_show_mean_marker | `` | Read/Write | Gets or sets the box show mean marker. |
box_show_inner_points | `` | Read/Write | Gets or sets the box show inner points. |
box_show_outlier_points | `` | Read/Write | Gets or sets the box show outlier points. |
box_gap_width | `` | Read/Write | Gets or sets the box gap width. |
is_3d | `` | Read/Write | Gets or sets the is 3d. |
gap_depth | `` | Read/Write | Gets or sets the gap depth. |
view_3d | `` | Read | Gets the view 3d. |
View3D | `` | Read | PascalCase alias of view_3d. |
show_connector_lines | `` | Read/Write | Gets or sets the show connector lines. |
has_subtotals | `` | Read/Write | Gets or sets the has subtotals. |
sub_charts | `` | Read | List of sub-chart descriptors for combo charts. |
axes | `` | Read | List of ChartAxis objects defining all axes for the chart. |
scatter_style | `` | Read/Write | Gets or sets the scatter style. |
wireframe | `` | Read/Write | Whether the surface chart uses wireframe display mode (<c:wireframe val=‘1’/>). |
radar_style | `` | Read/Write | Radar chart style: ‘standard’, ‘marker’, or ‘filled’. |
histogram_bin_count | `` | Read/Write | Number of bins for count-based binning (int or None for auto/size-based). |
histogram_bin_size | `` | Read/Write | Bin width for size-based binning (float or None for auto/count-based). |
histogram_interval_closed | `` | Read/Write | Which side of each bin interval is closed: ‘r’ (right) or ’l’ (left). |
histogram_overflow | `` | Read/Write | Overflow bin boundary value (float or None). |
histogram_underflow | `` | Read/Write | Underflow bin boundary value (float or None). |
disp_blanks_as | `` | Read/Write | Gets or sets the disp blanks as. |
stock_style | `` | Read/Write | Gets or sets the stock style. |
Example
Chart ऑब्जेक्ट्स को सीधे निर्मित नहीं किया जाता है। उपयोग करें ws.charts.add(...) या टाइप्ड सुविधा विधियों (add_bar(), add_line(), add_pie(), add_area()).
Example
| Signature | Description |
|---|---|
__init__(chart_type, upper_left_row, upper_left_column, lower_right_row, lower_right_column) | |
add_series(values, category_data, name, chart_type, x_values) | Convenience method to add a series. |
add_axis(axis_type, axis_id) | Adds an axis to the chart and returns it. |
copy() | Creates and returns a duplicate of the chart |
ChartCollection
ChartCollection को इस रूप में पहुँचाया जाता है ws.charts. इसमें वर्कशीट में एम्बेड किए गए सभी चार्ट शामिल हैं।.
Example
add
ws.charts.add(
chart_type: ChartType,
upper_left_row: int,
upper_left_column: int,
lower_right_row: int,
lower_right_column: int
) -> Chartनिर्दिष्ट प्रकार का चार्ट जोड़ता है। सभी पोजीशन आर्ग्यूमेंट्स 0-आधारित पंक्ति/कॉलम इंडेक्स होते हैं।.
add_bar
ws.charts.add_bar(upper_left_row, upper_left_column, lower_right_row, lower_right_column) -> Chartके लिए शॉर्टकट for add(ChartType.BAR, ...).
add_line
ws.charts.add_line(upper_left_row, upper_left_column, lower_right_row, lower_right_column) -> Chartके लिए शॉर्टकट add(ChartType.LINE, ...).
add_pie
ws.charts.add_pie(upper_left_row, upper_left_column, lower_right_row, lower_right_column) -> Chartके लिए शॉर्टकट add(ChartType.PIE, ...).
add_area
ws.charts.add_area(upper_left_row, upper_left_column, lower_right_row, lower_right_column) -> Chartके लिए शॉर्टकट add(ChartType.AREA, ...).
गुणधर्म और पुनरावृत्ति
NSeries
NSeries के माध्यम से पहुँचा जाता है chart.n_series. यह एक चार्ट से संबंधित डेटा सीरीज़ को प्रबंधित करता है।.
Example
add
chart.n_series.add(
area: str,
is_vertical: bool = False,
category_data: str | None = None,
name: str | None = None,
chart_type: ChartType | None = None
) -> ChartSeriesएक डेटा सीरीज़ जोड़ता है।. area एक रेंज स्ट्रिंग है जैसे "Sheet1!B1:B5". सेट is_vertical=True जब डेटा कॉलम में व्यवस्थित हो।. chart_type इस सीरीज़ के लिए पैरेंट चार्ट प्रकार को ओवरराइड करता है (कॉम्बो चार्ट में उपयोग किया जाता है)।.
गुणधर्म और पुनरावृत्ति
ChartSeries
ChartSeries एक चार्ट के भीतर एकल डेटा श्रृंखला का प्रतिनिधित्व करता है। प्राप्त किया जाता है के द्वारा chart.n_series[index].
Example
Example
add_error_bars
series.add_error_bars(
direction='y',
bar_type='both',
val_type='fixedVal',
val=1.0,
no_end_cap=False
) -> ChartErrorBarsइस श्रृंखला में एरर बार जोड़ता है और लौटाता है ChartErrorBars ऑब्जेक्ट।.
ChartAxis
ChartAxis तक पहुँचाया जाता है chart.axes[index].
Example
ChartView3D
ChartView3D के माध्यम से पहुँचा जाता है chart.view_3d. केवल तब लागू होता है जब chart.is_3d है True.
Example
ChartErrorBars
ChartErrorBars के माध्यम से पहुँचता है series.error_bars. के साथ बनाएं series.add_error_bars(...).
Example
Example
निम्नलिखित उदाहरण मासिक राजस्व डेटा लिखता है, शीर्षक और दो डेटा श्रृंखलाओं के साथ एक क्लस्टर्ड बार चार्ट बनाता है, और वर्कबुक को सहेजता है।.
from aspose.cells_foss import Workbook, ChartType
wb = Workbook()
ws = wb.worksheets[0]
ws.name = "Revenue"
# Write headers and data
headers = ["Month", "Product A", "Product B"]
data = [
["Jan", 12000, 9500],
["Feb", 14500, 11000],
["Mar", 13200, 12800],
["Apr", 15800, 14100],
]
for col, h in enumerate(headers):
ws.cells[0][col].put_value(h)
for row, row_data in enumerate(data, start=1):
for col, val in enumerate(row_data):
ws.cells[row][col].put_value(val)
# Add a bar chart covering rows 6-20, columns 0-6
chart = ws.charts.add_bar(6, 0, 20, 6)
chart.title = "Monthly Revenue by Product"
chart.bar_direction = "col" # vertical (column chart)
chart.grouping = "clustered"
# Series: Product A and Product B
chart.n_series.add("Revenue!B2:B5", is_vertical=True, category_data="Revenue!A2:A5", name="Product A")
chart.n_series.add("Revenue!C2:C5", is_vertical=True, category_data="Revenue!A2:A5", name="Product B")
chart.show_legend = True
chart.legend_position = "bottom"
wb.save("revenue_chart.xlsx")