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

[Solved] Coloring Markers

0 Answers 64 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lukas
Top achievements
Rank 1
Lukas asked on 05 Jan 2012, 04:51 PM
Hi guys

I'm trying to color Markers in a Scatterchart depending on its coordinates (see attachement). The best way I can figure is to store the color in the model, say "markerColor". But an Action like this, doesn't seem to work:
public void Markers(ChartMarkersBuilder builder)
{
    builder.Type(ChartMarkerShape.Circle);
    builder.Background("<#= dataItem.markerColor #>");
    builder.Border(2, "<#= dataItem.markerColor #>", ChartDashType.Solid);
    builder.Visible(true);
}
So I gave the model three different X/Y Properties, a pair for each color red, yellow and green. Then I drew three different series in a ScatterChart. 

@(Html.Telerik().Chart<FieldRisiko>()
  .Name("scatterMatrix")
  .Series(series =>
  {
    series.Scatter(typeof(RisikoManagementMatrix.Models.ViewModels.FieldRisiko),
                   "greenX", "greenY")
      .Labels(label)
      .Labels(true)
      .Markers(greenmarkers);
    series.Scatter(typeof(RisikoManagementMatrix.Models.ViewModels.FieldRisiko),
                   "yellowX", "yellowY")
      .Labels(label)
      .Labels(true)
      .Markers(yellowmarkers);
    series.Scatter(typeof(RisikoManagementMatrix.Models.ViewModels.FieldRisiko),
                   "redX", "redY")
      .Labels(label)
      .Labels(true)
      .Markers(redmarkers);
  })

But now each Object is drawn three times, once at the designated point and two times in the point 0/0, even if the other X/Y properties are null. (see Attachement).

Do I really have to make a Class for each Color i'd like to draw or is there another way to achieve this?

PS: I do already have the Code with the fixed bug to access the dataItem in a Template, i.e. in a Tooltip.

Thanks a lot.
Tags
Chart
Asked by
Lukas
Top achievements
Rank 1
Share this question
or