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

Line series auto scale not working properkly

7 Answers 154 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Luigi Bardetti
Top achievements
Rank 1
Luigi Bardetti asked on 23 Dec 2015, 01:37 PM

hi,

i jave a chart with line series and it has a different behavior of the auto scale between 200 and 400 items (or more).

the first is loaded correctly and the first value shown in the Yaxis is 0.95 (see attached) but with 400 it starts form zero.

all items are all positive and greater than zero.

what configuration am i missing?

 RadHtmlChart chart = new RadHtmlChart { Transitions = true, Skin = "Bootstrap", CssClass = "plutochart" };
            chart.ID = "htmlChart";
            chart.Legend.Appearance.BackgroundColor = Color.White;
            chart.Legend.Appearance.Position = ChartLegendPosition.Bottom;
            chart.Legend.Appearance.TextStyle.Bold = false;
            chart.Legend.Appearance.TextStyle.FontFamily = "Helvetica";
            chart.Legend.Appearance.TextStyle.Italic = false;
            chart.Legend.Appearance.TextStyle.Color = Color.Black;
            chart.Legend.Appearance.TextStyle.FontSize = 12;
            chart.Legend.Appearance.TextStyle.Margin = "0";
            chart.Legend.Appearance.TextStyle.Padding = "10";

            chart.Appearance.FillStyle.BackgroundColor = Color.Transparent;
            
            chart.PlotArea.XAxis.TitleAppearance.Visible = false;
            chart.PlotArea.XAxis.LabelsAppearance.DataFormatString = LocalizeHelper.DateTimeFormat;
            chart.PlotArea.XAxis.MajorGridLines.Visible = false;
            chart.PlotArea.XAxis.MinorGridLines.Visible = false;

            /*
             * nell'ascisse ci stanno al max 9 label quindi devo calcolare il corretto Step
             */
            double gropu = (listCount / 9);
            int step = Convert.ToInt32(Math.Ceiling(gropu));
            chart.PlotArea.XAxis.LabelsAppearance.Step = step > 0 ? step : 1;
            chart.PlotArea.XAxis.LabelsAppearance.RotationAngle = -45;
            chart.PlotArea.YAxis.TitleAppearance.Text = string.Empty;
            chart.PlotArea.YAxis.TitleAppearance.TextStyle.Margin = "20";
            chart.PlotArea.YAxis.MinorGridLines.Visible = false;
            chart.PlotArea.YAxis.Type = HtmlChartValueAxisType.Numeric;
            chart.PlotArea.YAxis.LabelsAppearance.DataFormatString = LocalizeHelper.RoundDoubleDecimalsToString;

 

LineSeries itemSeries = new LineSeries { Name = quotationsTitle };
            itemSeries.LabelsAppearance.DataFormatString = LocalizeHelper.RoundDoubleDecimalsToString;
            itemSeries.LineAppearance.Width = 3;
            itemSeries.TooltipsAppearance.Color = Color.White;
            itemSeries.LabelsAppearance.Visible = false;
            itemSeries.MarkersAppearance.Visible = false;
            LineSeries minMaxLastSeries = new LineSeries { DataFieldY = "MinMaxLastQuoteDouble", Name = minMaxLastTitle };

chart.PlotArea.XAxis.DataLabelsField = "QuoteDateTime";
                    itemSeries.DataFieldY = "QuoteDouble";
                    itemSeries.TooltipsAppearance.ClientTemplate = @"#= kendo.format(\'{0:" + LocalizeHelper.RoundDoubleDecimalsToString + @"}\', dataItem.QuoteDouble) #
                                <br/>
                                #= dataItem.QuoteDateTimeToString #";

                    minMaxLastSeries.TooltipsAppearance.ClientTemplate = @"#= kendo.format(\'{0:" + LocalizeHelper.RoundDoubleDecimalsToString + @"}\', dataItem.MinMaxLastQuoteDouble) #
                                <br/>
                                #= dataItem.QuoteDateTimeToString #";

minMaxLastSeries.LineAppearance.Width = 5;
            minMaxLastSeries.LabelsAppearance.Visible = true;
            minMaxLastSeries.LabelsAppearance.DataFormatString = LocalizeHelper.RoundDoubleDecimalsToString;
            minMaxLastSeries.MarkersAppearance.Visible = true;
            minMaxLastSeries.MarkersAppearance.Size = 14;
            minMaxLastSeries.MarkersAppearance.BackgroundColor = Color.Teal;
            minMaxLastSeries.TooltipsAppearance.DataFormatString = LocalizeHelper.RoundDoubleDecimalsToString;
            minMaxLastSeries.MissingValues = MissingValuesBehavior.Gap;
            

            LineSeries averageQuoteSeries = new LineSeries { DataFieldY = "AverageValue", Name = averageValueTitle };
            averageQuoteSeries.LineAppearance.Width = 3;
            averageQuoteSeries.LabelsAppearance.Visible = false;
            averageQuoteSeries.LabelsAppearance.DataFormatString = LocalizeHelper.RoundDoubleDecimalsToString;
            averageQuoteSeries.Appearance.FillStyle.BackgroundColor = Color.FromArgb(250, 152, 25);
            averageQuoteSeries.MarkersAppearance.Visible = false;
            averageQuoteSeries.TooltipsAppearance.DataFormatString = LocalizeHelper.RoundDoubleDecimalsToString;

            itemSeries.MissingValues = MissingValuesBehavior.Interpolate;

            chart.PlotArea.Series.Add(itemSeries);
            chart.PlotArea.Series.Add(averageQuoteSeries);
            chart.PlotArea.Series.Add(minMaxLastSeries);

