How to dynamically set plotbands for HTML Chart when xaxis are dates

4 posts, 0 answers
  1. Peter
    Peter avatar
    2 posts
    Member since:
    Aug 2013

    Posted 10 Sep Link to this post

    I have a HTML Chart that works great to plot Line Series data against hourly date/time values in the X axis.  I want to shade weekend dates based on the selected date range.  So this needs to be done dynamically in code.  I suspect that I'm not setting the From/To values correctly.  I found one reference that suggested that these should be in OADate format.  But this doesn't seem to work.  But there may be other issues that I'm not seeing.  Here is my code.  Any help is greatly appreciated.

    Here's the relevant Markup

    <telerik:RadHtmlChart runat="server" Width="1000px" Height="300px"  BackColor="AntiqueWhite" PlotArea-XAxis-LabelsAppearance-TextStyle-FontSize="9pt"
          ID="rhcLogsLast24hrs" BorderWidth="1"  >
          <PlotArea>
              <Series>
     
                  <telerik:LineSeries DataFieldY="LogParserSuccess" Name="Log Parser" >
                      <TooltipsAppearance Color="White" DataFormatString="{0:n0}"/>
                      <LabelsAppearance Visible="False" DataFormatString="{0:n0}" />
                      <Appearance  FillStyle-BackgroundColor="#5ab7de">
                          <FillStyle ></FillStyle>
                      </Appearance>
                      <LineAppearance Width="1" />
                      <MarkersAppearance MarkersType="Circle" BackgroundColor="White" Size="8" BorderColor="#5ab7de"
                          BorderWidth="2"></MarkersAppearance>
     
                          <TooltipsAppearance Color="White">
                              <ClientTemplate>
                                  #=dataItem.LogParserSuccess# Million Log Events Parsed on<br />#=dataItem.Hour#
                              </ClientTemplate>
                          </TooltipsAppearance>
                                   </telerik:LineSeries>                                                                                                         
              </Series>
              <XAxis DataLabelsField="Hour"   >
     
                  <LabelsAppearance RotationAngle="90"   DataFormatString="{0:M/d h tt}">
                  </LabelsAppearance>
                  <TitleAppearance Text="Hour">
                  </TitleAppearance>
              </XAxis>
              <YAxis>
                  <LabelsAppearance DataFormatString="{0:n0}" >
                  </LabelsAppearance>
                  <TitleAppearance Text="Log Events" >
                  </TitleAppearance>
              </YAxis>
     
          </PlotArea>
          <Legend >
              <Appearance Visible="True" Position="Right">
              </Appearance>
          </Legend>
          <ChartTitle Text="Log Events">
          </ChartTitle>
      </telerik:RadHtmlChart>

    Here is the relevant Code Behind:

    rhcLogsLast24hrs.PlotArea.XAxis.LabelsAppearance.DataFormatString = "{0:M/d h tt}"
               rhcLogsLast24hrs.PlotArea.XAxis.TitleAppearance.Text = "Hour"
               rhcLogsLast24hrs.PlotArea.YAxis.TitleAppearance.Text = "Log Events (Millions)"
               If ts.TotalHours > 24 Then
                   rhcLogsLast24hrs.PlotArea.XAxis.LabelsAppearance.Step = ts.TotalHours / 20
               End If
     
               Dim I As Integer = 0
               For Each dr As DataRow In dt.Rows
                   Dim thisdate As DateTime = dr("Hour")
     
                   If thisdate.DayOfWeek = DayOfWeek.Saturday Or thisdate.DayOfWeek = DayOfWeek.Sunday Then
                       Dim band As PlotBand = New PlotBand()
                       band.Color = System.Drawing.Color.Green
                       band.Alpha = 190
                       band.From = thisdate.ToOADate
                       band.To = thisdate.AddHours(1).ToOADate
                       rhcLogsLast24hrs.PlotArea.XAxis.PlotBands.Add(band)
                   End If
                   I += 1
               Next
          rhcLogsLast24hrs.DataSource = dt
           rhcLogsLast24hrs.DataBind()

     

    Thanks!

     

  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1494 posts

    Posted 14 Sep Link to this post

    Hi Peter,

    Generally, you can hide particular labels with x-axis templates. You cannot, however, avoid plotting slots for  the weekends. Such a feature request has already been logged in the kendo uservoice portal, so that you can monitor, comment and raise its priority here - http://kendoui-feedback.telerik.com/forums/127393-kendo-ui-feedback/suggestions/12805008-remove-blank-dates-weekends-from-candle-stock-ch

    Regards,
    Danail Vasilev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Peter
    Peter avatar
    2 posts
    Member since:
    Aug 2013

    Posted 16 Sep Link to this post

    I wasn't trying to hide labels for weekends.  I wanted create a plotband on the weekends.  Is there a way to do this when you have dates on the x-axis?
  5. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1494 posts

    Posted 19 Sep Link to this post

    Hi Peter,

    This is a feature request that has already been logged here, so that you can monitor, comment and raise its priority by voting on it - http://feedback.telerik.com/Project/108/Feedback/Details/125916

    For the time being you can use the provided workaround.

    Regards,
    Danail Vasilev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top