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

Feature/add configurable graph domain #136

Merged
merged 18 commits into from
Nov 23, 2020

Conversation

adieyal
Copy link
Contributor

@adieyal adieyal commented Nov 17, 2020

Description

Refactored chart.js and enabled more detailed configuration

Related Issue

N/A

How to test it locally

set the chart configuration on a chart to something like this
{
types: {
Value: {formatting: '~s', minX: 0, maxX: 100},
Percentage: {formatting: '.0%'}
}
}

the percentage chart should now range between 0 and 100

Screenshots

Changelog

Added

Updated

Refactoring and added configuration

Removed

Checklist

  • 🚀 is the code ready to be merged and go live?
  • 🛠 does it work (build) locally

Pull Request

  • 📰 good title
  • 📝good description
  • 🔖 issue linked
  • 📖 changelog filled out

Commits

  • commits are clean
  • commit messages are clean

Code Quality

  • 🚧 no commented out code
  • 🖨 no unnecessary logging
  • 🎱 no magic numbers
  • ⚙️ ran jslint
  • 🧰 ran codeclimate locally

Testing

  • ✅ added (appropriate) unit tests
  • 💢 edge cases in tests were considered
  • ✅ ran tests locally & are passing

No tests written because of testing complication

Adi Eyal and others added 15 commits November 17, 2020 09:58
Can now specify the minX and maxX values
previously the expectation was that all keys were present if a custom config was provided via the api
Some cleanup of chart.js. Removed some if statement that checked for percentage or value - this is now driven from the config. Also added the ability to set the domain of the axis. This allows users to for instance for the percentage graphs to range between 0 and 100
Copy link
Contributor

@milafrerichs milafrerichs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few small things

}
const indicators = detail.indicators;

let c = new Chart(config, this.subindicators, this.groups, indicators, 'Percentage', indicator, title);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of creating the variable indicators in line 47, you could just use it here

let c = new Chart(config, this.subindicators, this.groups, detail.indicators, 'Percentage', indicator, title);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detail needs to be refactored out of this class entirely

Base automatically changed from chore/added-utility-function to staging November 20, 2020 06:55
…dash

Lodash has a better deep merge function which deals with cases that the existing code didn't.
const indicators = {
'Age by race': {
'groups': {
'gender': {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

'Female': {'subindicator1': {'count': 10}, 'subindicator2': {'count': 20}},
'Male': {'subindicator1': {'count': 30}, 'subindicator2': {'count': 40}},
},
'race': {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

expect(chartData[1].value).toBe(expected.subindicator2.count);
})

test('Handles missing group correctly', () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

expect(chartData.length).toBe(0)
})

test('Handles missing subindicator correctly', () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

@netlify
Copy link

netlify bot commented Nov 20, 2020

Deploy preview for wazimap-staging ready!

Built with commit c478e8d

https://deploy-preview-136--wazimap-staging.netlify.app

@@ -1,3 +1,4 @@
import {merge} from 'lodash';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to point you to lodash, but I thought you might have considered it already :)

@@ -156,6 +156,25 @@ export class SubindicatorFilter extends Observable {
})
}

getFilteredGroups(groups, selectedGroup, selectedFilter) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

@milafrerichs milafrerichs merged commit 471df61 into staging Nov 23, 2020
@adieyal adieyal deleted the feature/add-configurable-graph-domain branch November 28, 2020 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants