This project is read-only.

Is there a way to display axes that go through the Origin of a LineGraph ?

Oct 10, 2009 at 8:14 PM

Instead of having axes on the left/right/top/bottom of the graph, I'd like to have X and Y axes that go through the Origin of a LineGraph.  

These axes should move when the graph is moved -- however, if the origin moves outside the visible area of the graph, I would then want to turn on the left/right/top/or bottom axes.

any thoughts on how to do this?

 

Oct 14, 2009 at 3:35 PM

Hi, currently this is not possible with DynamicDataDisplay out-of-the-box, thought we have such feature in long-term plans. To create such an axis you'll need to override default position of axis so that it is inside the viewport and change self position according to its changes.

Regards,

Mikhail.

Oct 14, 2009 at 4:30 PM
great, thanks for the reply.

I did find a way to get this to work cleanly that involved modifying
only a couple internal library functions and adding a couple of member
variables to turn the feature on and off.

Cheers,
-Bob

On Wed, Oct 14, 2009 at 10:35 AM, thecentury <notifications@codeplex.com> wrote:
> From: thecentury
>
> Hi, currently this is not possible with DynamicDataDisplay out-of-the-box,
> thought we have such feature in long-term plans. To create such an axis
> you'll need to override default position of axis so that it is inside the
> viewport and change self position according to its changes.
>
> Regards,
>
> Mikhail.
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com
Oct 14, 2009 at 4:38 PM

Hi Bob,

can I take a look at what you've done? It is very interesting fro me)

Mikhail.

Oct 14, 2009 at 7:16 PM
Sure thing ... the changes were mostly to OnViewportPropertyChanged in
AxisBase.cs which is appended below. This function now references two
new properties, AxisTiedToOrigin and ShowZeros, which I added to
AxisControl.cs. Finally, in AxisControl.cs, I added two lines to the
loop inside DrawTicks(...):

if (labels[i] is TextBlock && (labels[i] as
TextBlock).Text == "0" && !ShowZeros) // bcz: don't show '0' labels on
floating axes
continue;

I believe those are all the changes I made -- let me know if you add a
better way to do this, and I'll grab your source again.

Thanks,
-Bob


private void OnViewportPropertyChanged(object sender,
ExtendedPropertyChangedEventArgs e)
{
Viewport2D viewport = (Viewport2D)sender;
Rect visible = viewport.Visible;
Range<T> range =
CreateRangeFromRect(visible.ViewportToData(viewport.Transform));

using (axisControl.OpenUpdateRegion())
{
axisControl.Range = range;
axisControl.Transform = viewport.Transform;
if (axisControl.AxisTiedToOrigin) { //bcz: allow the axes
anchored to the left and right to float with the Origin
if (axisControl.Placement == AxisPlacement.Left) {
double min = visible.Left;
double max = visible.Right;
if (max > 0 && min < 0) {
double xorigin = (0 - min) / (max - min) *
viewport.Output.Width;
axisControl.RenderTransform = new
TranslateTransform(xorigin, 0);
axisControl.ShowZeros = false;
}
else
axisControl.ShowZeros = true;
if (min > 0)
axisControl.RenderTransform = new
TranslateTransform(0, 0);
if (max < 0)
axisControl.RenderTransform = new
TranslateTransform(viewport.Output.Width, 0);
}
if (axisControl.Placement == AxisPlacement.Bottom) {
double min = visible.Bottom;
double max = visible.Top;
if (max < 0 && min > 0) {
double yorigin = (0 - min) / (max - min) *
viewport.Output.Height;
axisControl.RenderTransform = new
TranslateTransform(0, -viewport.Output.Height + yorigin);
axisControl.ShowZeros = false;
}
else
axisControl.ShowZeros = true;
if (max > 0)
axisControl.RenderTransform = new
TranslateTransform(0, 0);
if (min < 0)
axisControl.RenderTransform = new
TranslateTransform(0, -viewport.Output.Height);
}
}
}
}



On Wed, Oct 14, 2009 at 11:41 AM, thecentury <notifications@codeplex.com> wrote:
> From: thecentury
>
> Hi Bob,
>
> can I take a look at what you've done? It is very interesting fro me)
>
> Mikhail.
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com