7 Answers, 1 is accepted

Sort by
0
Luigi Bardetti
Top achievements
Rank 1
answered on 23 Dec 2015, 01:38 PM
other question: is it possible to have some space in the right margin? see Capture_2_700 attached
0
Peter Filipov
Telerik team
answered on 25 Dec 2015, 02:20 PM
Hi Luigi,

Could you please open a support ticket and send us a runnable project where we could observer the issue.

Regards,
Peter Filipov
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
Luigi Bardetti
Top achievements
Rank 1
answered on 04 Jan 2016, 08:42 AM

Unfortunately the account is expired on 2015, and this forum page does not allow to upload zip files (500 KB).

How can i send you my project?

0
Luigi Bardetti
Top achievements
Rank 1
answered on 04 Jan 2016, 02:47 PM

ok , found by myself setting manually the min and max value

if (minValue > 0 && listCount > 10)
            {
                decimal? minValueaxe = (decimal?)(minValue - ((maxValue - minValue) / 10));
       
                if (maxValue - minValue > 1)
                {
                    chart.PlotArea.YAxis.MinValue = Math.Floor(minValueaxe.Value);
                    chart.PlotArea.YAxis.MaxValue = (decimal?)(maxValue + Math.Round(((maxValue - minValue) / 4)));
                }
                else
                {
                    chart.PlotArea.YAxis.MinValue = Math.Round(minValueaxe.Value, LocalizeHelper.RoundDoubleDecimals, MidpointRounding.ToEven);
                    chart.PlotArea.YAxis.MaxValue = (decimal?)(maxValue + Math.Round(((maxValue - minValue) / 4), LocalizeHelper.RoundDoubleDecimals, MidpointRounding.AwayFromZero));
                }
            }

but now i have an other question, how can i set the step in xaxis major grid ticks?

i set the

chart.PlotArea.XAxis.LabelsAppearance.Step = ...

but it did not solve it.

Note that in xaxis i have dynamic data like dates, years and nonths , it depends on the source.

 

 

 

 

0
Danail Vasilev
Telerik team
answered on 06 Jan 2016, 03:34 PM
Hi Luigi,

Please find my answers to your questions:
    - Place margin between starting and ending points. You can set the justified property. See details here - http://feedback.telerik.com/Project/108/Feedback/Details/63324
    - Sending a project. You can only attach projects only in support tickets. You can try to provide a link in the forum to a project location. You should, however, ensure to exclude the official Telerik .dll files.
     - Set a step for a date axis. Please refer to this article for details on the matter - http://docs.telerik.com/devtools/aspnet-ajax/controls/htmlchart/functionality/axes/date-axis-base-unit-steps

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
Luigi Bardetti
Top achievements
Rank 1
answered on 07 Jan 2016, 09:08 AM
  • i am using 2015.1.401.45
  • the script with chart.repaint did not work
  • the link you provided for the step axis refers to an older version, i have not "MaxDateGroups" or BaseUnit="Fit" (Fit is not in my list) properties.
  • My data in xaxis is dynamic, they are not only dates but they can be strings or integers.
  • you can download the project from here
    https://drive.google.com/folderview?id=0BzDGsD52rUrdbDA2SW9QV2dOcjQ&usp=sharing
0
Danail Vasilev
Telerik team
answered on 12 Jan 2016, 09:06 AM
Hi Luigi,

You can define the majorTicks.Step property. For example:

ASPX:
<form id="form1" runat="server">
    <telerik:RadScriptManager runat="server"></telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script>
            function pageLoad() {
                var chartID = $get("<%=hf1.ClientID%>").value;
                var kendoWidget = $find(chartID).get_kendoWidget();
                var majorTicksStep = kendoWidget.options.categoryAxis.labels.step;
                kendoWidget.options.categoryAxis.justified = false;
                kendoWidget.options.categoryAxis.majorTicks = { step: majorTicksStep };
                kendoWidget.redraw();
 
            }
        </script>
    </telerik:RadCodeBlock>
    <asp:HiddenField ID="hf1" runat="server" />
</form>
C#:
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
.....
                radHtmlChart.DataSource = itemViewModels;
                radHtmlChart.DataBind();
                hf1.Value = radHtmlChart.ClientID;
....
            }
        }


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
Luigi Bardetti
Top achievements
Rank 1
Answers by
Luigi Bardetti
Top achievements
Rank 1
Peter Filipov
Telerik team
Danail Vasilev
Telerik team
Share this question
or