<%@ Page Language="C#" %>
<%@ Register assembly="JQChart.Web" namespace="JQChart.Web.UI.WebControls" tagprefix="jqChart" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<link rel="stylesheet" type="text/css" href="~/Content/jquery.jqChart.css" />
<link rel="stylesheet" type="text/css" href="~/Content/themes/le-frog/jquery-ui-1.8.20.css" />
<script src="<% = ResolveUrl("~/Scripts/jquery-1.11.1.min.js") %>" type="text/javascript"></script>
<script src="<% = ResolveUrl("~/Scripts/jquery.jqChart.min.js") %>" type="text/javascript"></script>
</head>
<body>
<form runat="server">
<asp:ObjectDataSource ID="ObjectDataSource1"
runat="server"
SelectMethod="GetData"
TypeName="SamplesBrowser.Models.ScatterChartData"></asp:ObjectDataSource>
<jqChart:Chart ID="Chart1" Width="500px" Height="300px" runat="server" DataSourceID="ObjectDataSource1">
<Title Text="Scatter Chart"></Title>
<Animation Enabled="True" Duration="00:00:01" />
<Series>
<jqChart:ScatterSeries XValuesField="ValueX" YValuesField="ValueY1" Title="Scatter 1">
<Markers Visible="true" MarkerType="Diamond" Size="8"></Markers>
</jqChart:ScatterSeries>
<jqChart:ScatterSeries XValuesField="ValueX" YValuesField="ValueY2" Title="Scatter 2">
<Markers Visible="true" MarkerType="Rectangle" Size="8"></Markers>
</jqChart:ScatterSeries>
</Series>
</jqChart:Chart>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace SamplesBrowser.Models
{
public class ScatterChartData
{
public static List<ScatterChartData> GetRandom()
{
var data = new List<ScatterChartData>();
Random rnd = new Random();
for (var i = 0; i < 20; i++)
{
data.Add(new ScatterChartData(i, rnd.Next(0, 100)));
}
return data;
}
public static List<ScatterChartData> GetData()
{
var data = new List<ScatterChartData>();
Random rnd = new Random();
int yValue1 = 100;
int yValue2 = 20;
for (var i = 0; i < 20; i++)
{
yValue1 += (int)Math.Round(rnd.NextDouble() * 20 - 10);
yValue2 += (int)Math.Round(rnd.NextDouble() * 20 - 10);
data.Add(new ScatterChartData(i, yValue1, yValue2));
}
return data;
}
public static List<ScatterChartData> GetSplineScatterSampleData()
{
var data = new List<ScatterChartData>();
data.Add(new ScatterChartData(1, 46, 69));
data.Add(new ScatterChartData(2, 48, 57));
data.Add(new ScatterChartData(3, 68, 86));
data.Add(new ScatterChartData(4, 30, 70));
data.Add(new ScatterChartData(5, 55, 70));
data.Add(new ScatterChartData(6, 85, 60));
data.Add(new ScatterChartData(7, 43, 88));
data.Add(new ScatterChartData(8, 29, 60));
return data;
}
public ScatterChartData(double valueX, double valueY)
{
this.ValueX = valueX;
this.ValueY1 = valueY;
}
public ScatterChartData(double valueX, double valueY1, double valueY2)
{
this.ValueX = valueX;
this.ValueY1 = valueY1;
this.ValueY2 = valueY2;
}
public double ValueX { get; set; }
public double ValueY1 { get; set; }
public double ValueY2 { get; set; }
}
}