Variable Linear Gauge Range & Labels

4 posts, 2 answers
  1. Paul
    Paul avatar
    2 posts
    Member since:
    May 2013

    Posted 01 Aug 2013 Link to this post

    Can I define my own range and labels in the Linear Gauge?

    Controller:
    public ActionResult LinearGauge()
    {
    List<gaugeSetting> gaugeModel = new List<gaugeSetting>();

    gaugeModel.Add(new gaugeSetting { From = 1, To = 2, Color = "#000099", Label = "Requirements" });
    gaugeModel.Add(new gaugeSetting { From = 2, To = 3, Color = "#009900", Label = "Design" });
    gaugeModel.Add(new gaugeSetting { From = 3, To = 4, Color = "#ff0000", Label = "Development" });

    return View(gaugeModel)
    }

    View:

    @(Html.Kendo().LinearGauge()
    .Name("gauge")
    .Pointer(pointer => pointer
    .Value(2)
    .Shape(GaugeLinearPointerShape.Arrow)
    )
    .Scale(scale => scale
    .Vertical(false)
    .Labels(l =>
    {
    //Get the Labels from the Model
    })
    .MajorUnit(1)
    .MinorUnit(1)
    .Max(7)
    .Ranges(ranges =>
    {
    //Get the Ranges from the Model
    }
    )
    )
    .HtmlAttributes(new { style = "width:500px;" })
    )
  2. Answer
    Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2595 posts

    Posted 05 Aug 2013 Link to this post

    Hi Paul,

    In order to achieve this you could reach the Ranges field from your model in the lambda expression. For example: 

    .Ranges(ranges => {
       foreach (var range in Model.Ranges)
         {
          ranges.Add().From(range.From).To(range.To).Color(range.Color);
         }
    })

     
    Regards,
    Iliana Nikolova
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Paul
    Paul avatar
    2 posts
    Member since:
    May 2013

    Posted 05 Aug 2013 Link to this post

    Thanks Iliana.  How about the Labels?
  5. Answer
    Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2595 posts

    Posted 07 Aug 2013 Link to this post

    Hello Paul,

    I am afraid defying labels in Kendo UI Linear Gauge is not supported and there is no a suitable workaround I can suggest. Please accept my apologize for the inconvenience caused. 

    Regards,
    Iliana Nikolova
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready