Line Series Marker

4 posts, 0 answers
  1. Simon Channell
    Simon Channell avatar
    17 posts
    Member since:
    Mar 2004

    Posted 24 Apr 2014 Link to this post

    Is it possible to change line series marker colour dependant on value?
  2. Stamo Gochev
    Admin
    Stamo Gochev avatar
    157 posts

    Posted 29 Apr 2014 Link to this post

    Hi Simon ,

    Changing the color of the line series' markers can be achieved with the BackgroundColor property in the MarkersAppearance tag like this:
    <telerik:LineSeries>
        <MarkersAppearance BackgroundColor="Green" />
    </telerik:LineSeries>
    Of course, you need to check for a certain condition and apply the color accordingly. You can have a look at both our demo about Conditional Item Colorization and the help article on the same topic.

    Regards,
    Stamo Gochev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Simon Channell
    Simon Channell avatar
    17 posts
    Member since:
    Mar 2004

    Posted 19 May 2014 in reply to Stamo Gochev Link to this post

    My graph is set up in code behind

    Here is my code
    ​Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load



    Dim studentid2 As String
    Dim studentid3 As String
    Dim studentname As String
    Dim studentname2 As String
    Dim studentname3 As String





    Dim student_profile_personalDS As New System.Data.DataSet



    studentid2 = "SY122325"
    studentid3 = "SY122011"

    Dim studentds As New DataSet

    Dim studentds2 As New DataSet




    studentds = objstudent.getstudentpersonalprofile(studentid2)
    studentname = studentds.Tables(0).Rows(0).Item(3) & " " & studentds.Tables(0).Rows(0).Item(1)

    studentds2 = objstudent.getstudentpersonalprofile(studentid3)
    studentname2 = studentds2.Tables(0).Rows(0).Item(3) & " " & studentds2.Tables(0).Rows(0).Item(1)



    RadHtmlChart1.ChartTitle.Text = "Assessment Scores"
    RadHtmlChart1.Skin = "Office2007"




    RadHtmlChart1.PlotArea.YAxis.MinorGridLines.Visible = "false"

    RadHtmlChart1.PlotArea.YAxis.MaxValue = 180

    RadHtmlChart1.PlotArea.XAxis.MaxValue = 20

    RadHtmlChart1.PlotArea.XAxis.MinValue = 0

    RadHtmlChart1.PlotArea.XAxis.Step = 2





    Dim tbl As New DataTable()

    Dim col As New DataColumn("assessment_ref")

    col.DataType = GetType(String)

    tbl.Columns.Add(col)

    col = New DataColumn("assessment_title")

    col.DataType = GetType(String)

    tbl.Columns.Add(col)

    col = New DataColumn("mark")

    col.DataType = GetType(Double)

    tbl.Columns.Add(col)

    col = New DataColumn("grade")

    col.DataType = GetType(String)

    tbl.Columns.Add(col)


    Dim tbl1 As New DataTable()

    Dim col1 As New DataColumn("Method11")

    col1.DataType = GetType(String)

    tbl1.Columns.Add(col1)

    col1 = New DataColumn("Points1")

    col1.DataType = GetType(Double)

    tbl1.Columns.Add(col1)

    Dim tbl2 As New DataTable()

    Dim col2 As New DataColumn("assessment_ref")

    col2.DataType = GetType(String)

    tbl2.Columns.Add(col2)


    col2 = New DataColumn("assessment_title")

    col2.DataType = GetType(String)

    tbl2.Columns.Add(col2)

    col2 = New DataColumn("mark")

    col2.DataType = GetType(Double)

    tbl2.Columns.Add(col2)

    col2 = New DataColumn("grade")

    col2.DataType = GetType(String)

    tbl2.Columns.Add(col2)


    col2 = New DataColumn("Method2")

    col2.DataType = GetType(String)

    tbl2.Columns.Add(col2)

    col2 = New DataColumn("Points2")

    col2.DataType = GetType(Double)

    tbl2.Columns.Add(col2)


    Dim chartSeriestarget As New LineSeries
    chartSeriestarget.MarkersAppearance.MarkersType = HtmlChart.MarkersType.Circle
    chartSeriestarget.Appearance.FillStyle.BackgroundColor = Drawing.Color.Crimson
    chartSeriestarget.Name = "Target"
    chartSeriestarget.LabelsAppearance.Visible = False


    Dim markbookobj As New markbook


    Dim examobj As New examination
    Dim marksds As New DataSet
    Dim marksds2 As New DataSet
    Dim exams2ds As New DataSet
    Dim exams3ds As New DataSet

    marksds = markbookobj.get_student_marks(studentid2)
    marksds2 = markbookobj.get_student_marks(studentid3)

    exams3ds = examobj.getstudent_profile_examinationresults_by_yearnew(studentid3, "2012")



    If marksds.Tables.Count > 0 Then

    For x = 0 To marksds.Tables(0).Rows.Count - 1
    tbl.Rows.Add(New Object() {marksds.Tables(0).Rows(x).Item("assess_ref").ToString(), marksds.Tables(0).Rows(x).Item("exam_acad_assess_title").ToString(), marksds.Tables(0).Rows(x).Item("exam_acad_assess_sub_mark"), marksds.Tables(0).Rows(x).Item("exam_acad_assess_sub_grade")})

    Next
    End If


    If marksds2.Tables.Count > 0 Then
    For x = 0 To marksds2.Tables(0).Rows.Count - 1
    tbl2.Rows.Add(New Object() {marksds2.Tables(0).Rows(x).Item("assess_ref").ToString(), marksds2.Tables(0).Rows(x).Item("exam_acad_assess_title").ToString(), marksds2.Tables(0).Rows(x).Item("exam_acad_assess_sub_mark"), marksds2.Tables(0).Rows(x).Item("exam_acad_assess_sub_grade")})
    Next

    End If




    For x = 0 To 20
    Dim item0 As New CategorySeriesItem
    item0.Y = 80
    chartSeriestarget.SeriesItems.Add(item0)
    Next


    RadHtmlChart1.PlotArea.Series.Add(chartSeriestarget)

    If tbl.Rows.Count > 0 Then

    Dim dsNew As New DataSet
    dsNew.Tables.Add(tbl)

    Dim series1 As New LineSeries
    series1.Name = "Student 1"
    series1.MarkersAppearance.BorderColor = Drawing.Color.ForestGreen
    series1.Appearance.FillStyle.BackgroundColor = Drawing.Color.Gray
    series1.LabelsAppearance.Visible = False

    Dim series2 As New LineSeries
    series2.Name = "Student 2"
    series2.Appearance.FillStyle.BackgroundColor = System.Drawing.Color.Maroon
    series2.LabelsAppearance.Visible = False

    Dim dsNew2 As New DataSet
    dsNew2.Tables.Add(tbl2)


    Dim grade As String
    For Each dr As DataRow In dsNew.Tables(0).Rows
    Dim value As Double
    If dr("mark") Is System.DBNull.Value Then
    value = 0
    Else
    value = Convert.ToDouble(dr("mark").ToString())
    End If
    If dr("grade") Is System.DBNull.Value Then
    grade = ""
    Else
    grade = dr("grade")
    End If
    Dim item1 As New CategorySeriesItem(value)
    item1.Y = value

    Select Case grade
    Case "A"
    item1.BackgroundColor = Drawing.Color.Green

    Case "B"
    item1.BackgroundColor = Drawing.Color.Gray


    Case "C"
    item1.BackgroundColor = Drawing.Color.DarkOrange


    Case Else
    item1.BackgroundColor = Drawing.Color.Red

    End Select



    series1.SeriesItems.Add(item1)

    Next

    series1.Name = studentname
    series1.TooltipsAppearance.DataFormatString = series1.Name
    RadHtmlChart1.PlotArea.Series.Add(series1)

    If tbl2.Rows.Count > 0 Then
    For Each dr1 As DataRow In dsNew2.Tables(0).Rows
    Dim value As Double
    If dr1("mark") Is System.DBNull.Value Then
    value = 0
    Else
    value = Convert.ToDouble(dr1("mark").ToString())
    End If
    If dr1("grade") Is System.DBNull.Value Then
    grade = ""
    Else
    grade = dr1("grade")
    End If
    Dim item2 As New CategorySeriesItem(value)
    item2.Y = value

    Select Case grade
    Case "A"
    item2.BackgroundColor = Drawing.Color.LightGreen

    Case "B"
    item2.BackgroundColor = Drawing.Color.Gray
    Case "C"
    item2.BackgroundColor = Drawing.Color.DarkOrange

    Case Else
    item2.BackgroundColor = Drawing.Color.Red

    End Select


    series2.SeriesItems.Add(item2)
    Next

    End If
    series2.Name = studentname2
    RadHtmlChart1.PlotArea.Series.Add(series2)
    End If




    End Sub

    I need to know how to make the markers go Green for Grade A or Grey for Grade B
  5. Simon Channell
    Simon Channell avatar
    17 posts
    Member since:
    Mar 2004

    Posted 20 May 2014 in reply to Simon Channell Link to this post

    it's ok I figured out if you remove these 2 lines it works and the markers change colour according to the grade

    ​series1.MarkersAppearance.BorderColor = Drawing.Color.ForestGreen
    series1.Appearance.FillStyle.BackgroundColor = Drawing.Color.Gray
Back to Top