Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Steps progress bar

 

**EDIT - Fixed it so no responses needed**

 

Hi all

 

I have a question on progress bar for steps please...

 

I have this in my index.js

import {today, goals} from "user-activity";

import { me as device } from "device";

import document from "document";

 

const deviceWidth = device.screen.width;
const stepGoalPercentage = (userActivity.today.adjusted["steps"] || 0) * 100 / goals.steps;
stepsbar.width = (stepGoalPercentage / 100) * deviceWidth;
const stepsbar = document.getElementById("stepsbar");

 

and this in my index.gui

<rect id="stepsbar" width="150" height="20%" x="0" y="80%" fill="maroon"/>

 

However when trying to build there is an error "Unhandled exception: ReferenceError: userActivity is not defined".

I'm not sure if there is a step goal in the simulator so is there a way to force/pretend a goals.steps

 

Thank you for any help.

 

**EDIT - Fixed it so no responses needed**

Best Answer
0 Votes
1 REPLY 1

Yeah, you imported `today`, you can just reference the user activity API from that imported variable. e.g. `today.adjusted.steps`

Best Answer
0 Votes