We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Vertical StripLines on a DateTimeAxis

Is it possible? I can't figure out what start and width properties would be set to. 

7 Replies

DS Durgadevi Selvaraj Syncfusion Team May 22, 2017 11:30 AM UTC

Hi Rosanne,

Thanks for contacting Syncfusion Support.

We would like to inform you that, it is possible to set ChartStripline to the DateTimeAxis by converting the corresponding datetime value to the
double value as like in the below code snippet,
 
DateTimeAxis datetimeaxis = new DateTimeAxis(); 
datetimeaxis.LabelFormat = "MMM"; 
chart.PrimaryAxis = datetimeaxis;  
 
ChartStripLine stripline = new ChartStripLine(); 
stripline.Start = new DateTime(2010, 04, 01).ToOADate(); 
stripline.Width = 91; 
stripline.Background = new SolidColorBrush(Colors.LightBlue); 
stripline.Opacity = 0.8; 
stripline.Label = "Quarter 2"; 
datetimeaxis.StripLines.Add(stripline); 
 
 













  
  
  
  
  
  
Please find the output screenshot, 

We have prepared a demo sample for your reference and it can be downloaded from below link,
Sample: VerticalStripLine_DateTimeAxis

Regards,

Durgadevi S 





GI Gijs March 16, 2019 10:05 AM UTC

Hello, i was wondering how to do this in an asp.net core razor page.


MK Muneesh Kumar G Syncfusion Team March 18, 2019 04:54 AM UTC

Hi Rosanne, 
 
Thanks for your update.  
 
You can achieve this requirement in Asp.Net core by adding stripline to axis’s striplines collection as per the below code snippet.  
 
Code snippet 
<ejs-chart id="container" width="60%"> 
        <e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis> 
        <e-chart-axes> 
            <e-chart-axis name="yAxis" valueType="Category"> 
                <e-striplines> 
                    <e-stripline visible="true" start="20" end="30" color="red"></e-stripline> 
                </e-striplines> 
            </e-chart-axis> 
        </e-chart-axes> 
        <e-series-collection> 
            <e-series dataSource="ViewBag.dataSource" xName="x" yName="y" yAxisName="yAxis" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Column"></e-series> 
        </e-series-collection> 
    </ejs-chart> 
 
 
Online samples:  
 
Please let us know if you have any queries.  
 
Thanks, 
Muneesh Kumar G. 
 



GI Gijs March 18, 2019 12:38 PM UTC

Hello thanks for the quick response. Can you provide an example were the primaryxaxis is of valuetype DATETIME instead of CATEGORY?
The primaryxaxis constists of 70 hours and I want to draw stripline on a specific hour..

Best regards,
Gijs


DD Dharanidharan Dharmasivam Syncfusion Team March 19, 2019 11:36 AM UTC

Hi Rosanne, 
 
Thanks for the update. We have prepared a sample by rendering strip line with date time axis. Find the code snippet below to achieve this requirement and you can change this based on your requirement. 
 
 
<ejs-chart id="chartContainer" load="chartLoad"> 
    <e-chart-primaryxaxis valueType="DateTime"> 
        <e-primaryxaxis-striplines> 
            <e-primaryxaxis-stripline visible="true" text="Stripline" color="red"></e-primaryxaxis-stripline> 
        </e-primaryxaxis-striplines> 
    </e-chart-primaryxaxis> 
 </ejs-chart> 
 
function chartLoad(args) { 
        args.chart.primaryXAxis.stripLines[0].start = new Date(2019, 0, 4); 
        args.chart.primaryXAxis.stripLines[0].end = new Date(2019, 0, 5); 
    } 
 
 
Screenshot:  
 
 
 
Thanks, 
Dharani. 



PA Pat February 11, 2021 06:29 PM UTC

Whenever I try this approach I get the following error 

"System.ArgumentException: 'Object of type 'Syncfusion.EJ2.PivotView.PivotViewStripLine' cannot be converted to type 'Syncfusion.EJ2.Charts.ChartStripLine'.'"

This is our  XAxis markup

<e-chart-primaryxaxis edgeLabelPlacement="Shift" plotOffset="12" valueType="DateTime" interval="@Model.DateTimeAxisIntervalGrouping" intervalType="@Model.DateTimeAxisInterval" labelFormat="@Model.DateTimeAxisDateFormat" minimum="@Model.DateFrom" maximum="@Model.DateTo">
    <e-majorgridlines width="0"></e-majorgridlines>
    <e-primaryxaxis-striplines>
        <e-primaryxaxis-stripline visible="true" text="Stripline" color="red"></e-primaryxaxis-stripline>
    </e-primaryxaxis-striplines>
</e-chart-primaryxaxis>

What are we doing that is causing rhe control to think we are using a PivotViewStripLine?


SM Srihari Muthukaruppan Syncfusion Team February 12, 2021 05:03 AM UTC

Hi Pat, 
 
We have analyzed your query. From that, we would like to let you know that as of now it is not possible to achieve striplines through striplines tag. Hence we suggest you to use below solution in which we have added stripline in code behind to achieve your requirement. We have prepared a sample for your reference. Please find the sample and screenshot below. 
 
 
Screenshot: 
 
 
Let us know if you have any concerns. 
 
Regards, 
Srihari M 


Loader.
Live Chat Icon For mobile
Up arrow icon