Series visibility, Smooth refresh, CornerRadius/ShowPointer Tracker

Oystein Bjorke 6 lat temu 0
This discussion was imported from CodePlex

ChevyCP wrote at 2012-01-18 18:52:


    Great package!!  I'm using it in a mission critical package for use at sea on research vessels.  I have three (hopefully) quick questions.  (This is all done in WPF.)

I have about 18 basic line series.  I have a matching checkbox for each and I would like to bind the IsChecked of the checkbox to the visibility of the lineseries.  (Using a boolean to visibility converter like this:  Visibility="{Binding ElementName=CHECKBOX_NAME, Path=IsChecked, Converter={StaticResource BoolToVisConvert}}" )

Unfortunately this doesn't hide the series.  Even manually setting the series to collapsed in the xaml doesn't make it disapear.  What am I missing?  How can I hide a series?  The only (very ugly) solution I could come up with is to bind the itemssource of the lineseries to the tag property of the checkbox which would store the list of datapoints when checked and null when unchecked.


The second question has to do with triggering a refresh.  I have the color property of a lineseries bound to a color picker.  This works great and when I change the color in my color picker, the line is instantly updated with the correct color.  I thought this would work with the smooth property, but it doesn't trigger a refresh.  I have the Smooth property bound to a checkbox.  When checked, it does change the Smooth property to true and if you zoom/pan the chart, the lineseries is smoothed.  It just isn't refreshed automatically the way the color property is. 

Is there a notification event on the color but not on the smooth property?  Is this possible or would I have to manually create a refresh when the checkbox is selected/unselected?


The last, very minor question I had was it is possible to have both cornerradius and showpointer on the tracker?  Basically I want the default tracker functionality, but with round corners.  When I set the showpointer to true and cornerradius of the trackercontrol, the pointer is not displayed.  Is there anyway to easily do this or would I have to create a custom canvas with a border, textbox and a callout?


Thanks a lot!

objo wrote at 2012-01-27 07:58:

Hi, cool to hear that you are using the library on a real mission :)

#1: I added IsVisible bool property to the Series. I added one example in the example library. For Wpf.Series use the Visibility dependency property.

#2: Fixed the bug for all dependency properties in the Wpf.LineSeries

#3: Sorry, this is not currently possible. See TrackerControl.CreatePointerBorderGeometry if you want to improve this. Please send a patch if you can make it work!

See changelist 74393.

ChevyCP wrote at 2012-01-27 15:38:

Awesome!  Thanks!  I just downloaded the source and will try it out.


As for as the tracker control, I will check it out sometime, just don't know if I am good enough to come up with a solution for that.  I could design something in expression design and export it as a control or drawing brush and somehow bind the point of the pointer to the location on the series.  Or create some kind of opacity mask.  Or just add a point more line segments to make it look rounder...   Maybe one of those could work, I will let you know if I can come up with anything, once I get some free time.


I've been updating software from winforms to wpf c# and adding lots of new features.  We use it on NOAA research vessels to instantly validate the performance of fishing trawls using data that is streamed back to the ship from all kinds of sensors on the net and ship.  We need to make sure that all our tows meet certain exact standards and my software makes sure that it happens.  The graphing side of this app is extremely helpful in visualizing all our data.  With funding cuts, we don't have the budget to use one of those overpriced third-party apps, so your solution is perfect.  Just thought you'd like to know how your code is being used.  Again, thanks for creating this!

ChevyCP wrote at 2012-01-27 15:48:

lol, and I just noticed that you also coded the helix 3d toolkit.  I am also using that in this same project!  (And these two packages are the only third party code I am using in this program besides the ESRI wpf api.)   You're good.  


Instead of make a boring app with pop up windows for my different view like a settings page, a mapping page, a charting page, etc.  I put the whole thing on a 3d cube and when the user presses a button to see, say the charting window, instead of a popup, it rotates the cube the side with the charts.   Much prettier :-)   (and still very functional without being an assault on the eyes.  I made that mistake on my first wpf app and went overboard with the animations and effects...)

objo wrote at 2012-01-29 20:48:

cool to hear how you are using the libraries!   

The tracker control is changing size depending on the contents, and the alignment and pointer position is depending on the tracked point position (to make sure the contents never is outside the view). You should check how it is implemented in the TrackerControl code, it should not be too difficult to refactor the code to accept rounded corners (maybe it is possible to make some general code that is used for all 8 configurations...) 

GaganKapoor wrote at 2013-02-28 09:36:

  Regarding #1, I am also trying to add a checkbox to each legend series. Is there an example available where I can get reference ?

ChevyCP wrote at 2013-02-28 16:33:

Here are the key parts on how I did it. It should work the same for any series. This is just a customized lines that had two colors, with a center color and the end colors being the same (so it would go red, greeen, red on the same line).
     <BooleanToVisibilityConverter x:Key="BoolToVisConvert" />

 <CheckBox Name="exampleChartCB"
                  Style="{StaticResource chartCB}" />

     <oxy:CustomTwoColorLineSeries Name="exampleLineSeries"
                                                      ItemsSource="{Binding exampleChartLine}"
                                                      MaxLimit="{Binding ElementName=endLineLA, Path=X}"
                                                      MinLimit="{Binding ElementName=startLineLA, Path=X}"
                                                      Style="{StaticResource oxyLineSeriesStyle}"
                                                      TrackerFormatString="Example&#10;{2:yyyy-MM-dd HH:mm:ss}&#10;{4}"
                                                      Visibility="{Binding ElementName=exampleChartCB, Path=IsChecked, Converter={StaticResource BoolToVisConvert}}"
                                                      YAxisKey="{Binding ElementName=exampleAxisRB, Path=Tag}"
                                                      Color="{Binding ElementName=exampleColorPick, Path=SelectedColor}" />

GaganKapoor wrote at 2013-03-01 12:16:

Thanks ChevyCP

My oxyplot is bound to a model which creates the series dynamically. What I did eventually is to overlay a checkbox list on top of the plot and hide the default legend. Everything works fine excep I couldn't work out how to place the overlay checkbox list in proper place on top of plot. I coudn't get the exact x and y axis locations so that I can place my control properly. Do you know how to get the location ? Any help would be highly appreciated.

This is what I have in my xaml:
<oxy:Plot x:Name="plot"
              Model="{Binding OxyModel, Mode=OneWay, NotifyOnTargetUpdated=True}"/>
<!-- could't get how to set margin of below stackpanel so that It aligns with the bottom right corner of plot--> <StackPanel Name="legendPanel" Orientation="Vertical" VerticalAlignment="Bottom" Margin="0,0,20,30">
        <ListBox ItemsSource="{Binding Path=LegendItems}" 
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="Opacity" Value="0.9" />
                    <StackPanel Orientation="Horizontal" Margin="0,0,0,0">
                        <CheckBox IsChecked="{Binding Path=IsChecked}" Margin="0,0,1,0" BorderThickness="0" BorderBrush="Transparent"/>
                        <Border Width="15" Margin="0,1,0,1" CornerRadius="2" Background="{Binding Path=Background}"/>
                        <TextBlock Text="{Binding Path=DisplayText}" Margin="1,0,0,0" FontSize="10"/>