2015-11-01 29 views
0

我們一直在嘗試爲SSRS中的堆疊數據欄提供靈活的設計,以便在100%填充的Tablix列單元格中顯示所觀看視頻材料的百分比。具有可變數量數據點的SSRS堆疊數據條

目標是清晰顯示用戶查看過的視頻片段的各個部分。例如,我們主持了一個1小時的電視節目集,但用戶並不總是從頭到尾觀看整個節目,我們想知道他們實際觀看的視頻的哪些部分。用戶可能會跳起來 - 在開始時觀看一點點,然後跳到中間,看更多,然後走到最後。我們使用的流式視頻系統提供了查看開始和結束位置的詳細報告。我們的工作是將所有信息放入簡潔的固定長度的數據欄中,以便快速顯示特定用戶觀看過的特定視頻剪輯的數量。

這是報告的期望外觀。

Here's the desired look of the report

在第一行,你會看到用戶已經觀看了視頻的20%左右,則躍升至49%,並觀看,直到54%,然後停止。這導致觀看視頻總長度的25%。

這可以使用堆疊的數據條來實現嗎?任何建議非常感謝。

+0

我覺得「這是可能的」是它是。您是否有查詢返回已開發的相關數據?共享這個輸出將有助於我們爲圖表設計提供建議。 – Jonnus

+0

我認爲範圍條形圖更適合使用。這與甘特圖相同。 – Kim

+0

「在第一行中,您會看到用戶瀏覽過大約20%的視頻,然後跳到49%,然後觀看直到54%,然後停下來。」 - 它那種視頻吧? ;) – bushell

回答

0

我能夠通過創建一個定製的SSRS程序集來生成位圖圖像並將其作爲字節數組返回,然後在圖像表達式字段中使用它來解決此問題。

如果有人有興趣,所使用的部分C#代碼來生成基於所述視頻的觀看部分圖像是下面:

using System; 
using System.Collections.Generic; 
using System.Drawing; 
using System.Drawing.Drawing2D; 
using System.Drawing.Imaging; 
using System.IO; 
using System.Linq; 
using System.Text.RegularExpressions; 

namespace SSRSExtensions 
{ 
    public class ReportFunctions 
    { 
     public static Byte[] GetViewingRangeImage(String ranges, String imageFormatString, Single width, Single height, String backgroundColor, String foregroundColor, String separatorColor) 
     { 
      Byte[] retValue = null; 

      ImageFormat imageFormat = GetImageFormat(imageFormatString); 
      if (imageFormat != null) 
      { 
       ImageCodecInfo imageCodec = GetImageEncoderInfo(imageFormat); 

       Bitmap bitmap = GetViewingRangeImageBitmap(ranges, width, height, backgroundColor, foregroundColor, separatorColor); 

       using (EncoderParameters encoderParameters = new EncoderParameters(1)) 
       { 
        using (EncoderParameter encoderParameter = new EncoderParameter(Encoder.Quality, 100L)) 
        { 
         encoderParameters.Param[0] = encoderParameter; 

         using (MemoryStream memoryStream = new MemoryStream()) 
         { 
          bitmap.Save(memoryStream, imageFormat); 

          retValue = memoryStream.ToArray(); 
         } 
        } 
       } 
      } 

      return retValue; 
     } 
    } 
} 

形象表達是:= SSRSExtensions.ReportFunctions.GetViewingRangeImage(字段!ViewingRange.Value, 「PNG」,200,25, 「白」, 「#808080」, 「#bfbfbf」)

的實際範圍以逗號分隔字符串指定的,就像這樣: 0.000000-10.000000,20.000000-50.000000,90.000000-100.000000。,其中用戶首先觀看10%,跳過20%並觀看直到50%,然後跳到90%,並完成觀看直到結束。

這篇較舊的博客文章(https://blog.oraylis.de/2012/04/ssrs-custom-drawing-code/)討論瞭如何繪製動態圖像並在報告中使用它們。它使用內聯VB。如果您想使用C#,您必須創建一個外部程序集,將其複製到C:\ Program Files \ Microsoft SQL Server [SSRS INSTALL FOLDER] \ Reporting Services \ ReportServer \ bin文件夾,並在您的報告中引用它。

如果有人需要關於如何將此全部插入到SSRS報告的其他詳細信息,請告訴我,我很樂意幫助。