Tag Archive: PivotViewer


In the past, many times I have come around a situation where I want to load a completely different set of facets in the Pivot Viewer without really instantiating a new instance of it! While in the Pivot Viewer’s first version it was relatively simpler (by just loading a different cxml) but in the second version it didn’t work right, when I was using the client-side loading of items. There was always something that didn’t work example the filter pane wouldn’t show the facets of the new collection, etc. But, there’s a very simple solution for this (actually it was too simple to be believable for the first time…at least for me), so here it is…before you set the new PivotProperties and the Templates, just write down the following 3 lines:

ItemPivot.ItemsSource = null;
ItemPivot.PivotProperties.Clear();
ItemPivot.ItemTemplates.Clear();

Thats it! And you’ll never face a problem in loading a new set of items following a different structure again! Kapish? 🙂

Advertisements

Pivot Viewer v2 (released as a part of SL 5 RC) is one of smartest improvements done by MS to its own products. However, there are still somethings which are not very clearly available. For instance, sorting multivalued facets, custom actions, etc. In this series of blogs, I am going to explain to you how one can do the tasks which were quite easy in the old version of Pivot Viewer but not so straight forward in this version and then later I’ll take you through how you can harness the power of this newer version of the super awesome product. The series will evolve as follows:

Stay tuned!

An awesome blog post demonstrating how to harness the power of the new Pivot Viewer (released as a part of SL5 RC).

Joris Dries started a Twitter conversation this morning about getting decent performance out of the PivotViewer in SL5RC. So, I thought now would be a good time to gather a bunch of ideas I've had over the past few months and put them all in one post. This might not answer Joris' question directly, but it does satisfy the title. You can download the complete source code of the examples here. What I'll do is build a number of scenarios and compare … Read More

via Good Coffee Good Code

After playing with Pivot Viewer for long time, I decided to take one more step of going towards a decentralized approach i.e. storing data in different servers. So, I created 3 servers, one for images another for data (about facets) and one server for Pivot Viewer JIT Collection generation. Everything was well set and all communication working fine and suddenly I couldn’t see images any more in the Pivot Viewer. I checked all the images that my images were accessible from my machine, the data was going to the JIT server properly and also checked all the possible options where an exception could be raised and I didnt find anything…and still no images!

Then I compared the CXML files from the version before and this new setup and I found out that there was no information about the images and I was really pissed…as to what in the world went wrong? Then it struck into my mind to try an access the images on the server where the CXML is being generated and BINGO! The error was even though the images existed and were accessible from the my machine…they were not accessible on the JIT server and as soon as I enabled the access of the images on this server, the images started to show up on the pivot viewer as well.

Come to think about it, its pretty logical and I should have known that this would happen but I didn’t realize until I faced the issue. And sharing this, might help some other poor soul like mine was for the last 2 days.

Cheers!

If you are using a Mac OS, you may come across a situation where you are not able to see the collection in the Pivot viewer, while you will be able to see the same collection in Windows/Linux. And this can happen in the case of both when the cxml comes from a file or it is generated dynamically using the PivotServerTools JIT collection. There can be multiple reasons for this:

  1. The website that hosts the cxml doesn’t have anonymous access on. If this is case, just switch on the anonymous access and you should see the collection now.
  2. This case is usually found to be obstacle. It comes because of an incompatibility between Mac and PivotViewer’s DeepZoom. The DeepZoom bug is reproduced on all the Mac browsers if the “source” attribute for your items in the collection’s dzc file is empty. To see if you are the victim of this, do the following:

    1. Try to navigate to your .cxml from a browser on the mac. Make sure it comes back i.e. if the URL of your collection is http://www.abc.com/collection.cxml, visit this URL and see if the cxml is populated in your browser. In case of chrome, you’ll have to right click on the page and click on “View Page Source” to see if the collection is coming back.
    2. b. If the cxml is returned, find out the dzc from it. You can find it in the “ImgBase” attribute of the “Items” tag; it’ll look something like “collection-5f7c6a376516425598d3d822d2bd3cbf.dzc”.
    3. c. Then try to navigate to your .dzc file from the same browser, the URL will now be http://www.abc.com/collection-5f7c6a376516425598d3d822d2bd3cbf.dzc and see if the dzc is sent back. Again in chrome, check the Page’s source to see the result. The collection returned will now be something like this:

	<?xml version="1.0" encoding="utf-8" ?>
	<Collection MaxLevel="8" TileSize="256" Format="jpg" NextItemId="183" xmlns="http://schemas.microsoft.com/deepzoom/2008">
	  <Items>
		<I Id="0" N="0" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/0.dzi">
		  <Size Width="256" Height="256" />
		</I>
		<I Id="1" N="1" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/1.dzi">
		  <Size Width="256" Height="256" />
		</I>
		<I Id="2" N="2" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/2.dzi">
		  <Size Width="256" Height="256" />
		</I>
		<I Id="3" N="3" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/3.dzi">
		  <Size Width="256" Height="256" />
		</I>
		<I Id="4" N="4" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/4.dzi">
		  <Size Width="256" Height="256" />
		</I>
		<I Id="5" N="5" IsPath="1" Source="items-5f7c6a376516425598d3d822d2bd3cbf/dzi/5.dzi">
		  <Size Width="256" Height="256" />
		</I>
	  </Items>
	</Collection>

