In SUSI.AI skill ratings is an invaluable aspect which greatly helps the users to know which skills are performing better than the rest and are more popular than the others. A robust skill rating system for the skills was developed recently which allows the users to rate skills as per their experience and thus data like average rating, total number of ratings is available but there was no provision to see the rating history or how the skills rating has changed over time, this could be an important aspect for users or developers to know what changes to the skill made it less/more popular. An API is developed at the server to retrieve the ratings over time data, we can use these details to render attractive components for a better visual understanding of how the skill is performing and get statistics like how the skill’s rating has changed over time.
About the API
Endpoint : /cms/getRatingsOverTime.json
After consuming these params the API will return the number of times a skill is called along with
the date on which it is called. We use that data as an input for the line chart component that we want to render.
Fetching data from the server and storing in the application state
Make an AJAX call to the server to fetch the data from the URL which holds the server endpoint, on successfully receiving the data we do some formatting with the timestamp that comes along the data to make it more convenient to understand and then we call a saveRatingOverTime function which saves the data received from the server to the application state.
Save the skill usage details in the component state.
Send the received data as props to the Skill Rating component and render it.
Implementing the UI
Importing the packages for rendering the chart in the Skill Ratings component.
Display a small heading for the section in the ratings card and Render a Responsive container component which will form a parent component for out Chart which will be rendered when the ratings over time data received in the props is not empty.
Render a LineChart and supply data from the data prop received from the Skill Listing component, add X-Axis and Y-Axis by supplying corresponding dataKey props depending on the data received, Add a tooltip to describe points on the line chart and a legend which describes the lines, After that we have a Line component which depicts the change in ratings over time on the chart.
So I hope after going through this blog it is more clear how the ratings over time section is implemented in the Skill CMS.
- Line Chart component API documentation – http://recharts.org/en-US/api/LineChart.
- Blog on Re-designed charts for react – https://medium.com/@arcthur/re-designed-chart-for-react-fbb31cf78415