Silverlight (and WPF) Data Visualization classes unsealed [Silverlight Toolkit October 2009 release now available!]
We've just published the October 2009 release of the Silverlight Toolkit as part of today's .NET 4 and Visual Studio 2010's Beta 2 release! One of the big things we've done with this release of the Toolkit is to add rich support for Visual Studio 2010's vastly improved Silverlight design-time experience. In fact, the new VS 2010 design-time experience has gotten so good that some developers have stopped using Blend altogether!
Other big news for this release is the introduction of comprehensive, WPF-compatible drag-and-drop support for Silverlight! Although this support doesn't extend outside the web browser (that would require changes to Silverlight itself), it enables full-fidelity drag-and-drop experiences within the browser using the same API that WPF users are already accustomed to. And if that wasn't enough, there are also a collection of drag-and-drop-friendly "wrapper controls" for common scenarios (ex: ListBox
, TreeView
, and DataGrid
) that make it trivial to add support for drag-and-drop to an existing control. Dragging and dropping within a control (to re-order items) or between controls (to move items around) is now just a few lines of XAML away! (Note: No code changes necessary!) But wait, there's more: There's also a wrapper for Charting's DataPointSeries
that enables drag-and-drop into and out of a live Chart
control! This really needs to be seen to be believed, so please visit the "Drag and Drop" page of the public samples for a great example of this. Then go read Jafar's post about the new drag/drop support for all the juicy details!
Note: The October 09 release of the Silverlight Toolkit includes binaries for Silverlight 3 only. Now that Silverlight 3 has been out for a few months and is fully backward-compatible with all Silverlight 2 applications, we expect that everyone has upgraded from Silverlight 2 and are therefore no longer actively developing the Toolkit for Silverlight 2. Of course, if some of you have a specific need for Silverlight 2 Toolkit bits, previous releases continue to be available to download from CodePlex!
With the introductory stuff out of the way, let's move on to the details of changes to the Data Visualization assembly and the corresponding improvements to Silverlight and WPF Charting. My recent post on Data Visualization Development Release 1 has already discussed most of these changes at length, so I'm just going to include the change descriptions here. For more detail on the motivation behind these changes or their implications for current and future possibilities, please refer back to that post.
Notable Changes
Unsealed (i.e., removed the "sealed" modifier from) all core Data Visualization classes. Although we aren't yet completely settled on the public-facing API for Data Visualization and reserve the right to make breaking changes in the future, these classes are being unsealed now to help simplify a wide variety of user scenarios that are being actively developed and that are cumbersome without the ability to subclass (without needing to create a private build of the assembly solely for the purpose of unsealing these classes). Other changes were kept to a minimum, but a couple of methods have been changed to protected virtual for consistency and/or convenience as well as some tweaks that resulted due to new code analysis warnings due to explicit interface implementations in an unsealed class.
Introduced ISeries interface to Charting as "base interface" for all Series. This allows users to write
ItemsControl
-basedSeries
which will automatically leverage all of theItemsControl
infrastructure for creating points, tracking data changes, etc. and also gives us a safe root for a future 3D series hierarchy. As part of this change, some interfaces have been cleaned up a bit (IStyleDispenser
,ISeriesHost
) and others have been created (IStyleDispenser.StylesChanged
event). Also, some public methods with little justification have been removed/made private/moved lower (Chart.Refresh
,Chart.ResetStyles
,StyleDispenser.ResetStyles
) and some vestigial code has been removed (ISeriesHost.GlobalSeriesIndexesInvalidated
).Various usability improvements. Updated
Series
to look for "LegendItemStyle" in theirResourceDictionary
for increased customizability. AddedOwner
property toLegendItem
pointing to owningSeries
instance to simplifyLegendItem
-based user scenarios. AddedActualDataPointStyle
andActualLegendItemStyle
properties and usedBindings
to automatically propagate changes to the right places. (Aside: This fixes a bug that was reported against the WPF Toolkit as I was making the change!) Moved code so thatPieSeries
now has theDataPointStyle
property like the otherSeries
. UpdatedLegendItem
defaultTemplate
to include standardTemplateBindings
forBackground
/BorderBrush
/BorderThickness
for more friendly designer experience.Breaking Changes
Renamed Charting's StylePalette to Palette (for clarity) AND changed its type to IEnumerable<ResourceDictionary> (from IEnumerable<Style>) for a significant flexibility boost. Performed related renamings (many internal/private):
IStyleDispenser
->IResourceDictionaryDispenser
,StylePalette
->ResourceDictionaryCollection
,StyleDispensedEventArgs
->ResourceDictionaryDispensedEventArgs
,StyleDispenser
->ResourceDictionaryDispenser
,StyleEnumerator
->ResourceDictionaryEnumerator
.
Most notably, this change makes it possible to associate MULTIPLE things with a palette entry and enables designers to easily and flexibly customize things like theLineSeries
PolyLineStyle
in thePalette
. Additionally it enables the use ofDynamicResource
(currently only supported by the WPF platform) to let users customize theirDataPointStyle
without inadvertently losing the default/custom Palette colors. (Note: A very popular request!) Thanks to mergedResourceDictionaries
, this also enables the addition of arbitrary resources at thePalette
level (likeBrushes
) which can then be referenced byDataPoints
, etc..Changed return value of Charting's IAxis.GetPlotAreaCoordinate from UnitValue? to UnitValue to better support custom Axis implementations. Specifically, some numeric axis types (logarithmic axis, for example) don't support all numeric values and need a way to indicate that certain values (ex: <= 0 for logarithmic) are "not supported" for plotting. This was previously done by returning a
null
value, but now the code should return aUnitValue
withValue=double.NaN
. Convenience methodUnitValue.NaN
has been added to create such values easily. Because theSeries
implementations already need to handleNaN
values, this change collapses two different edge cases into one and simplifies the code accordingly. Added code toSeries
to handle this situation by hiding (viaVisibility=Collapsed
)DataPoints
on coordinates that are not valid.One notable consequence of this change is that the
Visibility
ofDataPoint
s is now controlled by theSeries
and will be set toVisible
orCollapsed
as necessary. Therefore, any customizations that directly set this property may no longer work, but there are other simple ways of achieving the same effect and this change is not expected to cause any difficulty. For example, the "Sparkline" demo of the samples project was affected by this change because it provided a customDataPointStyle
that setVisibility
toCollapsed
. The fix is not only trivial, but an improvement: change theStyle
to specify anull
Template
instead!Other Changes
Remove unnecessary code. Moved duplicated
DependencyProperties
IRangeAxis
DependentRangeAxis
andIAxis
IndependentAxis
fromColumnSeries
andBarSeries
into common base classColumnBarBaseSeries
. Moved duplicatedDependencyProperties
IRangeAxis
DependentRangeAxis
andIAxis
IndependentAxis
fromAreaSeries
andLineSeries
into common base classLineAreaBaseSeries
. Made similar changes for methodsOnApplyTemplate
andUpdateDataPoint
and half ofUpdateShape
.Simplified default Palette Brushes by removing ScaleTransform and TranslateTransform and replacing with RadialBrush. The on-screen visuals remain the same, but the XAML is considerably smaller and simpler - and should be a bit quicker to render as well!
Various other small changes.
Of the two breaking changes, only the rename to Palette
is likely to affect most people. Fortunately, converting existing code/XAML is really quite simple - which you can see as I recycle the example I gave previously.
The old way:
<chartingToolkit:Chart Title="Statistics (Custom Palette)"> <chartingToolkit:Chart.StylePalette> <visualizationToolkit:StylePalette> <Style TargetType="Control"> <Setter Property="Background" Value="Blue"/> </Style> <Style TargetType="Control"> <Setter Property="Background" Value="Green"/> </Style> <Style TargetType="Control"> <Setter Property="Background" Value="Red"/> </Style> </visualizationToolkit:StylePalette> </chartingToolkit:Chart.StylePalette> ... </chartingToolkit:Chart>
And the new way (with changes highlighted):
<chartingToolkit:Chart Title="Statistics (Custom Palette)"> <chartingToolkit:Chart.Palette> <visualizationToolkit:ResourceDictionaryCollection> <ResourceDictionary> <Style x:Key="DataPointStyle" TargetType="Control"> <Setter Property="Background" Value="Blue"/> </Style> </ResourceDictionary> <ResourceDictionary> <Style x:Key="DataPointStyle" TargetType="Control"> <Setter Property="Background" Value="Green"/> </Style> </ResourceDictionary> <ResourceDictionary> <Style x:Key="DataPointStyle" TargetType="Control"> <Setter Property="Background" Value="Red"/> </Style> </ResourceDictionary> </visualizationToolkit:ResourceDictionaryCollection> </chartingToolkit:Chart.Palette> ... </chartingToolkit:Chart>
It's pretty clear that once you've done this once, it'll be easy to do anywhere else your project requires. I explained the motivations for this change previously, so I won't repeat myself here - I just wanted to call out how straightforward the upgrade is expected to be.
Clearly, the big news for Data Visualization is the unsealing of the primary charting classes! Because I went into great detail on this earlier, I won't spend a lot of time on that here. Instead, I'd like to call out a particularly timely and relevant use of the new subclassing ability: Cory Plotts' LogarithmicAxis implementation for WPF and Silverlight! What's great about what he's done is that logarithmic axis support is one of our most requested features, and something we haven't had a chance to implement yet. I've always hoped that somebody in the community would be able to step up and share something here, so I was really excited to see Cory's blog post. If you're one of the users who's been waiting for a logarithmic axis, please have a look at Cory's implementation and see if it does what you need!
Aside: You might be wondering why we haven't gotten to logarithmic axis ourselves... Well, as you may be aware, we've been operating under severe resource constraints from the beginning, and that forces us to try to choose our investments carefully. When we're trying to decide between two features and one of them constitutes a change to the core of the Charting framework while the other is something that derives from an existing class to build on top of the framework, we'll tend to make the core framework change and hope that the community is able to help with the subclassing change. Honestly, this seems like the right balance to me and is a large part of why we're unsealing now even though the Charting APIs aren't completely set in stone.
Along similar lines, I encourage people who have been wanting to annotate their PieSeries
charts to have a look at the fantastic work Bea Stollnitz has done: Part 1, Part 2, Part 3. Bea built on top of the sealed Charting hierarchy using some pretty clever tricks and techniques. But now that we've unsealed, it's my hope that she'll be able to take advantage of that to spend more time working on the great features she's adding and less time trying to jump through artificial hoops.
There are two other things I'd like to call out here:
- I'll post an updated version of my DataVisualizationDemos sample application in the next couple of days to make sure people have lots of good Charting examples using the new
Palette
syntax. - I'll post a new Silverlight/WPF Data Visualization Development Release shortly after that to give anyone who wants pre-compiled binaries for WPF (or an easy way to compile for both platforms at once) what they need to be successful.
As always, if you have any questions or feedback, the right places to start are the Silverlight Discussion Forum or the WPF Discussion List. Bugs and feature requests can be logged with the Silverlight Issue Tracker or the WPF Issue Tracker. Please raise issues that are clearly unique to one platform or the other in the obvious place. But for general questions and things that are common to both platforms, the Silverlight forum/list is probably a better place because there's more context and history there.
Thanks very much for your interest in Silverlight and WPF Data Visualization - I hope you like the improvements!