Graphing for Windows Phone 7– Mood Tracker #6

Wishing every one a happy independence day!

In the last post we enabled Mood Tracker to enter new data in to HealthVault.  Before I start this post in details of adding graphing layer let me motivate it by showing what the graph for Mood Tracker looks like –

image

Fig 1. Graphing Over the 7 days

The interesting aspect here is that we are tracking Mood, Stress and Wellbeing over a period of one week, and looking for patterns in terms of mood, stress and wellbeing correlations. There are better ways to do graphing for this data but this is a simplistic approach.

In order to be able to get data from HealthVault for a specific time period we will have to update the implementation of our GetThings method to allow for a filter for effective date max and min. Notice the interesting formatting we need to do to make DateTime serializable.

private static string EffDateMinXml(DateTime? effDateMin)
{
    if (effDateMin != null)
        return
            string.Format(@"<eff-date-min>{0}</eff-date-min>",
                effDateMin.Value.ToString("yyyy-MM-ddTHH:mm:ss.FFFZ",
                            CultureInfo.InvariantCulture)
                );
    else return "";
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }Once we are powered with a way to selectively get information from HealthVault we can simply make use of the awesome open-source amCharts library. Infact I added it to the project with one-click using NuGet Package manager (note to self: may be post a version of HealthVault Windows Phone library on NuGet). Here is a snippet of how I configured the SerialChart.

<amq:SerialChart x:Name="EmotionsChart" BorderThickness="1" DataSource="{Binding EmotionList}" CategoryValueMemberPath="FormattedWhen" AxisForeground="White" PlotAreaBackground="Black" GridStroke="DarkGray" Height="463" Width="450"> <amq:SerialChart.Graphs> <amq:LineGraph ValueMemberPath="Mood" Title="Mood" Brush="Blue" StrokeThickness="6" BorderBrush="Cornsilk"/> <amq:LineGraph ValueMemberPath="Stress" Title="Stress" Brush="#8000FF00" StrokeThickness="8" /> <amq:LineGraph ValueMemberPath="Wellbeing" Title="Wellbeing" StrokeThickness="2" Brush="#80FF0000"/> </amq:SerialChart.Graphs> </amq:SerialChart>

 

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Note that the formatting for the X-Axis is derived by a special property we added to the EmotionalStateModel, it probably is not the right place to add that property.

Over last few days I have implemented an interesting idea to make entering emotional state information easier similar in themes as the original mood tree but more focused on making data entry fun , I call it vMudi.

So next time w’ll look at vMudi.

2 thoughts on “Graphing for Windows Phone 7– Mood Tracker #6

  1. Hi! Thank you for this valuable source of healthvault-wp7 interaction.
    Actually when i try to run the project (i have downloaded from git) after the authentication it gives me this error:
    emotionalState.Parse(latestEmotion.Descendants(“data-xml”).Descendants(“emotion”).Single());
    NullReferenceException was unhandled

    Did i miss something?
    Best Regards,
    George

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s