Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Pie chart title #57

Merged
merged 2 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions python/adminui/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ class PieChart(Element):
Args:
data: the data shown on the chart.
e.g. an array like [2, 3, 4, 5]
lables: labels corresponding to the data. Must be to the same length of the data
labels: labels corresponding to the data. Must be to the same length of the data
e.g. ['a', 'b', 'c', 'd']
height: the height of the chart
title: the title of the chart
"""
def __init__(self, data=[], labels=None, height=300, color=None, id=None):
super().__init__('PieChart', data=data, labels=labels, style={'height': height, 'color': color}, id=id)
def __init__(self, data=[], labels=None, height=300, color=None, title=None, id=None):
super().__init__('PieChart', data=data, labels=labels, style={'height': height, 'color': color, 'title': title}, id=id)

class ScatterPlot(Element):
"""Create a bar chart
Expand Down
19 changes: 18 additions & 1 deletion src/pages/pageParts/components/Charts/pieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@ export interface PieChartProps {
height?: number;
}

const styles ={
mainTitle:{
fontSize:20,
color:"black",
margin: "auto",
"padding-left": 52,
"padding-bottom": 20,
"box-sizing": "border-box"
}
}

export interface PieChartStyle {
height: number;
columns?: string[];
title: string;
}


Expand All @@ -34,6 +46,11 @@ const PieChart: React.FC<PieChartProps> = props => {
forceFit
height={chartStyle.height}
>
<h3 className='main-title' style={styles.mainTitle}>
<center>
{chartStyle.title}
</center>
</h3>
<Coord type="theta"/>
<Tooltip showTitle={false} />
<Geom
Expand All @@ -48,4 +65,4 @@ const PieChart: React.FC<PieChartProps> = props => {

}

export default autoHeight()(PieChart);
export default autoHeight()(PieChart);