This is a migrated thread and some comments may be shown as answers.
Variable Linear Gauge Range & Labels
3 Answers 44 Views
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 01 Aug 2013, 09:21 PM
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;" })
)

3 Answers, 1 is accepted

Sort by
0
Accepted
Iliana Nikolova
Telerik team
answered on 05 Aug 2013, 06:22 PM
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!
0
Paul
Top achievements
Rank 1
answered on 05 Aug 2013, 09:16 PM
Thanks Iliana.  How about the Labels?
0
Accepted
Iliana Nikolova
Telerik team
answered on 07 Aug 2013, 03:06 PM
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!
Asked by
Paul
Top achievements
Rank 1
Answers by
Iliana Nikolova
Telerik team
Paul
Top achievements
Rank 1
Share this question
or