Skip to content

Commit

Permalink
version 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisal-D committed Dec 25, 2024
1 parent 278d6b6 commit 8601e18
Show file tree
Hide file tree
Showing 8 changed files with 614 additions and 33 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

[![Downloads](https://static.pepy.tech/badge/tkchart)](https://pepy.tech/project/tkchart) [![Downloads](https://static.pepy.tech/badge/tkchart/month)](https://pepy.tech/project/tkchart) [![Downloads](https://static.pepy.tech/badge/tkchart/week)](https://pepy.tech/project/tkchart)

<img src="https://drive.google.com/thumbnail?id=1asMd-U3BmmVEl8YpdRssj679n6jRdflC&sz=w180">
<img src="https://drive.google.com/thumbnail?id=1jOltT5qBvLmKAdSU6zb9wjh3GYa6jRvD&sz=w180">

</div>

Expand Down Expand Up @@ -150,7 +150,6 @@ linechart = tkchart.LineChart()
| hide | hide a specific line | line: ``tkchart.Line``<br> state: ``bool`` |
| reset | reset line chart | - |
| cget | Get the value of the specified parameter. | attribute_name: ``str`` \| "\_\_all\_\_" |
|apply_line_changes | Applying changes made to a Line objects. | -
</div>
Expand Down Expand Up @@ -191,6 +190,7 @@ line = tkchart.Line()
|-------------------|----------------------------------------------------|------------------------------------------|
| configure | Change LineChart attributes | All attributes except for master |
| cget | Get the value of the specified parameter. | attribute_name: ``str`` \| "\_\_all\_\_" |
| reset | reset line object | - |
</div>
<br>
Expand Down
15 changes: 8 additions & 7 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

[![Downloads](https://static.pepy.tech/badge/tkchart)](https://pepy.tech/project/tkchart) [![Downloads](https://static.pepy.tech/badge/tkchart/month)](https://pepy.tech/project/tkchart) [![Downloads](https://static.pepy.tech/badge/tkchart/week)](https://pepy.tech/project/tkchart)

<img src="https://drive.google.com/thumbnail?id=1asMd-U3BmmVEl8YpdRssj679n6jRdflC&sz=w180">
<img src="https://drive.google.com/thumbnail?id=1jOltT5qBvLmKAdSU6zb9wjh3GYa6jRvD&sz=w180">

</div>

Expand Down Expand Up @@ -145,8 +145,7 @@ linechart = tkchart.LineChart()
| hide_all | 隐藏所有折线 | state: ``bool`` |
| hide | 隐藏特定折线 | line: ``tkchart.Line``<br> state: ``bool`` |
| reset | 重置折线图 | - |
| cget | 获取指定参数的值。 | attribute_name: ``str`` \| "\_\_全部\_\_" |
| apply_line_changes | 应用对 Line 对象所做的更改。 | - |
| cget | 获取指定参数的值。 | attribute_name: ``str`` \| "\_\_all\_\_" |
</div>
Expand All @@ -166,11 +165,11 @@ line = tkchart.Line()
## 参数
| 参数名称 | 必备参数 / 可选参数 | 描述 | 数据类型 | 示例值 |
| ---------------------------------------------------- | ------------------- | ---------------------------- | ---------------------------------- | ------------- |
| master | 必须 | Master | ``tkchart.Line`` | LineChart obj |
| ---------------------------------------------------- | ------------------- | ---------------------------|---------------------------------- | ------------- |
| master | 必须 | Master | ``tkchart.Line`` | LineChart obj |
| <a href="#line_color_size">color</a> | 可选 | 折线的颜色 | ``str`` | "#768df1" |
| <a href="#line_color_size">size</a> | 可选 | Size of the line | ``int`` | 1<= |
| <a href="#line_style">style</a> | 可选 | 折线风格(直线、虚线、点线) | ``str`` ("normal", "dashed", "dotted") | "normal" |
| <a href="#line_color_size">size</a> | 可选 | Size of the line | ``int`` | 1<= |
| <a href="#line_style">style</a> | 可选 | 折线风格(直线、虚线、点线) | ``str`` ("normal", "dashed", "dotted") | "normal" |
| <a href="#line_style_type">style_type</a> | 可选 | 实线与虚线的尺寸 | ``tuple[int, int]`` | (10, 5),... |
| <a href="#point_highlight">point_highlight</a> | 可选 | 端点高亮状态 | ``str`` ("enabled", "disabled") | "disabled" |
| <a href="#point_highlight">point_highlight_size</a> | 可选 | 高亮点的大小 | ``int`` | 1<= |
Expand All @@ -186,6 +185,8 @@ line = tkchart.Line()
| --------- | ---------------- | ---------------------------------------- |
| configure | 更改折线图属性 | 所有属性,除了 master |
| cget | 获取指定参数的值 | attribute_name: ``str`` \| "\_\_all\_\_" |
|reset | 重置线对象 | - |
</div>
<br>
Expand Down
72 changes: 68 additions & 4 deletions src/tkchart/Line.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ def __init__(self,
fill_color: str = "#5d6db6",
*args: any
) -> None:
"""
Initialize a Line object.
Args:
master (LineChart): The master object.
color (str): The color of the line.
size (int): The size/thickness of the line.
style (str): The style of the line (e.g., 'normal', 'dashed', 'dotted').
style_type (Tuple[int, int]): The style type for dashed or dotted lines.
point_highlight (str): Whether point highlighting is enabled or disabled.
point_highlight_size (int): The size of points used for highlighting.
point_highlight_color (str): The color of points used for highlighting.
fill (str): Whether fill for the line is enabled or disabled.
fill_color (str): The color of the fill for the line.
"""

if master == None:
if len(args) != 0:
Expand Down Expand Up @@ -64,51 +79,99 @@ def configure(self,
fill: str = None,
fill_color:str = None,
) -> None:
"""
Configure attributes of the Line object.
Args:
color (str): The color of the line.
size (int): The size/thickness of the line.
style (str): The style of the line (e.g., 'normal', 'dashed', 'dotted').
style_type (Tuple[int, int]): The style type for dashed or dotted lines.
point_highlight (str): Whether point highlighting is enabled or disabled.
point_highlight_size (int): The size of points used for highlighting.
point_highlight_color (str): The color of points used for highlighting.
fill (str): Whether fill for the line is enabled or disabled.
fill_color (str): The color of the fill for the line.
"""
changes_req = False

if color != None:
Validate._isValidColor(color, "color")
self.__color = color
changes_req = True

if size != None:
Validate._isInt(size, "size")
self.__size = size
changes_req = True

if style != None:
Validate._isValidLineStyle(style, "style")
self.__style = style
changes_req = True

if style_type != None:
Validate._isValidStyleType(style_type, "style_type")
self.__style_type = style_type
changes_req = True

if point_highlight != None:
Validate._isValidLineHighlight(point_highlight, "point_highlight")
self.__point_highlight = point_highlight
changes_req = True

if point_highlight_size != None:
Validate._isInt(point_highlight_size, "point_highlight_size")
self.__point_highlight_size = point_highlight_size

changes_req = True

if point_highlight_color != None:
Validate._isValidColor(point_highlight_color, "point_highlight_color")
self.__point_highlight_color = point_highlight_color
changes_req = True

if fill != None:
Validate._isValidLineFill(fill, "fill")
self.__fill = fill
changes_req = True

if fill_color != None:
Validate._isValidColor(fill_color, "fill_color")
self.__fill_color = fill_color

changes_req = True

if changes_req:
self.__master._LineChart__apply_line_configuration()


def __reset(self) -> None:
"""
Reset the Line object.
"""
self.__y_end = 0
self.__x_end = self.__master._LineChart__x_axis_point_spacing* -1
self.__data = []



def reset(self) -> None:
"""
Reset the line.
"""
self.__reset()
self.__master._LineChart__call_reshow_data()


def cget(self, attribute_name: str) -> any:
"""
Get the value of a Line attribute.
Args:
attribute_name (str): Name of the attribute.
Returns:
any: Value of the attribute.
"""

if attribute_name == "master": return self.__master
if attribute_name == "color": return self.__color
if attribute_name == "size": return self.__size
Expand All @@ -132,4 +195,5 @@ def cget(self, attribute_name: str) -> any:
"point_highlight_color" : self.__point_highlight_color,
"fill" : self.__fill,
"fill_color" : self.__fill_color
}
}
Validate._invalidCget(attribute_name)
Loading

0 comments on commit 8601e18

Please sign in to comment.