Function
Static Public Summary | ||
public |
Add a goal to the store. |
|
public |
Add all goals to the store. |
|
public |
addIndicator(indicator: Object): Object Add an indicator to the store |
|
public |
addLnobAssessment(params: Object): Object Add the spillover assessment to the store |
|
public |
addLnobDimension(params: Object): Object Add a LNOB to the store. |
|
public |
addLnobDimensions(options: Object): Object[] Add all lnobs to the store. |
|
public |
addObservation(observation: Object): Object Add an observation to the store |
|
public |
addOverallAssessment(params: Object): Object Add the overall assessment to the store |
|
public |
Add a region to the store |
|
public |
addSpilloverAssessment(params: Object): Object Add the spillover assessment to the store |
|
public |
addTimeseries(timeseries: Object): Object Add timeseries to the store. |
|
public |
convertScoreToColor(colorScore: number): string Convert score to rating color. |
|
public |
excelToJson(param: Object): Array Convert a sheet in an Excel file into JSON format. |
|
public |
findAssessmentById(id: String): Object Find an assessment by its ID. |
|
public |
findAssessmentBySlug(slug: String): Object Find an assessment by its slug. |
|
public |
findAssessmentForRegionById(region: Object, assessmentId: string): Object Find a specific assessment by ID and include the observation for the given region. |
|
public |
findGoalForRegionById(region: Object, goalId: string): Object Find a specific goal by assessment ID and include the observation for the given region. |
|
public |
findIndicatorById(id: String): Object Find an indicator by its ID. |
|
public |
findIndicatorBySlug(slug: String): Object Find an indicator by its slug. |
|
public |
findIndicatorForRegionById(region: Object, indicatorId: string): Object Find a specific indicator by ID and include the observation for the given region. |
|
public |
findIndicatorForRegionBySlug(region: Object, indicatorSlug: string): Object Find a specific indicator by slug and include the observation for the given region. |
|
public |
Get the leave-no-one-behind assessment. |
|
public |
findLnobAssessmentForRegion(region: Object): Object Get the leave-no-one-behind assessment, including the observation for the given region. |
|
public |
findObservationByRegionAndAssessment(region: Object, assessment: Object): Object Find the observation for the given region and assessment. |
|
public |
Get the overall SDG Index assessment. |
|
public |
findOverallAssessmentForRegion(region: Object): Object Get the overall SDG Index assessment, including the observation for the given region. |
|
public |
findRegionById(id: String): Object Find a region by its ID. |
|
public |
findRegionBySlug(slug: String): Object Find a region by its slug. |
|
public |
findRegionWithAssessmentById(assessment: Object, regionId: string): Object Find a specific region by ID and include the observation for the given assessment. |
|
public |
Get the spillover index assessment. |
|
public |
findSpilloverAssessmentForRegion(region: Object): Object Get the spillover index assessment, including the observation for the given region. |
|
public |
findTimeseriesByRegionAndAssessment(region: Object, assessment: Object): Array Find the timeseries for a specific region and assessment. |
|
public |
findTimeseriesByRegionAndIndicator(region: Object, indicator: Object): Array Find the timeseries for a specific region and indicator. |
|
public |
Get all assessments from the store. |
|
public |
Get the color for an SDG with the given number. |
|
public |
getFirstYear(timeseries: Object): number Get the first year where the timeseries has a non-null value. |
|
public |
Get all goal assessments from the store. |
|
public |
getGoalsForRegion(region: Object): Array Get all goal assessments from the store, each including the respective observation for the given region. |
|
public |
getIndicatorUnit(label: string): string | null Extract the unit from an indicator label. |
|
public |
Get all indicators from the store. |
|
public |
getIndicatorsByGoal(goal: Object): Array Get all indicators for the given goal from the store. |
|
public |
getIndicatorsByLnobDimension(dimension: Object): Array Get all indicators for the given lnob dimension from the store. |
|
public |
getIndicatorsForRegion(region: Object): Array Get all indicators from the store, each including the respective observation for the given region. |
|
public |
getIndicatorsForRegionByGoal(region: Object, goal: Object): Array Get all indicators for the given goal from the store, each including the respective observation for the given region. |
|
public |
getIndicatorsForRegionByLnobDimension(region: Object, dimension: Object): Array Get all indicators for the given lnob dimension from the store, each including the respective observation for the given region. |
|
public |
Get the label/title for an SDG with the given number. |
|
public |
getLabelWithoutUnit(label: string): string Remove the unit from the indicator label. |
|
public |
getLastYear(timeseries: Object): number Get the last year where the timeseries has a non-null value. |
|
public |
getLnobDimension(dimNumber: number): Object Get the label & description for a LNOB dimension with the given number. |
|
public |
Get all LNOB assessments from the store. |
|
public |
getLnobDimensionsForRegion(region: Object): Array Get all lnob assessments from the store, each including the respective observation for the given region. |
|
public |
Get the numeric rank for the given observation. |
|
public |
getRankAsText(observation: Object, fallback: string): String Get the text rank for a given observation. |
|
public |
Get the rating for a given observation (green, yellow, orange, etc...). |
|
public |
getRegions(): Array Get all regions from the store. |
|
public |
getRegionsByType(type: String): Array Get all regions from the store of a given type. |
|
public |
getRegionsWithAssessment(assessment: Object): Array Get all regions from the store, each including the respective observation for the given assessment. |
|
public |
getRegionsWithTimeseries(assessment: Object): Array Get all regions from the store, each including the respective timeseries values for the given assessment. |
|
public |
Get the numeric score for the given observation. |
|
public |
getScoreAsText(observation: Object, precision: number, fallback: string): String Get the text score for a given observation, with the given level of decimal precision. |
|
public |
Get the label and the color for an SDG with the given number. |
|
public |
getTimeseriesValue(timeseries: Object, year: Number): number Get timeseries value for the given year. |
|
public |
Get the trend (e.g., "↑", "➚", etc...) for the given observation. |
|
public |
Get all trend indicators from the store. |
|
public |
Get the numeric, raw value for the given observation. |
|
public |
getValueAsText(observation: Object, precision: number, fallback: string): String Get the text raw value for a given observation, with the given level of decimal precision. |
|
public |
Get the numeric year for the given observation. |
|
public |
getYearAsText(observation: Object, fallback: string): String Get the text year for a given observation. |
|
public |
hasTimeseries(timeseries: Object): bool Check if the given object has timeseries values. |
|
public |
Check if the given region is a country. |
|
public |
isDataLoaded(options: Object): boolean Check if all datasets have already been loaded into the store. |
|
public |
isGlobalOnly(assessment: Object): bool Check whether the given assessment is a global-only indicator (used only to assess non-OECD countries). |
|
public |
Check if the given assessment is a goal. |
|
public |
Check if the given observation is imputed. |
|
public |
isIndicator(assessment: Object): bool Check if the given assessment is an indicator. |
|
public |
isLnobAssessment(assessment: Object): bool Check if the given assessment is the leave-no-one-behind performance. |
|
public |
isLnobDimension(assessment: Object): bool Check if the given assessment is a LNOB dimension. |
|
public |
Check whether the given region is a member of the OECD. |
|
public |
isOecdOnly(assessment: Object): bool Check whether the given assessment is an OECD-only indicator (used only to assess OECD countries). |
|
public |
isOverallAssessment(assessment: Object): bool Check if the given assessment is the overall SDG Index performance. |
|
public |
isRelevantIndicatorForRegion(assessment: Object, region: Object): bool Check whether the given assessment is a relevant indicator for the region. |
|
public |
isSpilloverAssessment(assessment: Object): bool Check if the given assessment is the overall spillover index performance. |
|
public |
isTrendIndicator(assessment: Object): bool Check if the given assessment is a trend indicator. |
|
public |
Loads data (assessments, regions, observations, ...) into store. |
|
public |
roundNumber(number: string | number, precision: number): number Round a number to a given level of precision. |
|
public |
useDataStore(options: Object): DataStoreStatus Use any @sdgindex/data functions in a React component. |
|
public |
Write the store to a series of human-readable and minified JSON files. |
Static Private Summary | ||
private |
addAssessment(assessment: Object): Object Add an assessment to the store. |
|
private |
decodeObject(array: Array, encoding: Array): Object Decode the given array back into an object structure, based on the provided encoding. |
|
private |
determineObjectEncoding(objects: Array): Array Determine object encoding by counting the number of times each property/key appears in the objects. |
|
private |
encodeObject(object: Object, encoding: Array): Array Convert the given object into array, which requires less space and is faster to load. |
|
private |
ensureDataIds(param: *) Ensure dataId prop is present on the object, otherwise load dataId from store The dataId prop is added permanently to the object, so that we don't have to reload it again and again. |
|
private |
loadDataset(dataset: Object): Promise Load a single dataset into the store. |
Static Public
public addGoal(params: Object): Object source
import {addGoal} from '@sdgindex/data/parse'
Add a goal to the store.
public addGoals(options: Object): Object[] source
import {addGoals} from '@sdgindex/data/parse'
Add all goals to the store. Optionally, skip certain goals by passing
the except
argument.
public addIndicator(indicator: Object): Object source
import {addIndicator} from '@sdgindex/data/parse'
Add an indicator to the store
Params:
Name | Type | Attribute | Description |
indicator | Object | ||
indicator.id | string | The unique ID for the indicator |
|
indicator.goalNumber | number | The goal to which the indicator belongs, e.g., |
|
indicator.labelWithUnit | string |
|
The label for the indicater, including the unit. Used to automatically generate the slug, label, and unit. Alternatively, slug, label, and unit properties can be set manually. |
indicator.slug | string |
|
The slug for the indicator, usually automatically generated from labelWithUnit. |
indicator.label | string |
|
The label for the indicator, usually automatically generated from labelWithUnit. |
indicator.unit | string |
|
The unit for the indicator, usually automatically generated from labelWithUnit. |
indicator.params | ...Object |
|
any other params to add to the indicator, such as description or source |
public addLnobAssessment(params: Object): Object source
import {addLnobAssessment} from '@sdgindex/data/parse'
Add the spillover assessment to the store
Params:
Name | Type | Attribute | Description |
params | Object |
|
any custom parameters to add to the assessment or default properties to overwrite |
public addLnobDimension(params: Object): Object source
import {addLnobDimension} from '@sdgindex/data/parse'
Add a LNOB to the store.
public addLnobDimensions(options: Object): Object[] source
import {addLnobDimensions} from '@sdgindex/data/parse'
Add all lnobs to the store. Optionally, skip certain lnobs by passing
the except
argument.
public addObservation(observation: Object): Object source
import {addObservation} from '@sdgindex/data/parse'
Add an observation to the store
Params:
Name | Type | Attribute | Description |
observation | Object | ||
observation.region | Object | the region to which the observation belongs |
|
observation.assessment | Object | the assessment to which the observation belongs |
|
observation.score | number |
|
the score of the region on the assessment |
observation.rank | number |
|
the rank of the region on the assessment |
observation.rating | string |
|
the rating of the region on the assessment,
e.g., |
observation.trend | string |
|
the trend of the region on the assessment,
e.g., |
observation.value | number |
|
the raw value of the region on the assessment (applicable to indicators only) |
observation.year | number |
|
the raw value of the region on the assessment (applicable to indicators only) |
observation.isImputed | boolean |
|
whether the observation is imputed ( |
observation.params | ...Object |
|
any other properties to store on the observation |
public addOverallAssessment(params: Object): Object source
import {addOverallAssessment} from '@sdgindex/data/parse'
Add the overall assessment to the store
Params:
Name | Type | Attribute | Description |
params | Object |
|
any custom parameters to add to the assessment or default properties to overwrite |
public addRegion(region: Object): Object source
import {addRegion} from '@sdgindex/data/parse'
Add a region to the store
Params:
Name | Type | Attribute | Description |
region | Object | ||
region.id | string | the unique ID for the region |
|
region.name | string | The name of the region. Used to automatically generate the region slug. |
|
region.type | string | the type of the region, e.g., |
|
region.slug | string |
|
provide a slug to overwrite the auto-generated slug |
region.params | ...Object |
|
any other params to add to the region, such as population or GDP |
public addSpilloverAssessment(params: Object): Object source
import {addSpilloverAssessment} from '@sdgindex/data/parse'
Add the spillover assessment to the store
Params:
Name | Type | Attribute | Description |
params | Object |
|
any custom parameters to add to the assessment or default properties to overwrite |
public addTimeseries(timeseries: Object): Object source
import {addTimeseries} from '@sdgindex/data/parse'
Add timeseries to the store. If the values of all data points are null, the series is not added.
Params:
Name | Type | Attribute | Description |
timeseries | Object | ||
timeseries.region | Object | the region to which the timeseries belongs |
|
timeseries.assessment | Object | the assessment to which the timeseries belongs |
|
timeseries.dataPoints | Object[] | an array of data points |
|
timeseries.dataPoints[].year | number | the year of the data point |
|
timeseries.dataPoints[].value | number | the value of the data point |
public convertScoreToColor(colorScore: number): string source
import {convertScoreToColor} from '@sdgindex/data/parse'
Convert score to rating color. Color scores are sometimes used in the US SDG Index.
- colorScore below 1 => red
- colorScore below 2 => orange
- colorScore below 3 => yellow
- colorScore over or equal 3 => green
- colorScore null | undefined => gray
Params:
Name | Type | Attribute | Description |
colorScore | number | The numeric color score |
public excelToJson(param: Object): Array source
import {excelToJson} from '@sdgindex/data/parse'
Convert a sheet in an Excel file into JSON format. See: https://www.npmjs.com/package/xlsx
Return:
Array | the converted sheet as an array of objects. See: https://www.npmjs.com/package/xlsx#json |
public findAssessmentById(id: String): Object source
import {findAssessmentById} from '@sdgindex/data'
Find an assessment by its ID.
Params:
Name | Type | Attribute | Description |
id | String | The UNIQUE id associated with the assessment |
public findAssessmentBySlug(slug: String): Object source
import {findAssessmentBySlug} from '@sdgindex/data'
Find an assessment by its slug.
Params:
Name | Type | Attribute | Description |
slug | String | The UNIQUE slug associated with the assessment |
public findAssessmentForRegionById(region: Object, assessmentId: string): Object source
import {findAssessmentForRegionById} from '@sdgindex/data'
Find a specific assessment by ID and include the observation for the given region.
public findGoalForRegionById(region: Object, goalId: string): Object source
import {findGoalForRegionById} from '@sdgindex/data'
Find a specific goal by assessment ID and include the observation for the given region.
public findIndicatorById(id: String): Object source
import {findIndicatorById} from '@sdgindex/data'
Find an indicator by its ID.
Params:
Name | Type | Attribute | Description |
id | String |
public findIndicatorBySlug(slug: String): Object source
import {findIndicatorBySlug} from '@sdgindex/data'
Find an indicator by its slug.
Params:
Name | Type | Attribute | Description |
slug | String |
public findIndicatorForRegionById(region: Object, indicatorId: string): Object source
import {findIndicatorForRegionById} from '@sdgindex/data'
Find a specific indicator by ID and include the observation for the given region.
public findIndicatorForRegionBySlug(region: Object, indicatorSlug: string): Object source
import {findIndicatorForRegionBySlug} from '@sdgindex/data'
Find a specific indicator by slug and include the observation for the given region.
public findLnobAssessment(): Object source
import {findLnobAssessment} from '@sdgindex/data'
Get the leave-no-one-behind assessment.
public findLnobAssessmentForRegion(region: Object): Object source
import {findLnobAssessmentForRegion} from '@sdgindex/data'
Get the leave-no-one-behind assessment, including the observation for the given region.
Params:
Name | Type | Attribute | Description |
region | Object | The region for which to load the observations |
public findObservationByRegionAndAssessment(region: Object, assessment: Object): Object source
import {findObservationByRegionAndAssessment} from '@sdgindex/data'
Find the observation for the given region and assessment.
public findOverallAssessment(): Object source
import {findOverallAssessment} from '@sdgindex/data'
Get the overall SDG Index assessment.
public findOverallAssessmentForRegion(region: Object): Object source
import {findOverallAssessmentForRegion} from '@sdgindex/data'
Get the overall SDG Index assessment, including the observation for the given region.
Params:
Name | Type | Attribute | Description |
region | Object | The region for which to load the observations |
public findRegionById(id: String): Object source
import {findRegionById} from '@sdgindex/data'
Find a region by its ID.
Params:
Name | Type | Attribute | Description |
id | String |
public findRegionBySlug(slug: String): Object source
import {findRegionBySlug} from '@sdgindex/data'
Find a region by its slug.
Params:
Name | Type | Attribute | Description |
slug | String |
public findRegionWithAssessmentById(assessment: Object, regionId: string): Object source
import {findRegionWithAssessmentById} from '@sdgindex/data'
Find a specific region by ID and include the observation for the given assessment.
public findSpilloverAssessment(): Object source
import {findSpilloverAssessment} from '@sdgindex/data'
Get the spillover index assessment.
public findSpilloverAssessmentForRegion(region: Object): Object source
import {findSpilloverAssessmentForRegion} from '@sdgindex/data'
Get the spillover index assessment, including the observation for the given region.
Params:
Name | Type | Attribute | Description |
region | Object | The region for which to load the observations |
Return:
Object | return the overallspillover index assessment, including the observation for the given region |
public findTimeseriesByRegionAndAssessment(region: Object, assessment: Object): Array source
import {findTimeseriesByRegionAndAssessment} from '@sdgindex/data'
Find the timeseries for a specific region and assessment.
public findTimeseriesByRegionAndIndicator(region: Object, indicator: Object): Array source
import {findTimeseriesByRegionAndIndicator} from '@sdgindex/data'
Find the timeseries for a specific region and indicator.
public getAssessments(): Array source
import {getAssessments} from '@sdgindex/data'
Get all assessments from the store.
public getColor(sdgNumber: number): String source
import {getColor} from '@sdgindex/data/sdgs'
Get the color for an SDG with the given number.
Params:
Name | Type | Attribute | Description |
sdgNumber | number | The number of the SDG (1 - 17) |
public getFirstYear(timeseries: Object): number source
import {getFirstYear} from '@sdgindex/data/timeseries'
Get the first year where the timeseries has a non-null value.
Params:
Name | Type | Attribute | Description |
timeseries | Object |
public getGoals(): Array source
import {getGoals} from '@sdgindex/data'
Get all goal assessments from the store.
public getGoalsForRegion(region: Object): Array source
import {getGoalsForRegion} from '@sdgindex/data'
Get all goal assessments from the store, each including the respective observation for the given region.
Params:
Name | Type | Attribute | Description |
region | Object | The region for which to load the observations |
Return:
Array | return an array of goals, each including the respective observation for the given region |
public getIndicatorUnit(label: string): string | null source
import {getIndicatorUnit} from '@sdgindex/data/parse'
Extract the unit from an indicator label. Assumes that the unit is wrapped in parentheses. For example: "CO₂ emissions (kg/capita)"
Params:
Name | Type | Attribute | Description |
label | string | the label with unit |
public getIndicators(): Array source
import {getIndicators} from '@sdgindex/data'
Get all indicators from the store.
public getIndicatorsByGoal(goal: Object): Array source
import {getIndicatorsByGoal} from '@sdgindex/data'
Get all indicators for the given goal from the store.
Params:
Name | Type | Attribute | Description |
goal | Object | The goal for which to load the indicators |
public getIndicatorsByLnobDimension(dimension: Object): Array source
import {getIndicatorsByLnobDimension} from '@sdgindex/data'
Get all indicators for the given lnob dimension from the store.
Params:
Name | Type | Attribute | Description |
dimension | Object | The lnob dimension for which to load the indicators |
public getIndicatorsForRegion(region: Object): Array source
import {getIndicatorsForRegion} from '@sdgindex/data'
Get all indicators from the store, each including the respective observation for the given region.
Params:
Name | Type | Attribute | Description |
region | Object | The region for which to load the observations |
Return:
Array | return an array of indicators, each including the respective observation for the given region |
public getIndicatorsForRegionByGoal(region: Object, goal: Object): Array source
import {getIndicatorsForRegionByGoal} from '@sdgindex/data'
Get all indicators for the given goal from the store, each including the respective observation for the given region.
Return:
Array | return an array of indicators, each including the respective observation for the given region |
public getIndicatorsForRegionByLnobDimension(region: Object, dimension: Object): Array source
import {getIndicatorsForRegionByLnobDimension} from '@sdgindex/data'
Get all indicators for the given lnob dimension from the store, each including the respective observation for the given region.
Return:
Array | return an array of indicators, each including the respective observation for the given region |
public getLabel(sdgNumber: number): String source
import {getLabel} from '@sdgindex/data/sdgs'
Get the label/title for an SDG with the given number.
Params:
Name | Type | Attribute | Description |
sdgNumber | number | The number of the SDG (1 - 17) |
public getLabelWithoutUnit(label: string): string source
import {getLabelWithoutUnit} from '@sdgindex/data/parse'
Remove the unit from the indicator label. Assumes that the unit is wrapped in parentheses. For example: "CO₂ emissions (kg/capita)"
Params:
Name | Type | Attribute | Description |
label | string | the label with unit |
public getLastYear(timeseries: Object): number source
import {getLastYear} from '@sdgindex/data/timeseries'
Get the last year where the timeseries has a non-null value.
Params:
Name | Type | Attribute | Description |
timeseries | Object |
public getLnobDimension(dimNumber: number): Object source
import {getLnobDimension} from '@sdgindex/data/sdgs'
Get the label & description for a LNOB dimension with the given number.
Params:
Name | Type | Attribute | Description |
dimNumber | number | The number of the LNOB (1 - 4) |
public getLnobDimensions(): Array source
import {getLnobDimensions} from '@sdgindex/data'
Get all LNOB assessments from the store.
public getLnobDimensionsForRegion(region: Object): Array source
import {getLnobDimensionsForRegion} from '@sdgindex/data'
Get all lnob assessments from the store, each including the respective observation for the given region.
Params:
Name | Type | Attribute | Description |
region | Object | The region for which to load the observations |
Return:
Array | return an array of lnob, each including the respective observation for the given region |
public getRank(observation: Object): number source
import {getRank} from '@sdgindex/data/observations'
Get the numeric rank for the given observation.
Params:
Name | Type | Attribute | Description |
observation | Object |
public getRankAsText(observation: Object, fallback: string): String source
import {getRankAsText} from '@sdgindex/data/observations'
Get the text rank for a given observation. If rank is null, the fallback text is returned.
public getRating(observation: Object): String source
import {getRating} from '@sdgindex/data/observations'
Get the rating for a given observation (green, yellow, orange, etc...).
Params:
Name | Type | Attribute | Description |
observation | Object |
public getRegions(): Array source
import {getRegions} from '@sdgindex/data'
Get all regions from the store.
public getRegionsByType(type: String): Array source
import {getRegionsByType} from '@sdgindex/data'
Get all regions from the store of a given type.
Params:
Name | Type | Attribute | Description |
type | String | The type of regions to return |
public getRegionsWithAssessment(assessment: Object): Array source
import {getRegionsWithAssessment} from '@sdgindex/data'
Get all regions from the store, each including the respective observation for the given assessment.
Params:
Name | Type | Attribute | Description |
assessment | Object | the assessment for which to load the observation |
public getRegionsWithTimeseries(assessment: Object): Array source
import {getRegionsWithTimeseries} from '@sdgindex/data'
Get all regions from the store, each including the respective timeseries values for the given assessment.
Params:
Name | Type | Attribute | Description |
assessment | Object | the assessment for which to load the timeseries |
Return:
Array | return an array of regions, each including the timeseries values for the given assessment |
public getScore(observation: Object) source
import {getScore} from '@sdgindex/data/observations'
Get the numeric score for the given observation.
Params:
Name | Type | Attribute | Description |
observation | Object |
public getScoreAsText(observation: Object, precision: number, fallback: string): String source
import {getScoreAsText} from '@sdgindex/data/observations'
Get the text score for a given observation, with the given level of decimal precision. If the score is null, the fallback text is returned.
public getSdg(sdgNumber: number): Object source
import {getSdg} from '@sdgindex/data/sdgs'
Get the label and the color for an SDG with the given number.
Params:
Name | Type | Attribute | Description |
sdgNumber | number | The number of the SDG (1 - 17) |
public getTimeseriesValue(timeseries: Object, year: Number): number source
import {getTimeseriesValue} from '@sdgindex/data/timeseries'
Get timeseries value for the given year.
public getTrend(observation: Object): string source
import {getTrend} from '@sdgindex/data/observations'
Get the trend (e.g., "↑", "➚", etc...) for the given observation.
Params:
Name | Type | Attribute | Description |
observation | Object |
public getTrendIndicators(): Array source
import {getTrendIndicators} from '@sdgindex/data'
Get all trend indicators from the store.
public getValue(observation: Object): number source
import {getValue} from '@sdgindex/data/observations'
Get the numeric, raw value for the given observation.
Params:
Name | Type | Attribute | Description |
observation | Object |
public getValueAsText(observation: Object, precision: number, fallback: string): String source
import {getValueAsText} from '@sdgindex/data/observations'
Get the text raw value for a given observation, with the given level of decimal precision. If the raw value is null, the fallback text is returned.
public getYear(observation: Object): number source
import {getYear} from '@sdgindex/data/observations'
Get the numeric year for the given observation.
Params:
Name | Type | Attribute | Description |
observation | Object |
public getYearAsText(observation: Object, fallback: string): String source
import {getYearAsText} from '@sdgindex/data/observations'
Get the text year for a given observation. If year is null, the fallback text is returned.
public hasTimeseries(timeseries: Object): bool source
import {hasTimeseries} from '@sdgindex/data/timeseries'
Check if the given object has timeseries values.
Params:
Name | Type | Attribute | Description |
timeseries | Object |
Return:
bool | Return true if the object has timeseries |
public isCountry(region: Object): bool source
import {isCountry} from '@sdgindex/data/regions'
Check if the given region is a country.
Params:
Name | Type | Attribute | Description |
region | Object |
Return:
bool | return true if the given region is a country |
public isDataLoaded(options: Object): boolean source
import {isDataLoaded} from '@sdgindex/data'
Check if all datasets have already been loaded into the store.
public isGlobalOnly(assessment: Object): bool source
import {isGlobalOnly} from '@sdgindex/data/assessments'
Check whether the given assessment is a global-only indicator (used only to assess non-OECD countries).
Params:
Name | Type | Attribute | Description |
assessment | Object |
Return:
bool | Return true if the assessment is a global-only indicator |
public isGoal(assessment: Object): bool source
import {isGoal} from '@sdgindex/data/assessments'
Check if the given assessment is a goal.
Params:
Name | Type | Attribute | Description |
assessment | Object |
Return:
bool | Return true if assessment type is "goal" |
public isImputed(observation: Object): bool source
import {isImputed} from '@sdgindex/data/observations'
Check if the given observation is imputed.
Params:
Name | Type | Attribute | Description |
observation | Object |
Return:
bool | Return true if observation is imputed |
public isIndicator(assessment: Object): bool source
import {isIndicator} from '@sdgindex/data/assessments'
Check if the given assessment is an indicator.
Params:
Name | Type | Attribute | Description |
assessment | Object |
Return:
bool | Return true if assessment type is "indicator" |
public isLnobAssessment(assessment: Object): bool source
import {isLnobAssessment} from '@sdgindex/data/assessments'
Check if the given assessment is the leave-no-one-behind performance.
Params:
Name | Type | Attribute | Description |
assessment | Object |
Return:
bool | Return true if assessment is the LNOB performance |
public isLnobDimension(assessment: Object): bool source
import {isLnobDimension} from '@sdgindex/data/assessments'
Check if the given assessment is a LNOB dimension.
Params:
Name | Type | Attribute | Description |
assessment | Object |
Return:
bool | Return true if assessment type is "lnob" |
public isOecd(region: Object): bool source
import {isOecd} from '@sdgindex/data/regions'
Check whether the given region is a member of the OECD.
Params:
Name | Type | Attribute | Description |
region | Object |
Return:
bool | return true if the region is a member of the OECD |
public isOecdOnly(assessment: Object): bool source
import {isOecdOnly} from '@sdgindex/data/assessments'
Check whether the given assessment is an OECD-only indicator (used only to assess OECD countries).
Params:
Name | Type | Attribute | Description |
assessment | Object |
Return:
bool | Return true if the assessment is an OECD-only indicator |
public isOverallAssessment(assessment: Object): bool source
import {isOverallAssessment} from '@sdgindex/data/assessments'
Check if the given assessment is the overall SDG Index performance.
Params:
Name | Type | Attribute | Description |
assessment | Object |
Return:
bool | Return true if assessment is the overall SDG Index performance |
public isRelevantIndicatorForRegion(assessment: Object, region: Object): bool source
import {isRelevantIndicatorForRegion} from '@sdgindex/data/assessments'
Check whether the given assessment is a relevant indicator for the region.
Return:
bool | Return true if the assessment is a relevant indicator for the region |
public isSpilloverAssessment(assessment: Object): bool source
import {isSpilloverAssessment} from '@sdgindex/data/assessments'
Check if the given assessment is the overall spillover index performance.
Params:
Name | Type | Attribute | Description |
assessment | Object |
Return:
bool | return true if the assessment is the overall spillover index performance |
public isTrendIndicator(assessment: Object): bool source
import {isTrendIndicator} from '@sdgindex/data/assessments'
Check if the given assessment is a trend indicator.
Params:
Name | Type | Attribute | Description |
assessment | Object |
Return:
bool | Return true if the assessment is a trend indicator |
public loadData(options: Object): Promise source
import {loadData} from '@sdgindex/data'
Loads data (assessments, regions, observations, ...) into store.
public roundNumber(number: string | number, precision: number): number source
import {roundNumber} from '@sdgindex/data/parse'
Round a number to a given level of precision.
public useDataStore(options: Object): DataStoreStatus source
import {useDataStore} from '@sdgindex/data'
Use any @sdgindex/data functions in a React component. The data store will be loaded, if not already done so. Optionally, timeseries can be loaded, too. The hook uses useState internally, so the component will be re-rendered when the data has been fully loaded.
Example:
const MyComponent = () => {
const { isLoaded } = useDataStore();
if(!isLoaded) return null;
return <div>my content</div>;
};
public writeStoreToJson() source
import {writeStoreToJson} from '@sdgindex/data/parse'
Write the store to a series of human-readable and minified JSON files. These can then be loaded/imported in the data visualization. One JSON file is created for each type of data (assessments, regions, observations, and timeseries).
Static Private
private addAssessment(assessment: Object): Object source
import {addAssessment} from '@sdgindex/data/parse'
Add an assessment to the store.
Params:
Name | Type | Attribute | Description |
assessment | Object |
private decodeObject(array: Array, encoding: Array): Object source
import {decodeObject} from '@sdgindex/data/src/utilities/decodeObject.js'
Decode the given array back into an object structure, based on the provided encoding.
private determineObjectEncoding(objects: Array): Array source
import {determineObjectEncoding} from '@sdgindex/data/src/utilities/determineObjectEncoding.js'
Determine object encoding by counting the number of times each property/key appears in the objects. The encoding is then set to start with the property that appears most frequently and to end with the property that appears least frequently.
Params:
Name | Type | Attribute | Description |
objects | Array | the array of objects for which to determine the best encoding |
private encodeObject(object: Object, encoding: Array): Array source
import {encodeObject} from '@sdgindex/data/src/utilities/encodeObject.js'
Convert the given object into array, which requires less space and is faster to load. The object properties are converted into an array according to the encoding. The encoding should be an array of properties.
private ensureDataIds(param: *) source
import {ensureDataIds} from '@sdgindex/data'
Ensure dataId prop is present on the object, otherwise load dataId from store The dataId prop is added permanently to the object, so that we don't have to reload it again and again.