Jump to content
Software FX Community

dates in out-gauge


sstranger

Recommended Posts

The dates are static the way I set them up, but I believe you could set them up dynamically in the XML of the template file.  How will the gadget be used?  Will it be restarted every so often, for example?  The gadget would have to be closed/reopened for the dates to get adjusted with the method I'm thinking of (if it works).

Link to comment
Share on other sites

If I understand correctly, you want to be able to plot dates in a linear gauge instead of numbers, e.g. the scale min is 01/01/2007, the scale max is 12/31/2007 and you want to plot today's date. Linear and radial gauges don't accept dates as values/min/max, but you can do a couple of tricks to achieve what you want, using PowerShell and the .NET Framework.

First, you need to convert your dates into doubles, by using .NET's Convert.ToOADate, which converts a datetime into its corresponding double. Then, you can customize the scale's labels to show the dates you want instead of the numbers. The following code assigns 01/01/2007 as the scale's min and 12/31/2007 as the scale's max, and today's date as the plotted value (I assume today's date is a day in the year 2007).

$min = [Convert]::ToDateTime("01/01/2007")$max = [Convert]::ToDateTime("12/31/2007")$today = get-date

out-gauge -type horizontal -mainscale_min $min.ToOADate() -mainscale_max $max.ToOADate() -value $today.ToOADate() -mainscale_MaxAlwaysDisplayed true -mainscale_CustomLabels_39083 "01/01/2007" -mainscale_CustomLabels_39447 "12/31/2007" -mainscale_tickmarks_major_step (39447-39083)

The numbers 39447 and 39083 that seem to appear magically are the representation as double of $min and $max ($min.ToOADate and $max.ToOADate). I'm setting the step so no intermediate labels appear, but you can tweak it to show whatever you want, just making sure that you assign the appropriate customlabels to avoid showing a number.

It's important to be aware of that you are actually passing a number, which will appear in places like the tooltip. You can customize your tooltip to show the actual date plotted by adding -mainindicator_tooltip $today.This is not a perfect solution, but I hope it helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...