RadChart hide empty values

Thread is closed for posting
7 posts, 0 answers
  1. jesus trejo
    jesus trejo avatar
    6 posts
    Member since:
    Sep 2009

    Posted 22 Oct 2009 Link to this post

    Hi, i need help...

    I have a stored procedure with nulls values, so, when I poppulated the RadChart with this stored, I can see the lines but where the value is null the line goes to the 0 and i dont want that, i need to hide, cut, etc the line, how can I do this?


    thks.
  2. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 23 Oct 2009 Link to this post

    Try using this code:
     
    if (e.SeriesItem.YValue == 0.0) 
         e.SeriesItem.Parent.Items.Remove(e.SeriesItem); 

    in the ItemDataBound event.
  3. jesus trejo
    jesus trejo avatar
    6 posts
    Member since:
    Sep 2009

    Posted 23 Oct 2009 Link to this post

    Hi,

    Thks a lot for the code and answer, I try it and it works, but I have a problem, I have another stored and I used in the Radchart and use this code, the e.SeriesItem.Index freeze in the Index 6 then the code remove the item and de index value is -1 then the process continue and enter again in this code and code throw index = 6 then -1 while the Item passed to the next the value, for example:

    index = 6
    Item 7 // the process Removed this item
    index = -1
    -------------

    index = 6
    Item 8 // the process Removed this item
    Index = -1

    -------------
    etc.. etc.. etc... and throw this exception:

     

    Server Error in '/AnalisisLBBO' Application.

    StackedLine series must have equal items count

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Telerik.Charting.ChartException: StackedLine series must have equal items count

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [ChartException: StackedLine series must have equal items count]
       Telerik.Charting.Chart.GetException(RenderEngine renderEngine, Exception ex) +638
       Telerik.Charting.Chart.GetImage(Int32 width, Int32 height) +583
       Telerik.Web.UI.RadChart.RenderClassic(HtmlTextWriter writer) +384
       Telerik.Web.UI.RadChart.RenderContents(HtmlTextWriter writer) +380
       System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
       Telerik.Web.UI.RadDataBoundControl.Render(HtmlTextWriter writer) +36
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
       System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +163
       System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
       System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
       System.Web.UI.Page.Render(HtmlTextWriter writer) +29
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
    


    Do you know what´s happening?  this is the stored:

    SELECT
    MESID,
    [MENSUALES MAYORES],
    [MENSUAL PROMEDIO UNIDADES],
    [MENSUALES MENORES],
    [MENSUAL FRANQUICIA ANALIZADA],
    [MENSUAL PROMEDIO FRANQUICIAS],
    [MENSUAL PROMEDIO CADENA LBBO],
    [MENSUAL UNIDADES CORPORATIVO],
    [ANUAL FRANQUICIA ANALIZADA]
    FROM (
      SELECT  
      ISNULL(A.MESID,B.MESID)MESID,
      ROUND([MENSUALES MAYORES],2)[MENSUALES MAYORES],
      ROUND([MENSUAL PROMEDIO UNIDADES],2)[MENSUAL PROMEDIO UNIDADES],
      ROUND([MENSUALES MENORES],2)[MENSUALES MENORES],
      ROUND([MENSUAL FRANQUICIA ANALIZADA],2)[MENSUAL FRANQUICIA ANALIZADA],
      ROUND([MENSUAL PROMEDIO FRANQUICIAS],2)[MENSUAL PROMEDIO FRANQUICIAS],
      ROUND([MENSUAL PROMEDIO CADENA LBBO],2)[MENSUAL PROMEDIO CADENA LBBO],
      ROUND([MENSUAL UNIDADES CORPORATIVO],2)[MENSUAL UNIDADES CORPORATIVO],
      ROUND([ANUAL FRANQUICIA ANALIZADA],2)[ANUAL FRANQUICIA ANALIZADA],
      A.TAMANOUNIDADID
       FROM (
        SELECT H.TAMANOUNIDADID, H.ANIOID, H.MESID,MAX(TOTALES) [MENSUALES MAYORES], MIN(TOTALES) [MENSUALES MENORES], AVG(TOTALES)[MENSUAL PROMEDIO UNIDADES]
        FROM (
        SELECT V.UNIDADID, V.TAMANOUNIDADID, V.ANIOID, V.MESID,(B/A)*100 TOTALES
        FROM (
           SELECT UA.UNIDADID, TAMANOUNIDADID, UA.ANIOID, UA.MESID,MONTO A
           FROM dbo.Catalogo_Unidades CA
           JOIN unidades_analizadas UA
            ON CA.cadid = UA.cadenaid
            AND CA.unidadid = UA.unidadid
           JOIN catalogo_meses CM
            ON UA.mesid = CM.mesid
           WHERE UA.conid = '2-01-99-000-0000'
            AND cadid = 1
            AND anioid = @anio
            AND trimestre <= @trime
            AND tamanounidadid = (SELECT tamanounidadid FROM dbo.Catalogo_Unidades WHERE cadid = 2 AND unidadid = @unidad)
           GROUP BY UA.UNIDADID, TAMANOUNIDADID, UA.ANIOID, UA.MESID, MONTO
          ) V
          JOIN (
            SELECT UA.UNIDADID, TAMANOUNIDADID, UA.ANIOID, UA.MESID, MONTO B
            FROM dbo.Catalogo_Unidades CA
            JOIN unidades_analizadas UA
             ON CA.cadid = UA.cadenaid
             AND CA.unidadid = UA.unidadid
            JOIN catalogo_meses CM
             ON UA.mesid = CM.mesid
            WHERE UA.conid = '2-20-00-000-0000'
             AND cadid = 1
             AND anioid = @anio
             AND trimestre <= @trime
             AND tamanounidadid = (SELECT tamanounidadid FROM dbo.Catalogo_Unidades WHERE cadid = 2 AND unidadid = @unidad)
            GROUP BY UA.UNIDADID,TAMANOUNIDADID, UA.ANIOID, UA.mesid,MONTO
           ) W
           ON V.ANIOID = W.ANIOID AND V.MESID = W.MESID AND V.UNIDADID = W.UNIDADID
        ) H
        GROUP BY H.tamanounidadid, H.ANIOID, H.MESID
       ) A
       JOIN (
        SELECT A.tamanounidadid,A.ANIOID, A.MESID, ([UTILIDAD MENSUAL FRANQUICIA ANALIZADA]/[VENTAS MENSUAL FRANQUICIA ANALIZADA] * 100)[MENSUAL FRANQUICIA ANALIZADA]
        FROM (
         SELECT tamanounidadid,UA.ANIOID, UA.MESID, SUM(MONTO)[VENTAS MENSUAL FRANQUICIA ANALIZADA]
         FROM dbo.Catalogo_Unidades CA
         JOIN unidades_analizadas UA
          ON CA.cadid = UA.cadenaid
          AND CA.unidadid = UA.unidadid
         JOIN catalogo_meses CM
          ON UA.mesid = CM.mesid
         WHERE UA.conid = '2-01-99-000-0000'
          AND cadid = 2
          AND anioid = @anio
          AND UA.unidadid = @unidad
         GROUP BY tamanounidadid,UA.CONID, UA.ANIOID, UA.mesid
        ) A
        JOIN (
         SELECT tamanounidadid, UA.ANIOID, UA.MESID, SUM(MONTO)[UTILIDAD MENSUAL FRANQUICIA ANALIZADA]
         FROM dbo.Catalogo_Unidades CA
         JOIN unidades_analizadas UA
          ON CA.cadid = UA.cadenaid
          AND CA.unidadid = UA.unidadid
         JOIN catalogo_meses CM
          ON UA.mesid = CM.mesid
         WHERE UA.conid = '2-20-00-000-0000'
          AND cadid = 2
          AND anioid = @anio
          AND UA.unidadid = @unidad
         GROUP BY tamanounidadid,UA.CONID, UA.ANIOID, UA.mesid
        ) B
        ON A.ANIOID = B.ANIOID AND A.MESID = B.MESID
       ) C
       ON A.TAMANOUNIDADID = C.TAMANOUNIDADID AND A.ANIOID = C.ANIOID AND A.MESID = C.MESID
       JOIN (
        SELECT A.tamanounidadid, A.ANIOID, A.MESID, ([UTILIDAD MENSUAL UNIDADES CORPORATIVO]/[VENTAS MENSUAL UNIDADES CORPORATIVO]*100) [MENSUAL UNIDADES CORPORATIVO]
        FROM (
         SELECT tamanounidadid, UA.ANIOID, UA.MESID, MONTO[VENTAS MENSUAL UNIDADES CORPORATIVO]
         FROM dbo.Catalogo_Unidades CA
         JOIN unidades_analizadas UA
          ON CA.cadid = UA.cadenaid
          AND CA.unidadid = UA.unidadid
         JOIN catalogo_meses CM
          ON UA.mesid = CM.mesid
         WHERE UA.conid = '2-01-99-000-0000'
          AND cadid = 1
          AND anioid = @anio
          AND trimestre <= @trime
          AND UA.unidadid = (SELECT compunidadid FROM comparaciones WHERE unidadid = @unidad)
         GROUP BY tamanounidadid,UA.ANIOID, UA.mesid, MONTO
        ) A
        JOIN (
         SELECT tamanounidadid, UA.ANIOID, UA.MESID, MONTO[UTILIDAD MENSUAL UNIDADES CORPORATIVO]
         FROM dbo.Catalogo_Unidades CA
         JOIN unidades_analizadas UA
          ON CA.cadid = UA.cadenaid
          AND CA.unidadid = UA.unidadid
         JOIN catalogo_meses CM
          ON UA.mesid = CM.mesid
         WHERE UA.conid = '2-20-00-000-0000'
          AND cadid = 1
          AND anioid = @anio
          AND trimestre <= @trime
          AND UA.unidadid = (SELECT compunidadid FROM comparaciones WHERE unidadid = @unidad)
         GROUP BY tamanounidadid, UA.ANIOID, UA.mesid, MONTO
        ) B
        ON A.TAMANOUNIDADID = B.TAMANOUNIDADID AND A.ANIOID = B.ANIOID AND A.MESID = B.MESID
       ) F
       ON  A.TAMANOUNIDADID = F.TAMANOUNIDADID AND A.ANIOID = F.ANIOID AND A.MESID = F.MESID
       JOIN (
        SELECT A.TAMANOUNIDADID, A.ANIOID, A.MESID, (FRANQUICIAS + CORPORATIVO)/12 [MENSUAL PROMEDIO CADENA LBBO], PROMEDIO [MENSUAL PROMEDIO FRANQUICIAS]
        FROM (
         SELECT TAMANOUNIDADID, ANIOID, MESID,SUM(TOTALES) FRANQUICIAS, AVG(TOTALES) PROMEDIO
         FROM (
           SELECT V.UNIDADID, V.TAMANOUNIDADID, V.ANIOID, V.MESID,(B/A)*100 TOTALES
           FROM (
              SELECT UA.UNIDADID, TAMANOUNIDADID, UA.ANIOID, UA.MESID,sum(MONTO) A
              FROM dbo.Catalogo_Unidades CA
              JOIN unidades_analizadas UA
               ON CA.cadid = UA.cadenaid
               AND CA.unidadid = UA.unidadid
              JOIN catalogo_meses CM
               ON UA.mesid = CM.mesid
              WHERE UA.conid = '2-01-99-000-0000'
               AND cadid = 2
               AND anioid = @anio
               AND trimestre <= @trime
               AND tamanounidadid = (SELECT tamanounidadid FROM dbo.Catalogo_Unidades WHERE cadid = 2 AND unidadid = @unidad)
              GROUP BY UA.UNIDADID, TAMANOUNIDADID, UA.ANIOID, UA.MESID
             ) V
             JOIN (
               SELECT UA.UNIDADID, TAMANOUNIDADID, UA.ANIOID, UA.MESID, sum(MONTO) B
               FROM dbo.Catalogo_Unidades CA
               JOIN unidades_analizadas UA
                ON CA.cadid = UA.cadenaid
                AND CA.unidadid = UA.unidadid
               JOIN catalogo_meses CM
                ON UA.mesid = CM.mesid
               WHERE UA.conid = '2-20-00-000-0000'
                AND cadid = 2
                AND anioid = @anio
                AND trimestre <= @trime
                AND tamanounidadid = (SELECT tamanounidadid FROM dbo.Catalogo_Unidades WHERE cadid = 2 AND unidadid = @unidad)
               GROUP BY UA.UNIDADID,TAMANOUNIDADID, UA.ANIOID, UA.mesid
              ) W
              ON V.ANIOID = W.ANIOID AND V.MESID = W.MESID AND V.UNIDADID = W.UNIDADID
         ) A
         GROUP BY TAMANOUNIDADID, ANIOID, MESID
        ) A
        JOIN (
         SELECT TAMANOUNIDADID, ANIOID, MESID, SUM(TOTALES) CORPORATIVO
         FROM (
           SELECT V.UNIDADID, V.TAMANOUNIDADID, V.ANIOID, V.MESID,(B/A)*100 TOTALES
           FROM (
              SELECT UA.UNIDADID, TAMANOUNIDADID, UA.ANIOID, UA.MESID,sum(MONTO) A
              FROM dbo.Catalogo_Unidades CA
              JOIN unidades_analizadas UA
               ON CA.cadid = UA.cadenaid
               AND CA.unidadid = UA.unidadid
              JOIN catalogo_meses CM
               ON UA.mesid = CM.mesid
              WHERE UA.conid = '2-01-99-000-0000'
               AND cadid = 1
               AND anioid = @anio
               AND trimestre <= @trime
               AND tamanounidadid = (SELECT tamanounidadid FROM dbo.Catalogo_Unidades WHERE cadid = 2 AND unidadid = @unidad)
              GROUP BY UA.UNIDADID, TAMANOUNIDADID, UA.ANIOID, UA.MESID
             ) V
             JOIN (
               SELECT UA.UNIDADID, TAMANOUNIDADID, UA.ANIOID, UA.MESID, sum(MONTO) B
               FROM dbo.Catalogo_Unidades CA
               JOIN unidades_analizadas UA
                ON CA.cadid = UA.cadenaid
                AND CA.unidadid = UA.unidadid
               JOIN catalogo_meses CM
                ON UA.mesid = CM.mesid
               WHERE UA.conid = '2-20-00-000-0000'
                AND cadid = 1
                AND anioid = @anio
                AND trimestre <= @trime
                AND tamanounidadid = (SELECT tamanounidadid FROM dbo.Catalogo_Unidades WHERE cadid = 2 AND unidadid = @unidad)
               GROUP BY UA.UNIDADID,TAMANOUNIDADID, UA.ANIOID, UA.mesid
              ) W
              ON V.ANIOID = W.ANIOID AND V.MESID = W.MESID AND V.UNIDADID = W.UNIDADID

         ) H
         GROUP BY TAMANOUNIDADID, ANIOID, MESID
        ) B
        ON A.TAMANOUNIDADID = B.TAMANOUNIDADID AND A.ANIOID = B.ANIOID AND A.MESID = B.MESID
       ) K
       ON A.TAMANOUNIDADID = K.TAMANOUNIDADID AND A.ANIOID = K.ANIOID AND A.MESID = K.MESID
       FULL OUTER JOIN ( 
        SELECT A.TAMANOUNIDADID,A.ANIOID, A.MESID, ([UTILIDAD ANUAL FRANQUICIA ANALIZADA]/[VENTAS ANUAL FRANQUICIA ANALIZADA] * 100)[ANUAL FRANQUICIA ANALIZADA]
        FROM (
         SELECT tamanounidadid,UA.ANIOID, UA.MESID, SUM(MONTO)[VENTAS ANUAL FRANQUICIA ANALIZADA]
         FROM dbo.Catalogo_Unidades CA
         JOIN unidades_analizadas UA
          ON CA.cadid = UA.cadenaid
          AND CA.unidadid = UA.unidadid
         JOIN catalogo_meses CM
          ON UA.mesid = CM.mesid
         WHERE UA.conid = '2-01-99-000-0000'
          AND cadid = 2
          AND anioid = (@anio - 1)
          AND UA.unidadid = @unidad
         GROUP BY TAMANOUNIDADID,UA.CONID, UA.ANIOID, UA.mesid
        ) A
        JOIN (
         SELECT TAMANOUNIDADID, UA.ANIOID, UA.MESID, SUM(MONTO)[UTILIDAD ANUAL FRANQUICIA ANALIZADA]
         FROM dbo.Catalogo_Unidades CA
         JOIN unidades_analizadas UA
          ON CA.cadid = UA.cadenaid
          AND CA.unidadid = UA.unidadid
         JOIN catalogo_meses CM
          ON UA.mesid = CM.mesid
         WHERE UA.conid = '2-20-00-000-0000'
          AND cadid = 2
          AND anioid = (@anio - 1)
          AND UA.unidadid = @unidad
         GROUP BY TAMANOUNIDADID,UA.CONID, UA.ANIOID, UA.mesid
        ) B
        ON A.TAMANOUNIDADID = B.TAMANOUNIDADID AND A.ANIOID = B.ANIOID AND A.MESID = B.MESID
       ) B
       ON A.MESID = B.MESID
    ) [MONTOS TOTALES]
    LEFT OUTER JOIN CATALOGO_TAMANO_UNIDAD T
    ON [MONTOS TOTALES].TAMANOUNIDADID = T.TAMANOUNIDADID
    GROUP BY
    MESID,
    [MENSUALES MAYORES],
    [MENSUAL PROMEDIO UNIDADES],
    [MENSUALES MENORES],
    [MENSUAL FRANQUICIA ANALIZADA],
    [MENSUAL PROMEDIO FRANQUICIAS],
    [MENSUAL PROMEDIO CADENA LBBO],
    [MENSUAL UNIDADES CORPORATIVO],
    [ANUAL FRANQUICIA ANALIZADA]
    ORDER BY MESID





  4. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 26 Oct 2009 Link to this post

    Are you experiencing this with all types of Chart types (bar, line, spline etc.) or is it just for a few types? If so, what types?
  5. jesus trejo
    jesus trejo avatar
    6 posts
    Member since:
    Sep 2009

    Posted 26 Oct 2009 Link to this post

    no, I´m using a  RadChart stackedline with one bar
  6. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 27 Oct 2009 Link to this post

    Just trying to make sure I understand why / where this is occurring. You mention that this works with another stored procedure - do you still use a StackedLine and a Bar series on this procedure? If you take out the StackedLine series does the Bar series get any items removed / does this error occur then as well?
  7. Ves
    Admin
    Ves avatar
    2927 posts

    Posted 28 Oct 2009 Link to this post

    Guys,

    The "StackedLine series must have equal items count" exception actually say it all -- stacked series in RadChart require the same number of items in each series in order to ensure proper rendering. Generally, you could use the ChartSeries.Appearance.EmptyValue.Appearance to control how empty values are rendered, for example - set the line color to transparent:

     
    <telerik:ChartSeries Type="Line">
        <Appearance>
            <EmptyValue Mode="Zero" Line-Color="Transparent">
            </EmptyValue>
        </Appearance>

    Unfortunately, due to a bug in the control, this would not be applicable for StackedLine series. My suggestion would be to switch to Line series and add a procedure to update each item's YValue, so that the lines appear as stacked. Here is an example:

    for (int i = RadChart1.Series.Count - 1; i > 0; i--)
                for (int j = 0; j < RadChart1.Series[0].Items.Count; j++)
                {
                    RadChart1.Series[i][j].Label.TextBlock.Text = RadChart1.Series[i][j].YValue.ToString();
                    for (int k = i-1; k >= 0; k--)
                        RadChart1.Series[i][j].YValue += RadChart1.Series[k][j].YValue;
                }


    Greetings,
    Ves
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top