<ejs-chart id="container">
<e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.DataSource" xName="Day" yName="Temperature" type="MultiColoredLine" pointColorMapping="Color" width="2"></e-series>
</e-series-collection>
</ejs-chart>
<style>
#container_Series_0_Point_3 {
stroke-dasharray: 5;
}
</style> |
...
public IActionResult Index()
{
List<ChartData> ChartLineData = new List<ChartData>();
ChartLineData.Add(new ChartData("Monday", 10, false));
ChartLineData.Add(new ChartData("Tuesday", 20, false));
ChartLineData.Add(new ChartData("Wednesday", 30, false));
ChartLineData.Add(new ChartData("Thursday", 40, true));
ChartLineData.Add(new ChartData("Friday", 50, false));
ViewBag.DataSource = ChartLineData;
return View();
}
...
public class ChartData
{
public string Day { get; set; }
public string Color { get; set; }
public int Temperature { get; set; }
public bool IsEstimate { get; set; }
public ChartData(string Day, int Temperature, bool IsEstimate)
{
this.Day = Day;
this.Temperature = Temperature;
this.IsEstimate = IsEstimate;
this.Color = IsEstimate ? "Green" : "Red";
}
} |
|
|
.......
public IActionResult Index()
{
List<ChartData> ChartLineData = new List<ChartData>();
ChartLineData.Add(new ChartData("Jan", 1000, 2000, 6, 14, false));
ChartLineData.Add(new ChartData("Feb", 2000, 1500, 22, 12, false));
ChartLineData.Add(new ChartData("Mar", 2200, 1000, 36, 15, false));
ChartLineData.Add(new ChartData("Apr", 1500, 500, 46, 25, true));
ChartLineData.Add(new ChartData("May", 2500, 1000, 56, 28, false));
ViewBag.dataSource = ChartLineData;
return View();
}
......
public class ChartData
{
public string month { get; set; }
public string color { get; set; }
public int powerUsage { get; set; }
public int powerUsage2 { get; set; }
public int highTemp { get; set; }
public int lowTemp { get; set; }
public bool IsEstimate { get; set; }
public ChartData(string month, int powerUsage, int powerUsage2, int highTemp, int lowTemp, bool IsEstimate)
{
this.month = month;
this.powerUsage = powerUsage;
this.powerUsage2 = powerUsage2;
this.highTemp = highTemp;
this.lowTemp = lowTemp;
this.IsEstimate = IsEstimate;
this.color = IsEstimate ? "Red" : "Blue";
}
}
........ |