diff options
author | srichman333 <sarah_n_richman@brown.edu> | 2023-07-12 23:48:46 -0400 |
---|---|---|
committer | srichman333 <sarah_n_richman@brown.edu> | 2023-07-12 23:48:46 -0400 |
commit | e1e74c5e35c5eafa6b4fadc4df2173ba09e235ec (patch) | |
tree | 0c3ec933cc47d478a6634e94fbab0a52be92626e /src | |
parent | aa7642006598bd47b415d4d2452dd4d226ab3ac5 (diff) |
pie chart axis labels
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/DataVizBox/components/PieChart.tsx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/client/views/nodes/DataVizBox/components/PieChart.tsx b/src/client/views/nodes/DataVizBox/components/PieChart.tsx index 3ca49a46c..8f7fadfa5 100644 --- a/src/client/views/nodes/DataVizBox/components/PieChart.tsx +++ b/src/client/views/nodes/DataVizBox/components/PieChart.tsx @@ -228,7 +228,7 @@ export class PieChart extends React.Component<PieChartProps> { }) var field = Object.keys(dataSet[0])[0] const data = validData.map((d: { [x: string]: any; }) => { - if (this.numericalData) { return +d[field].replace(/\$/g, '').replace(/\%/g, '') } + if (this.numericalData) { return +d[field].replace(/\$/g, '').replace(/\%/g, '').replace(/\</g, '') } return d[field] }) return data; @@ -259,7 +259,7 @@ export class PieChart extends React.Component<PieChartProps> { //Generate groups var percentField = Object.keys(dataSet[0])[0] - var descriptionField = Object.keys(dataSet[0])[1] + var descriptionField = Object.keys(dataSet[0])[1]! var arcs = g.selectAll("arc") .data(pie(data)) .enter() @@ -273,12 +273,14 @@ export class PieChart extends React.Component<PieChartProps> { arcs.append("text") .attr("transform",function(d){ return "translate("+ (arc.centroid(d as unknown as d3.DefaultArcObject)) + ")"; }) .attr("text-anchor", "middle") - .text(function(d){ return dataSet[data.indexOf(d.value)][percentField] + ' ' + dataSet[data.indexOf(d.value)][descriptionField]}) + .text(function(d){ + return dataSet[data.indexOf(d.value)][percentField] + + (!descriptionField? '' : (' ' + dataSet[data.indexOf(d.value)][descriptionField]))}) }; render() { - + return ( this.props.axes.length >= 1 && (this.incomingSelected? this.incomingSelected.length>0 : true) ? ( <div ref={this._piechartRef} className="chart-container"> |