Fill one side of remainder of chart with extrapolated data

I have a chart that looks like this:




The markup is something like:


<SfChart>

    <ChartCrosshairSettings Enable="true" LineType="LineType.Vertical" />

    <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category" />

    <ChartPrimaryYAxis Minimum="40">

        <ChartStriplines>

            <ChartStripline Start="70" End="80" Color="#ff000022" />

            <ChartStripline Start="80" End="100" Color="#ff000044" />

        </ChartStriplines>

    </ChartPrimaryYAxis>

    <ChartSeriesCollection>

        @foreach (var series in DummyTemperatureData)

        {

            <ChartSeries DataSource="@series.Value" XName="Category" YName="Value" Type="ChartSeriesType.Spline" Name="@series.Key" />

        }

    </ChartSeriesCollection>

</SfChart>


One thing that's missing here is an extrapolation of previous values. Even though I'm not providing a temperature value for before 0:00:00, I want it to look as though I did. So, I want the left side (and ideally only the left side!) of the lines to keep going (until the left margin of the chart, i.e. the line of the Y axis), ideally perhaps as dashed lines.


It sounds a bit like "range padding" is what I'm looking for, but there's no visual example, and also not enough customization (can't do it only for the left side, and can't change the line shape). Is range padding even for this? Is there a different way of accomplishing this?






6 Replies 1 reply marked as answer

SK Soeren Kuklau replied to Soeren Kuklau June 18, 2021 01:22 PM UTC



Minor addendum:

It 
sounds a bit like "range padding" is what I'm looking for

OK, with this visual aid, I get now what range padding is. I do want that, but I also want that padded range to be filled with a dotted, extrapolated line, and only on the left side. Does that make sense?


SM Srihari Muthukaruppan Syncfusion Team June 21, 2021 12:08 PM UTC

Hi Soeren, 
 
Sorry for the inconvenience. 
 
We can add extra padding to the chart's axis by using RangePadding. We currently do not have support for drawing the dash array or extrapolated line in the absence of data. Because a spline series was used in the provided screenshot, calculating the exact y value to which the extrapolated line must be drawn is not possible. 
 
please let us know if we can use line series to meet your requirements, which will allow us to proceed with further analysis and provide you with a solution sooner.  
 
Regards, 
Srihari M 



SK Soeren Kuklau June 21, 2021 12:14 PM UTC

Hi Srihari,


would it be possible to define range padding separately for each side? It seems what I'm looking for is something like:


LeftRangePadding="None" RightRangePadding="Auto"


That way, it becomes visually clearer to the user that there is additional data on the left (from the past), but that the right does not continue, because it's in the future.



SM Srihari Muthukaruppan Syncfusion Team June 23, 2021 12:25 PM UTC

Hi Soeren, 

We can achieve your requirement by using labelPlacement as OnTicks and add empty point to the provided data as shown in the below code snippet. Please find the sample, code snippet and screenshot below. 

 
Code Snippet: 
// add your additional code here 
 
<SfChart ID="chart" Title="NC Weather Report - 2016" Theme="@Theme"> 
        <ChartArea><ChartAreaBorder Width="0"></ChartAreaBorder></ChartArea> 
        <ChartPrimaryXAxis LabelPlacement="Syncfusion.Blazor.Charts.LabelPlacement.OnTicks" ValueType="Syncfusion.Blazor.Charts.ValueType.Category"> 
            <ChartAxisMajorTickLines Width="0"></ChartAxisMajorTickLines> 
        </ChartPrimaryXAxis> 
 
// add your additional code here 
 
public List<SplineChartData> SplineData = new List<SplineChartData> 
    { 
        new SplineChartData { Days = "Sun", MaxTemp = 15, AvgTemp = 10, MinTemp = 2 }, 
        new SplineChartData { Days = "Mon", MaxTemp = 22, AvgTemp = 18, MinTemp = 12 }, 
        new SplineChartData { Days = "Tue", MaxTemp = 32, AvgTemp = 28, MinTemp = 22 }, 
        new SplineChartData { Days = "Wed", MaxTemp = 31, AvgTemp = 28, MinTemp = 23 }, 
        new SplineChartData { Days = "Thu", MaxTemp = 29, AvgTemp = 26, MinTemp = 19 }, 
        new SplineChartData { Days = "Fri", MaxTemp = 24, AvgTemp = 20, MinTemp = 13 }, 
        new SplineChartData { Days = "Sat", MaxTemp = 18, AvgTemp = 15, MinTemp = 8 }, 
         
    }; 
    protected override void OnInitialized() 
    { 
        SplineData.Add(new SplineChartData { Days = " ", MaxTemp = null, AvgTemp = null, MinTemp = null }); 
    } 
public class SplineChartData 
    { 
        public string Days { get; set; } 
        public double? MaxTemp { get; set; } 
        public double? AvgTemp { get; set; } 
        public double? MinTemp { get; set; } 
    } 
 
Screenshot: 
 
 
Let us know if you have any concerns. 

Regards, 
Srihari M 


Marked as answer

SK Soeren Kuklau June 24, 2021 10:48 AM UTC

Hello Srihari,


yes, I think I'm happier with that result. Thank you!


Regards,

Sören



SM Srihari Muthukaruppan Syncfusion Team June 25, 2021 04:25 AM UTC

Hi Soeren, 
 
Most welcome. 
 
Kindly get in touch with us, if you requires further assistance. We are always happy in assisting you.   
   
Thanks,   
Srihari 


Loader.
Up arrow icon