Home Forums Chart Support MVC Stacked Range Reply To: MVC Stacked Range

#42112

@dpanscik,

Please check out this gallery example for creating range bar chart in ASP.NET MVC. In order to add color to the datapoint, you can modify the DataPoint Model class to include color property as well as while creating DataPoint object include color required. Please take a look at the below code snippet for the same


/* DataPoint Model Class */
public DataPoint(string label, double[] y, string color)
{
  this.Label = label;
  this.Y = y;
  this.Color = color;
}

//Explicitly setting the name to be used while serializing to JSON.
[DataMember(Name = "label")]
public string Label = "";

//Explicitly setting the name to be used while serializing to JSON.
[DataMember(Name = "y")]
public double[] Y = null;

[DataMember(Name = "y")]
public string Color = null;
.
.
/* Controller */
dataPoints.Add(new DataPoint("Owl", new double[] { 200, 1200 }, "#369EAD"));
.
.

—-
Manoj Mohan
Team CanvasJS