Gallery
JS Circular Marker Slider
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dnc" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Demonstrates an interactive gauge with axis line breaks and a data point on top of the axis line.
Chart.Size = "400x380";
Chart.TempDirectory = "temp";
Chart.Type = ChartType.Gauges;
Chart.DefaultSeries.GaugeType = GaugeType.CircularBars;
Chart.Debug = false;
Chart.Palette = new Color[] { };
Chart.LegendBox.Visible = false;
Chart.JS.Enabled = true;
Chart.JS.RenderCallback = "startPlaying";
Chart.JS.ControlID = "chart";
Chart.JS.RenderCallback = "updateChart";
//Specifies animation duration for all animatios.
Chart.JS.InitialAnimationDuration = 0;
Chart.DefaultSeries.LegendEntry.Visible = false;
Chart.DefaultElement.Marker.Size = 30;
Chart.DefaultElement.Marker.Color = ColorTranslator.FromHtml("#77E6B4");
//Used to position marker on top of axis line.
Chart.JS.Settings.Add("xAxis_scale_range", "[0,1]");
Chart.JS.Settings.Add("defaultPoint_marker_fill", "white");
Chart.JS.Settings.Add("defaultPoint_marker_outline_width", "10");
Chart.JS.Settings.Add("defaultPoint_marker_type", "circle");
Chart.JS.Settings.Add("defaultPoint_marker_size", "30");
Chart.JS.Settings.Add("defaultPoint_marker_outline_color", "currentColor");
Chart.YAxis.ScaleRange = new ScaleRange(0, 100);
Chart.YAxis.Interval = 10;
Chart.YAxis.LineBreaks.Enabled = true;
Chart.YAxis.LineBreaks.Gap = 0.03;
Chart.YAxis.TickLabelPadding = 13;
Chart.YAxis.Line.Width = 15;
Chart.YAxis.DefaultTick.Label.Text = "%Value";
Chart.YAxis.DefaultTick.Label.Font = new Font("Arial", 12);
Chart.YAxis.ExtraTicks.Add(new AxisTick(10,""));
Chart.YAxis.ExtraTicks.Add(new AxisTick(30,""));
Chart.YAxis.ExtraTicks.Add(new AxisTick(50,""));
Chart.YAxis.ExtraTicks.Add(new AxisTick(70,""));
Chart.YAxis.ExtraTicks.Add(new AxisTick(90,""));
Chart.JS.Settings.Add("yAxis.line.color", "smartPalette");
Chart.JS.Settings.Add("palette_ranges", "js:ranges");
Chart.JS.Settings.Add("palette_pointValue", "%yValue");
Chart.JS.Settings.Add("defaultSeries_opacity", "1");
Chart.JS.Settings.Add("defaultSeries_mouseTracking_enabled", "false");
Chart.JS.Settings.Add("toolbar_items_slider_type", "range");
Chart.JS.Settings.Add("toolbar_items_slider_margin", "20");
Chart.JS.Settings.Add("toolbar_items_slider_width", "300");
Chart.JS.Settings.Add("toolbar_items_slider_height", "20");
Chart.JS.Settings.Add("toolbar_items_slider_events_change", "js:moveSlider");
Chart.JS.Settings.Add("toolbar_items_slider_position", "top");
Chart.JS.Settings.Add("toolbar_items_slider_min", "js:0");
Chart.JS.Settings.Add("toolbar_items_slider_max", "js:100");
Chart.JS.Settings.Add("toolbar_items_slider_value", "js:58");
Annotation an = new Annotation();
an.Label.Text = "0%";
an.ClearColors();
an.Label.Font = new Font("Arial", 13);
an.Position = new Point(9, 11);
Chart.Annotations.Add(an);
an = new Annotation();
an.Label.Text = "100%";
an.ClearColors();
an.Label.Font = new Font("Arial", 13);
an.Position = new Point(339, 11);
Chart.Annotations.Add(an);
// *DYNAMIC DATA NOTE*
// This sample uses random data to populate the chart. To populate
// a chart with database data see the following resources:
// - Use the getLiveData() method using the dataEngine to query a database.
// - Help File > Getting Started > Data Tutorials
// - DataEngine Class in the help file
// - Sample: features/DataEngine.aspx
// Add the random data.
Chart.SeriesCollection.Add(getData());
}
Series getData()
{
SeriesCollection sc = new SeriesCollection();
Series series = new Series();
series.Type = SeriesType.Marker;
series.Name = "score";
dotnetCHARTING.Label label1 = new dotnetCHARTING.Label();
//label1.Text = "js:labelText(50)";
label1.LineAlignment = StringAlignment.Center;
label1.Font = new Font("Arial", 48);
series.ShapeLabels.Add(label1);
Element el = new Element();
el.YValue = 50;
series.Elements.Add(el);
return series;
}
SeriesCollection getLiveData()
{
DataEngine de = new DataEngine(ConfigurationManager.AppSettings["DNCConnectionString"]);
de.ChartObject = Chart; // Necessary to view any errors the dataEngine may throw.
de.SqlStatement = "SELECT XAxisColumn, YAxisColumn FROM ....";
return de.GetSeries();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script type="text/javascript">
var chart;
var ranges = [
{ value: [0, 30], color: '#FF5353' },
{ value: [30, 70], color: '#FFD221' },
{ value: [70, 100], color: '#77E6B4' }
];
function updateChart(chrt) {
chrt = chart || chrt;
var series = chrt.series(0);
series.options({ shape_label_text: labelText(series) });
series.points(0).options({ y: 58 });
}
function startPlaying(chrt) {
chart = chrt;
}
function moveSlider(val) {
// Update chart title and points. The then: cb update option will execute the callback once the animation is finished.
chart
.series(0)
.points(0)
.options({ y: Math.round(val * 10) / 10 });
}
function labelText(series) {
var value = series.points(0).options('y'),
fgg = value >= 70 ? 'Great!' : value >= 30 ? 'Good' : 'Fair';
return '%sum%<br/><span style="fontSize: 32px">' + fgg + '</span>';
}
</script>
</head>
<body>
<div align="center">
<dnc:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
<%@ Page Language="vb" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dnc" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Demonstrates an interactive gauge with axis line breaks and a data point on top of the axis line.
Chart.Size = "400x380"
Chart.TempDirectory = "temp"
Chart.Type = ChartType.Gauges
Chart.DefaultSeries.GaugeType = GaugeType.CircularBars
Chart.Debug = False
Chart.Palette = New Color() { }
Chart.LegendBox.Visible = False
Chart.JS.Enabled = True
Chart.JS.RenderCallback = "startPlaying"
Chart.JS.ControlID = "chart"
Chart.JS.RenderCallback = "updateChart"
'Specifies animation duration for all animatios.
Chart.JS.InitialAnimationDuration = 0
Chart.DefaultSeries.LegendEntry.Visible = False
Chart.DefaultElement.Marker.Size = 30
Chart.DefaultElement.Marker.Color = ColorTranslator.FromHtml("#77E6B4")
'Used to position marker on top of axis line.
Chart.JS.Settings.Add("xAxis_scale_range", "[0,1]")
Chart.JS.Settings.Add("defaultPoint_marker_fill", "white")
Chart.JS.Settings.Add("defaultPoint_marker_outline_width", "10")
Chart.JS.Settings.Add("defaultPoint_marker_type", "circle")
Chart.JS.Settings.Add("defaultPoint_marker_size", "30")
Chart.JS.Settings.Add("defaultPoint_marker_outline_color", "currentColor")
Chart.YAxis.ScaleRange = New ScaleRange(0, 100)
Chart.YAxis.Interval = 10
Chart.YAxis.LineBreaks.Enabled = True
Chart.YAxis.LineBreaks.Gap = 0.03
Chart.YAxis.TickLabelPadding = 13
Chart.YAxis.Line.Width = 15
Chart.YAxis.DefaultTick.Label.Text = "%Value"
Chart.YAxis.DefaultTick.Label.Font = New Font("Arial", 12)
Chart.YAxis.ExtraTicks.Add(New AxisTick(10,""))
Chart.YAxis.ExtraTicks.Add(New AxisTick(30,""))
Chart.YAxis.ExtraTicks.Add(New AxisTick(50,""))
Chart.YAxis.ExtraTicks.Add(New AxisTick(70,""))
Chart.YAxis.ExtraTicks.Add(New AxisTick(90,""))
Chart.JS.Settings.Add("yAxis.line.color", "smartPalette")
Chart.JS.Settings.Add("palette_ranges", "js:ranges")
Chart.JS.Settings.Add("palette_pointValue", "%yValue")
Chart.JS.Settings.Add("defaultSeries_opacity", "1")
Chart.JS.Settings.Add("defaultSeries_mouseTracking_enabled", "false")
Chart.JS.Settings.Add("toolbar_items_slider_type", "range")
Chart.JS.Settings.Add("toolbar_items_slider_margin", "20")
Chart.JS.Settings.Add("toolbar_items_slider_width", "300")
Chart.JS.Settings.Add("toolbar_items_slider_height", "20")
Chart.JS.Settings.Add("toolbar_items_slider_events_change", "js:moveSlider")
Chart.JS.Settings.Add("toolbar_items_slider_position", "top")
Chart.JS.Settings.Add("toolbar_items_slider_min", "js:0")
Chart.JS.Settings.Add("toolbar_items_slider_max", "js:100")
Chart.JS.Settings.Add("toolbar_items_slider_value", "js:58")
Dim an As Annotation = New Annotation()
an.Label.Text = "0%"
an.ClearColors()
an.Label.Font = New Font("Arial", 13)
an.Position = New Point(9, 11)
Chart.Annotations.Add(an)
an = New Annotation()
an.Label.Text = "100%"
an.ClearColors()
an.Label.Font = New Font("Arial", 13)
an.Position = New Point(339, 11)
Chart.Annotations.Add(an)
' *DYNAMIC DATA NOTE*
' This sample uses random data to populate the chart. To populate
' a chart with database data see the following resources:
' - Use the getLiveData() method using the dataEngine to query a database.
' - Help File > Getting Started > Data Tutorials
' - DataEngine Class in the help file
' - Sample: features/DataEngine.aspx
' Add the random data.
Chart.SeriesCollection.Add(getData())
End Sub
Function getData() As Series
Dim sc As SeriesCollection = New SeriesCollection()
Dim series As Series = New Series()
series.Type = SeriesType.Marker
series.Name = "score"
Dim label1 As dotnetCHARTING.Label = New dotnetCHARTING.Label()
'label1.Text = "js:labelText(50)";
label1.LineAlignment = StringAlignment.Center
label1.Font = New Font("Arial", 48)
series.ShapeLabels.Add(label1)
Dim el As Element = New Element()
el.YValue = 50
series.Elements.Add(el)
Return series
End Function
Function getLiveData() As SeriesCollection
Dim de As DataEngine = New DataEngine(ConfigurationManager.AppSettings("DNCConnectionString"))
de.ChartObject = Chart ' Necessary to view any errors the dataEngine may throw.
de.SqlStatement = "SELECT XAxisColumn, YAxisColumn FROM ...."
Return de.GetSeries()
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script type="text/javascript">
var chart;
var ranges = [
{ value: [0, 30], color: '#FF5353' },
{ value: [30, 70], color: '#FFD221' },
{ value: [70, 100], color: '#77E6B4' }
];
function updateChart(chrt) {
chrt = chart || chrt;
var series = chrt.series(0);
series.options({ shape_label_text: labelText(series) });
series.points(0).options({ y: 58 });
}
function startPlaying(chrt) {
chart = chrt;
}
function moveSlider(val) {
// Update chart title and points. The then: cb update option will execute the callback once the animation is finished.
chart
.series(0)
.points(0)
.options({ y: Math.round(val * 10) / 10 });
}
function labelText(series) {
var value = series.points(0).options('y'),
fgg = value >= 70 ? 'Great!' : value >= 30 ? 'Good' : 'Fair';
return '%sum%<br/><span style="fontSize: 32px">' + fgg + '</span>';
}
</script>
</head>
<body>
<div align="center">
<dnc:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
- Sample FilenameJsCircularMarkerSlider.aspx
- Version10.3
- Uses DatabaseNo