This dzc file contains the information about the DeepZoom for the collection items. Here what you have to check is that for an item you have the value in the Source attribute. If there’s no value in the Source attribute i.e. Source=””, then we have a problem. And this is what brings us to the DeepZoom bug on the Mac OS. So if you can be put a value to this Source attribute even though a fake one (Yes, I said fake), you will start seeing the collection. It’s funny how an attribute whose value doesn’t matter can be so problematic (FYI, the source attribute is used for getting the DZI). If you are doing a JIT collection, the reason for this could be that the size of your images used for the collection items is 256 by 256. You can check this by debugging the “PivotServerTools” project, go to PivotServerTools Ă  Internal Ă  MakeItemContent


	string source = string.Empty;
	if ((null != item.ImageProvider) && (null != item.ImageProvider.DziPath))
	{
		source = item.ImageProvider.DziPath;
	}
	else if (IsAutoGenerateDzi)
	{
		//Only provide an auto-DZI if the image is larger than a collection tile
		if (null != item.ImageProvider)
		{
			Size size = item.ImageProvider.Size;
			if ((size.Width >= TileDimension) || (size.Height >= TileDimension))
			{
				source = DziSerializer.MakeDziPath(m_collection.CollectionKey, id);
			}
		}
	}

	yield return new XAttribute("Source", source);


Check here what the exact reason is and correct it else you can use a fake URL to get it working. Enjoy!

When you are using dynamic collections with PivotViewer i.e. JIT collections generated using the PivotServerTools, there comes a situation when the Pivot Viewer stops taking the fresh data from the server. This is because the Pivot Viewer caches the collection, so when you reload the collection again (in the same session), it doesn’t ask the JIT server for the cxml again and instead uses the cxml from the cache. This is good in terms of the performance however it’s bad if your data keeps on updating at the server and you are not able to reflect the latest data in your collection. What you should know is that the PivotViewer caches the collection based on the URL that you pass in the PivotViewer’s LoadCollection method, so if you call the method:

PivotViewer.LoadCollection(“url”, “viewerstate”);

again and again without changing the url parameter, only for the first call data will be fetched from your server, for all subsequent calls PivotViewer will take the collection from the cache. To avoid this, you have to keep changing the URL, whenever you call the above method. The best way to do it, is to add a query string parameter which you may/may not use and update it every time you load the collection. You can do something like below:

PivotViewer.LoadCollection(“url”+ “?guid=”+Guid.NewGuid(), “viewerstate”);

this adds a new query string parameter “guid” to your url who’s value change every time you load the collection and since it’s a different url, PivotViewer doesn’t find the collection in its cache and hence sends a call to the JIT server to get the new collection. Therefore, you will always see fresh data in your collection but what you should keep in mind is that this will degrade the performance of the PivotViewer (but only at the time of loading), so what you can do as a further tweak is only change the guid parameter when you need fresh data in your collection and in all the other cases you can use the url with the same guid parameter which will help in keeping the performance of the PivotViewer intact, this tweak will be a boon if your JIT server takes time for generating the collection and the data is not updated always.

Happy Coding 🙂

I have been working around with the Silverlight Pivot Viewer for long time now and I have noticed that whenever I use a JIT collection I dont see Description in the facet panel but when I use a static collection, Description is available. First I thought maybe description facet is not allowed in JIT collections but then I remembered that the Collection class constructor does ask for Description in its parameter, this made my curious and I started dive into the code of PivotServerTools Project and I found that there’s no place in the code where this Description is used apart from when creating the default item images. After a lot of searching I was able to find a solution using which Description can be made visible. To do so, follow the below steps:

1. Go to the PivotServerTools project.
2. Open the Internal folder.
3. There you’ll see a “CxmlSerializer” class, this class is used when the method Collection.ToCXML() is invoked, which is done by the Pivot Viewer. Open this class and navigate to the method “MakeItemContent”. In this method add the following line:

if (!string.IsNullOrEmpty(item.Description)){
	yield return new XStreamingElement(Xmlns + "Description", item.Description);
}

This way Description will start showing up in the Facet panel of every collection provided you specified a value for it in the Item’s collection class constructor.