From 3932f197e004b292e228aa532741d4777ed27411 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Mon, 31 Jul 2023 18:33:02 +0530 Subject: [PATCH] add percentage --- src/components/AbsorbanceGraph.js | 1 + src/components/TestAnalytics.css | 12 +++++++++++- src/components/TestAnalyticsPie.js | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/AbsorbanceGraph.js b/src/components/AbsorbanceGraph.js index 9c7488e..27a3820 100644 --- a/src/components/AbsorbanceGraph.js +++ b/src/components/AbsorbanceGraph.js @@ -11,6 +11,7 @@ class AbsorbanceGraph extends Component { super(props); this.state = { url: this.props.url, show: this.props.show }; } + componentDidMount() { this.drawChart(this.state.url); } diff --git a/src/components/TestAnalytics.css b/src/components/TestAnalytics.css index 378174a..02fd9a8 100644 --- a/src/components/TestAnalytics.css +++ b/src/components/TestAnalytics.css @@ -1,7 +1,17 @@ .container { display: flex; - flex-direction: row; + flex-direction: column; align-items: center; justify-content: center; height: 50vh; +} + +@media screen and (min-width: 900px) { + .container { + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; + height: 50vh; + } } \ No newline at end of file diff --git a/src/components/TestAnalyticsPie.js b/src/components/TestAnalyticsPie.js index 33504dc..0f05e59 100644 --- a/src/components/TestAnalyticsPie.js +++ b/src/components/TestAnalyticsPie.js @@ -65,7 +65,7 @@ class TestAnalyticsPie extends Component { .attr("d", path) .attr("fill", function (d) { return color(d.data.category); }) .on('mouseover', (event, d) => { - tooltip.text(`${d.data.category}: ${d.data.count}`); + tooltip.text(`${d.data.category}: ${d.data.count}, ${100 * d.data.count/data.reduce((a, c) => a + c.count, 0)}%`); return tooltip .style("visibility", "visible") .style("font-size", "0.75em")