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

RadHtmlChart set Xaxis Min Value C#

7 Answers 161 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Charlie
Top achievements
Rank 1
Charlie asked on 14 May 2015, 06:39 AM

Hi I am having problems with a RadHtmlChart I am using within an Asp page. It is a scatter chart which the data is applied to in the code behind. This all works correctly and plots fine the problem I am having is with trying to set the Min Value on the Xaxis. As I am using date ranges to decrease the amounts of data the chart shows the minimum value on the Xaxis changes so I would like the chart to start at the minimum value + 5. If I set the minimum value for the Xaxis within the configuration wizard this works fine but isn't dynamic enough for what I need. So I am trying in the code behind using the below code:

PcrInfeasPlot.PlotArea.XAxis.MinValue = lowestValue - 5;

This assigns the value correctly as I have checked the value in the debugger but the chart never reflects this change. How would I go about changing the minimum value so that I can see more on the chart.

 

Regards,

 

Charlie

7 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 18 May 2015, 06:34 AM
Hi Charlie,

I am not sure if I correctly understand what is your requirement about the chart. I can suggest that you provide a small fully runnable sample as well as snapshots of the actual and the expected behavior of the chart, so that I can provide a reliable solution if possible.

Regards,
Danail Vasilev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Charlie
Top achievements
Rank 1
answered on 18 May 2015, 06:50 AM

Sorry I know it is a bit difficult to explain in text. I have attached a screenshot of the chart at the moment. What I would like is for the graph to start when the data starts not at zero on the x-axis. Below is the code I used to populate the chart. The code below is in a method and I call the method on a date changed event of a calendar which modifys the data selected in the sqldatasource (sqlPcrInfeasLead)

 

01.List<Tuple<int, int>> low = new List<Tuple<int, int>>();
02.List<Tuple<int, int>> med = new List<Tuple<int, int>>();
03.List<Tuple<int, int>> high = new List<Tuple<int, int>>();
04.List<Tuple<int, int>> vhigh = new List<Tuple<int, int>>();
05.DataView dv = (DataView)sqlPcrInfeasLead.Select(DataSourceSelectArguments.Empty);
06.int lowestPCR = 100000;
07.int lowestScore = -10000;
08.foreach (DataRowView drv in dv)
09.{
10.        int pcr = (Convert.ToInt32(drv[0]));
11.        int infeas = Convert.ToInt32(drv[2]);
12.        int complex = Convert.ToInt32(drv[1]);
13.        Tuple<int, int> tuple = new Tuple<int, int>(pcr, infeas);
14.        if (pcr < lowestPCR)
15.        {
16.               lowestPCR = pcr;
17.        }
18.        if (infeas > lowestScore)
19.        {
20.              lowestScore = infeas;
21.        }
22.        if (complex == 1)
23.        {
24.               low.Add(tuple); 
25.        }
26.        else if (complex == 2)
27.        {
28.               med.Add(tuple);
29.        }
30.        else if (complex == 3)
31.        {
32.               high.Add(tuple);
33.        }
34.        else
35.        {
36.               vhigh.Add(tuple);
37.        }
38.}
39.  
40.List<List<Tuple<int, int>>> list = new List<List<Tuple<int, int>>>();
41.list.Add(low);
42.list.Add(med);
43.list.Add(high);
44.list.Add(vhigh);
45.int i = 0;
46.foreach (List<Tuple<int, int>> item in list)
47.{
48.        foreach (Tuple<int, int> item1 in item)
49.        {
50.                Telerik.Web.UI.SeriesItem sItem = new Telerik.Web.UI.SeriesItem();
51.                sItem.XValue = item1.Item1;
52.                sItem.YValue = item1.Item2;
53.                PcrInfeasPlot.PlotArea.Series[i].Items.Add(sItem);                    
54.        }
55.        i++;
56.}
57.PcrInfeasPlot.PlotArea.XAxis.MinValue = lowestPCR - 5;

0
Danail Vasilev
Telerik team
answered on 19 May 2015, 06:39 AM
Hi Charlie,

I have tried to reproduce the mentioned issue by using similar values for the scatter chart but the chart axes are properly resized on my side. The chart below renders like this - http://screencast.com/t/kGvMG03gSG

<telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="600" Height="400">
    <PlotArea>
        <Series>
            <telerik:ScatterSeries>
                <SeriesItems>
                    <telerik:ScatterSeriesItem Y="-20" X="80" />
                    <telerik:ScatterSeriesItem Y="-80" X="90" />
                    <telerik:ScatterSeriesItem Y="-160" X="100" />
                </SeriesItems>
            </telerik:ScatterSeries>
        </Series>
    </PlotArea>
</telerik:RadHtmlChart>

I can suggest that you try the following:
   - If you are not using latest Telerik UI (2015.1.401 version), does upgrading to it helps?
   - You can manually find the min and the max values of the axis and set them. This can also be done the client-side.
   - We have also an idea to implement xAxis.narroRange property for the upcoming Q2 2015 release, so that if everything is fine it will be ready for this release.

Regards,
Danail Vasilev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mike Barraclough
Top achievements
Rank 1
answered on 15 Oct 2015, 10:18 PM

I am curious as to how to set the minimum value on the client.  I have occasions when I do chart.set_dataSource(...) for data retrieved via Ajax, and I want to force the minimum to zero.

I get the valueAxis via

var myAxis = kendoChart.options.valueAxis,  but I do not see minimum as an exposed property.

How would I do this?

 

0
Danail Vasilev
Telerik team
answered on 20 Oct 2015, 08:03 AM
Hello Mike,

Numeric series like scatter and scatterline use yAxis and xAxis client-side objects for its y and x axes. For example, in order to change the max for the x-axis of a scatterline series in this demo (http://demos.telerik.com/aspnet-ajax/htmlchart/examples/charttypes/scatterlinechart/defaultcs.aspx) you can execute the following code in the browser console:

$find('ctl00_ContentPlaceholder1_ScatterLineChart').get_kendoWidget().options.xAxis.max = 110;
$find('ctl00_ContentPlaceholder1_ScatterLineChart').get_kendoWidget().redraw();


Regards,
Danail Vasilev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mike Barraclough
Top achievements
Rank 1
answered on 20 Oct 2015, 04:25 PM

I am using LineSeries, not ScatterLineSeries.

I did as you suggested and accessed the yAxis; the min is an exposed property.  However, when I set the min to 0 and redraw, it has no effect.

Should I open a support ticket?

 

0
Danail Vasilev
Telerik team
answered on 21 Oct 2015, 08:31 AM
Hello Mike,

To reference axes in category series you should use valueAxis (y-axis) and categoryAxis (x-axis) objects. For example you can try the following code with this demo (http://demos.telerik.com/aspnet-ajax/htmlchart/examples/charttypes/linechart/defaultcs.aspx):

$find('ctl00_ContentPlaceholder1_LineChart').get_kendoWidget().options.valueAxis.min = 50;
$find('ctl00_ContentPlaceholder1_LineChart').get_kendoWidget().redraw();

Regarding the forum threads/support tickets - support tickets have 24-hour maximum lead time for each response Mon-Fri, excluding public holidays. More information on the matter is available here - http://www.telerik.com/purchase/support-plans/devtools. Although we do not officially guarantee a response in a forum thread we try to answer them when possible. That being said if you need a faster answer you can open a support ticket, which however, requires a subscription.

Regards,
Danail Vasilev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart (HTML5)
Asked by
Charlie
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Charlie
Top achievements
Rank 1
Mike Barraclough
Top achievements
Rank 1
Share this question
or