This is a migrated thread and some comments may be shown as answers.

Secondary Axis without data series

4 Answers 89 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 02 Dec 2018, 06:16 PM

Hi,

I would like to add a secondary x-axis to my chart (having relative instead of absolute values) without a belonging data series. But I have problems to get this axis shown. With the following code, the axis is simlpy not shown:

// Secondary x-axis with percent values of current price
            LinearAxis horAx2 = new LinearAxis();
            horAx2.VerticalLocation = AxisVerticalLocation.Bottom;
            horAx2.Minimum = Math.Round(_minX / ulPrice, 4);
            horAx2.Maximum = Math.Round(_maxX / ulPrice, 4);
            horAx2.MajorStep = Math.Round(ulPrice * 0.03 / ulPrice, 4); // 0.05; // 1 Prozent gerundet //Convert.ToInt16(units)*10;
            horAx2.Font = new System.Drawing.Font("Ubuntu", 10F, System.Drawing.FontStyle.Bold);

 

Is it possible to a secondary axis without a complementay data series?

Thank you

4 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 03 Dec 2018, 08:38 AM
Hello Patrick,

In order to display multiple axes in RadChartView, you will need to have more than one series. A possible solution is to add a second series to the chart so that the second axis will be painted and later hide the data points of the series: 
foreach (var item in this.radChartView1.Series[1].Children)
{
    item.IsVisible = false;
}       

If it can fit your local setup, you can also consider using an annotation instead of a secondary axis: https://docs.telerik.com/devtools/winforms/controls/chartview/features/annotations/grid-line.

I hope this will help. Let me know if you need further assistance.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Patrick
Top achievements
Rank 1
answered on 03 Dec 2018, 06:31 PM

Hello,

thx for the reply. I tries somethijng similar even before going to the forum. I created another DataSeries (phantomLine) and gave it transparent as color. The behavoir of the chart then is really strange:

// Horizontal Axis
LinearAxis horAx = new LinearAxis();
horAx.Minimum = _minX; // minStrike
horAx.Maximum = _maxX;  //maxStrike
horAx.MajorStep = Math.Round((ulPrice * 0.03), 0);
horAx.Title = "Underlying Price";
horAx.Font = new System.Drawing.Font("Ubuntu", 10F, FontStyle.Bold);
 
// Secondary x-axis with percent values of current price
LinearAxis horAx2 = new LinearAxis();
horAx2.VerticalLocation = AxisVerticalLocation.Bottom;
horAx2.Minimum = Math.Round(_minX / ulPrice, 4);
horAx2.Maximum = Math.Round(_maxX / ulPrice, 4);
horAx2.Title = "Strike Moneyness";
horAx2.MajorStep = Math.Round(ulPrice * 0.03 / ulPrice, 4);
horAx2.Font = new System.Drawing.Font("Ubuntu", 10F, System.Drawing.FontStyle.Bold);
 
 
foreach (Line l in _drawnLines)
{
    ScatterLineSeries sls = l.sls;
    sls.PointSize = new SizeF(1, 1);
    sls.BorderColor = l.color;
    sls.ForeColor = l.color;
    sls.BackColor = l.color;
    sls.BorderWidth = 3;
    if (l.name == "DTE 0")
    {
        sls.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
    }
    else
    {
        sls.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
    }
    sls.LegendTitle = l.name;
 
    if (sls.Name == "phantomLine2")
    {
        sls.HorizontalAxis = horAx2;
    }
    else
    {
        sls.HorizontalAxis = horAx;
    }
 
    rcv.Series.Add(sls);
 
}
 
 
// Vertical Axis
LinearAxis verAx = rcv.Axes.Get<LinearAxis>(1); //.Axes.Get<LinearAxis>(1);
verAx.Minimum = _minY; // - 1000;
verAx.Maximum = _maxY; // + 1000;
verAx.Title = "P&L";
verAx.MajorStep = Math.Round(Math.Max(Math.Abs(_minY), Math.Abs(_maxY)) * 0.1, 0);
verAx.LabelFormat = "{0:N}";
verAx.Font = new System.Drawing.Font("Ubuntu", 10F, FontStyle.Bold);

 

This leads to an annoying graph which moves(!) in the upper direction AND still does not show the second x-axis (see pic1)...

 

To show you what I want: this is a similar task with a relativel similar code and it works fine:

LinearAxis horAx = new LinearAxis(); // radChartView1.Axes.Get<LinearAxis>(0);
            horAx.Minimum = minX;
            horAx.Maximum = maxX;
            horAx.MajorStep = Math.Round((ulPrice * 0.03), 2);
            horAx.Title = "Strike";
            horAx.Font = new System.Drawing.Font("Ubuntu", 12F, System.Drawing.FontStyle.Bold);
            ivCallRaw.HorizontalAxis = horAx;
            ivPutRaw.HorizontalAxis = horAx;
 
            LinearAxis horAx2 = new LinearAxis();
            horAx2.VerticalLocation = AxisVerticalLocation.Bottom;
            horAx2.Minimum = Math.Round(minX / ulPrice, 4);
            horAx2.Maximum = Math.Round(maxX / ulPrice, 4);
            horAx2.Title = "Strike Moneyness";
            horAx2.MajorStep = Math.Round(ulPrice * 0.03 / ulPrice, 4) ;
            horAx2.Font = new System.Drawing.Font("Ubuntu", 12F, System.Drawing.FontStyle.Bold);
            ivCallMoneyness.HorizontalAxis = horAx2;
 
            radChartView1.Series.Add(ivCallRaw);
            radChartView1.Series.Add(ivCallMoneyness);
            radChartView1.Series.Add(ivPutRaw);
             
 
            LinearAxis verAx = radChartView1.Axes.Get<LinearAxis>(1);
            verAx.Minimum = Math.Round(Math.Min(minCallIv, minPutIv), 0) - 2;
            verAx.Maximum = Math.Round(Math.Max(maxCallIv, maxPutIv), 0) + 2;
            verAx.Title = "Implied Volatility %";
            verAx.MajorStep = Math.Round(verAx.Maximum * 0.1, 0);
            verAx.LabelFormat = "{0:N}";
            verAx.Font = new System.Drawing.Font("Ubuntu", 12F, System.Drawing.FontStyle.Bold);

 

and this leads to this graph aka two x-axis (pic2)

 

I spend hours with this issue now and would really thankful for help, but also would like to mention that this functionality is not sufficiently documented. In the doc are very short three examples which do not help me regarding this. Is there another you could recommend me for issues like this. Nevertheless, for the short-term your help would be highly appreciated

Thank you

Patrick

 

0
Patrick
Top achievements
Rank 1
answered on 04 Dec 2018, 06:44 AM

Sorry for the typos.
And in the second to last sentence, I meant: Is there another more comprehensive documentation you could recommend me, please?

 

 

0
Hristo
Telerik team
answered on 04 Dec 2018, 10:48 AM
Hello Patrick,

I am sending my test project illustrating the suggested approach from my previous post. Please note that the desired behavior is not directly supported and each of the multiple axes needs to be associated with a series added to the chart. About the documentation, we have tried to explain and provide several examples demonstrating the intended use of the multiple axes.

In case you will be needing further assistance, please open a support ticket and send us your project so that we can test it on our end. I hope this will help.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ChartView
Asked by
Patrick
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Patrick
Top achievements
Rank 1
Share this question
or