本文整理汇总了C#中DotNet.Highcharts.Highcharts类的典型用法代码示例。如果您正苦于以下问题:C# Highcharts类的具体用法?C# Highcharts怎么用?C# Highcharts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Highcharts类属于DotNet.Highcharts命名空间,在下文中一共展示了Highcharts类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAnswersPerDayChart
public Highcharts CreateAnswersPerDayChart(string chartName)
{
var data = _dataSource.GetAnswersPerDay(_userTimeZone, _fakeTodayDate);
var chart = new Highcharts(chartName)
.InitChart(new Chart {DefaultSeriesType = ChartTypes.Spline})
.SetOptions(new GlobalOptions {Global = new Global {UseUTC = false}})
.SetTitle(new Title {Text = "Answers per day"})
.SetXAxis(new XAxis
{
Type = AxisTypes.Datetime,
DateTimeLabelFormats = new DateTimeLabel {Month = "%e. %B", Year = "%b", Day = "%A, %e. %B"}
})
.SetYAxis(new YAxis
{
Title = new YAxisTitle {Text = "Number of answers"},
Min = 0
})
.SetTooltip(new Tooltip
{
Formatter =
"function() { return '<b>'+ this.series.name +'</b><br/>'+ Highcharts.dateFormat('%A, %e. %B', this.x) +': '+ this.y +''; }"
})
.SetSeries(new[]
{
CreateDateCountSeries(data, "Begrijpend Lezen"),
CreateDateCountSeries(data, "Rekenen"),
CreateDateCountSeries(data, "Spelling")
});
return chart;
}
示例2: ConstructChart
public static Highcharts ConstructChart(Dictionary<int, double> dataToDisplay, string chartTitle,string chartDescription)
{
var title = new Title() { Text = chartTitle };
var subtitle = new Subtitle() { Text = chartDescription };
var XData = dataToDisplay.Keys.ToList().ConvertAll(x => Convert.ToString(x)).ToArray();
var YData = dataToDisplay.Values;
var xaxisTitle = new XAxisTitle { Text = "X" };
var yaxisTitle = new YAxisTitle { Text = "Y" };
Highcharts chart = new Highcharts("Chart")
.SetTitle(title)
.SetSubtitle(subtitle)
.SetXAxis(new XAxis
{
Categories = XData,
Title = xaxisTitle,
LineWidth = 0
})
.SetYAxis(new YAxis
{
Title = yaxisTitle,
LineWidth = 0
})
.SetSeries(new Series
{
Data = new Data(YData.OfType<object>().ToArray()),
});
return chart;
}
示例3: AllGoalsByMonthNet
public string AllGoalsByMonthNet()
{
var now = DateTime.Now;
var currentMonth = new DateTime(now.Year, now.Month, 1);
var startDate = currentMonth.AddYears(-1);
var highchart = new Highcharts("AllGoalsMonth");
var chart = new Chart()
{
Type = ChartTypes.Column
};
highchart.InitChart(chart);
highchart.SetTitle(new Title() {Text = "Goals by Month"});
var yaxis = new YAxis {Max = 2};
highchart.SetYAxis(yaxis);
var series = new Series {Name = "Steps"};
var xaxis = new XAxis();
var categories = new List<string>();
var data = new List<object>();
for (var i = startDate; i <= currentMonth; i = i.AddMonths(1))
{
categories.Add(i.Month.ToString() + "-" + i.Year.ToString());
data.Add(pedometerCalcService.MonthPct(i.Month, i.Year));
}
xaxis.Categories = categories.ToArray();
series.Data = new Data(data.ToArray());
highchart.SetXAxis(xaxis);
highchart.SetSeries(series);
return highchart.ToHtmlString();
}
示例4: CurrentMonthGoalProgressNet
public string CurrentMonthGoalProgressNet()
{
var now = DateTime.Now;
var daysInMonth = DateTime.DaysInMonth(now.Year, now.Month);
var expectedPct = ((decimal)now.Day / daysInMonth);
var remainingDays = daysInMonth - now.Day;
var stepsPR = pedometerCalcService.StepsPR();
var remainingSteps = (int) (stepsPR-pedometerCalcService.MonthStepsActual())/remainingDays;
var highchart = new Highcharts("CurrentMonthGoal");
var chart = new Chart() {Type = ChartTypes.Bar};
var categories = new List<string> {"Steps"};
var yaxis = new YAxis {Max = 1};
var seriesArray = new List<Series>();
var series = new Series {Name = "Expected",Color = Color.Red};
var data = new List<object> {pedometerCalcService.MonthPctExpected(now)};
var plotoptions = new PlotOptionsBar
{
Grouping = false,
Shadow = false,
DataLabels = new PlotOptionsBarDataLabels()
{
Enabled = false,
Format = string.Format("Expected: {0}", (int) (stepsPR*expectedPct)),
Color = Color.White
}
};
series.Data = new Data(data.ToArray());
series.PlotOptionsBar = plotoptions;
seriesArray.Add(series);
series = new Series {Name = "Actual", Color = Color.Green};
data = new List<object> { pedometerCalcService.MonthPct(now.Month, now.Year) };
plotoptions = new PlotOptionsBar
{
Grouping = false,
Shadow = false,
DataLabels = new PlotOptionsBarDataLabels()
{
Enabled = true,
Format = string.Format("Remaining: {0}/day", remainingSteps),
Color = Color.White,
Shadow = false
}
};
series.Data = new Data(data.ToArray());
series.PlotOptionsBar = plotoptions;
seriesArray.Add(series);
highchart.InitChart(chart);
highchart.SetTitle(new Title() {Text = "Month Progress"});
highchart.SetXAxis(new XAxis() {Categories = categories.ToArray()});
highchart.SetYAxis(yaxis);
highchart.SetSeries(seriesArray.ToArray());
highchart.SetTooltip(new Tooltip() {Enabled = false});
return highchart.ToHtmlString();
}
示例5: ComparisonViewModel
public ComparisonViewModel(Highcharts chart)
{
NumberOfQueries = 4;
Chart = chart;
FirstIndex = IndexEnum.gist;
SecondIndex = IndexEnum.rtree;
AllIndexes = false;
Data = DataEnum.countries;
Query = QueryEnum.FindNearestNeighbours;
}
示例6: GetContributor
public ActionResult GetContributor()
{
Random rand = new Random();
//create a collection of data
var transactionCounts = new List<TransactionCount>
{
new TransactionCount(){ MonthName="January", Count=rand.Next(101)},
new TransactionCount(){ MonthName="February", Count=rand.Next(101)},
new TransactionCount(){ MonthName="March", Count=rand.Next(101)},
new TransactionCount(){ MonthName="April", Count=rand.Next(101)}
};
//modify data type to make it of array type
var xDataMonths = transactionCounts.Select(i => i.MonthName).ToArray();
var yDataCounts = transactionCounts.Select(i => new object[] { i.Count }).ToArray();
//instanciate an object of the Highcharts type
var chart = new Highcharts("chart")
//define the type of chart
.InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
//overall Title of the chart
.SetTitle(new Title { Text = "Incoming Transacions per hour" })
//small label below the main Title
.SetSubtitle(new Subtitle { Text = "Accounting" })
//load the X values
.SetXAxis(new XAxis { Categories = xDataMonths })
//set the Y title
.SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Number of Transactions" } })
.SetTooltip(new Tooltip
{
Enabled = true,
Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y; }"
})
.SetPlotOptions(new PlotOptions
{
Line = new PlotOptionsLine
{
DataLabels = new PlotOptionsLineDataLabels
{
Enabled = true
},
EnableMouseTracking = false
}
})
//load the Y values
.SetSeries(new[]
{
new Series {Name = "Hour", Data = new Data(yDataCounts)},
//you can add more y data to create a second line
// new Series { Name = "Other Name", Data = new Data(OtherData) }
});
return PartialView("Contributor", chart);
}
示例7: Index
//
// GET: /HighChartsSampleModel/
public ActionResult Index()
{
var highchartSample = new List<HighChartsSampleModel>
{
new HighChartsSampleModel() {Parameters = "Event", GoodScore = 23.45D, AverageScore = 15.32D,BadScore = 9.4D,ActualScore=78.33D},
new HighChartsSampleModel() {Parameters = "Weather",GoodScore=45.67D,AverageScore = 33.24D,BadScore = 12.23D,ActualScore = 56.22D},
new HighChartsSampleModel() {Parameters = "User Review",GoodScore=67.23D,AverageScore = 31.23D,BadScore = 10.11D,ActualScore = 29.44D},
new HighChartsSampleModel() {Parameters = "Tweets",GoodScore = 89.67D,AverageScore = 12.33D,BadScore = 3.43D,ActualScore = 88.11D},
new HighChartsSampleModel() {Parameters = "Persona",GoodScore=38.34D,AverageScore = 25.34D,BadScore = 16.43D,ActualScore = 35.08D},
new HighChartsSampleModel() {Parameters = "Crime",GoodScore=38.34D,AverageScore = 25.34D,BadScore = 16.43D,ActualScore = 24.87D}
};
var xDataParameters = highchartSample.Select(i => i.Parameters).ToArray();
var actualScore = highchartSample.Select(i => i.ActualScore);
var chart = new Highcharts("chart");
chart.InitChart(new Chart { DefaultSeriesType = ChartTypes.Bar });
chart.SetTitle(new Title { Text = "Risk Score Profiling" });
chart.SetSubtitle(new Subtitle { Text = "Risk predicting using social media" });
chart.SetXAxis(new XAxis { Categories = xDataParameters });
chart.SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Scores" }, Max = 100 });
chart.SetLegend(new Legend { Enabled = false, });
chart.SetTooltip(new Tooltip
{
Enabled = true,
Formatter = @"function(){return '<b>' + this.series.name +'</b><br/>' + this.x+':' + this.y;}"
});
chart.SetPlotOptions(new PlotOptions
{
//Series = new PlotOptionsSeries() { Stacking = Stackings.Normal },
Bar = new PlotOptionsBar
{
DataLabels = new PlotOptionsBarDataLabels { Enabled = true,Color = Color.Maroon,Shadow = true},
//PointWidth = 10,
//GroupPadding = 1,
//PointPadding = 0,
Shadow = true,
BorderWidth = 1,
BorderColor = Color.FloralWhite,
}
});
Data data = new Data(
actualScore.Select(y => new Point { Color = GetBarColor(y), Y = y}).ToArray()
);
chart.SetSeries(new Series { Name = "Actual Score", Data = data });
return View(chart);
}
示例8: Bar
public ActionResult Bar()
{
var list = new DataForBarChart().ListDatas;
Series[] array = new Series[list.Count];
for (int i = 0; i < list.Count; i++)
array[i] = new Series { Name = list[i].Name, Data = new Data(list[i].List) };
Highcharts chart = new Highcharts("chart")
.InitChart(new Chart { Type = ChartTypes.Bar })
.SetTitle(new Title { Text = "Yearly Sales of Goods" })
.SetXAxis(new XAxis
{
Categories = _elementsService.ProductsItems.Select(item => item.Name).ToArray(),
Title = new XAxisTitle { Text = string.Empty }
})
.SetYAxis(new YAxis
{
Min = 0,
Title = new YAxisTitle
{
Text = "BYR",
Align = AxisTitleAligns.High
}
})
.SetTooltip(new Tooltip { Formatter = @"function() {
return ''+ this.series.name +': '+ this.y +' BYR';
}" })
.SetPlotOptions(new PlotOptions
{
Bar = new PlotOptionsBar
{
DataLabels = new PlotOptionsBarDataLabels { Enabled = true }
}
})
.SetLegend(new Legend
{
Layout = Layouts.Vertical,
Align = HorizontalAligns.Right,
VerticalAlign = VerticalAligns.Top,
X = -100,
Y = 100,
Floating = true,
BorderWidth = 1,
BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFFFFF")),
Shadow = true
})
.SetCredits(new Credits { Enabled = false })
.SetSeries(array);
return View(chart);
}
示例9: ChartOrders
public ActionResult ChartOrders()
{
Highcharts orders = new Highcharts("OrderID");
orders.SetTitle(new Title() { Text = Resources.Resource.OrdersRoma });
orders.SetYAxis(new YAxis
{
Title = new YAxisTitle() { Text = Resources.Resource.CountRoma },
});
//var ord = orderManager.GetQueryableOrders();
var drivers = userManager.GetQueryableDrivers();
//var res = ord.Join(drivers, x => x.DriverId, y => y.Id, (x, y) => new { Name = y.UserName, Orders = 1 }).GroupBy(x=>x.Name).ToList();
List<Series> series = new List<Series>();
List<object> serieData = new List<object>();
/*foreach (var i in res)
{
Series serie = new Series();
serie.Name = i.Key;
serie.Type = ChartTypes.Column;
serieData.Clear();
serieData.Add(i.Count());
serie.Data = new Data(serieData.ToArray());
series.Add(serie);
}*/
orders.SetSeries(series.ToArray());
orders.SetLegend(new Legend()
{
Align = HorizontalAligns.Right,
Layout = Layouts.Vertical,
VerticalAlign = VerticalAligns.Top
});
orders.SetPlotOptions(new PlotOptions()
{
Area = new PlotOptionsArea() { Stacking = Stackings.Normal }
});
orders.SetCredits(new Credits() { Enabled = false });
ViewBag.Order = orders;
return View();
}
示例10: BuildAreaSplineChart
private Highcharts BuildAreaSplineChart(XAndYAxisArrayContainer chartData, string chartTitle, string yAxisTitle)
{
Highcharts chart = new Highcharts(GenerateChartName(chartTitle))
.InitChart(new Chart { DefaultSeriesType = ChartTypes.Areaspline })
.SetTitle(new Title { Text = string.Empty })
.SetLegend(new Legend { Enabled = false })
.SetXAxis(new XAxis { Categories = chartData.XAxis })
.SetYAxis(new YAxis { Title = new YAxisTitle { Text = yAxisTitle } })
.SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.x +': '+ this.y + ' WIs Remaining'; }" })
.SetCredits(new Credits { Enabled = false })
.SetPlotOptions(new PlotOptions { Areaspline = new PlotOptionsAreaspline { FillOpacity = 0.5 } })
.SetSeries(new[] { new Series { Data = new Data(chartData.YAxis) } });
return chart;
}
示例11: AppendHighchart
public static void AppendHighchart(this StringBuilder sb, Highcharts chart)
{
foreach (KeyValuePair<string, string> jsVariable in chart.JsVariables)
sb.AppendLine("var {0} = {1};".FormatWith(jsVariable.Key, jsVariable.Value), 1);
sb.AppendLine(chart.Name + " = new Highcharts.Chart({", 1);
sb.Append(chart.GetOptions(), 2);
sb.AppendLine("});", 1);
foreach (KeyValuePair<string, string> jsFunction in chart.JsFunctions)
{
sb.AppendLine();
sb.AppendLine(jsFunction.Key, 1);
sb.AppendLine(jsFunction.Value, 2);
sb.AppendLine("}", 1);
}
}
示例12: Index
// GET: Graficos
public ActionResult Index()
{
var produto = new Produto();
var intArray = _produtoBo.ObterProdutos().Select(x => x.Quantidade);
var objectArray = intArray.Cast<object>().ToArray();
DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
.InitChart(new Chart { DefaultSeriesType = ChartTypes.Bar })
.SetTitle(new Title { Text = "Quantidade de Produtos Comprados" })
.SetXAxis(new XAxis
{
Categories = _produtoBo.ObterProdutos().Select(x => x.Produto).ToArray()
})
.SetYAxis(new YAxis
{
Min = 0,
Title = new YAxisTitle { Text = "Total Produtos" }
})
.SetSeries(new Series
{
Name = "Produto",
Data = new Data(objectArray)
});
ViewBag.grafico = chart;
var intArrayCompra = _compraBo.ObterCompra().Select(x => x.QuantidadeItem);
var objArrayCompra = intArrayCompra.Cast<object>().ToArray();
DotNet.Highcharts.Highcharts graficoCompra = new DotNet.Highcharts.Highcharts("graficoCompra")
.InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
.SetTitle(new Title { Text = "Quantidade de Compras" })
.SetXAxis(new XAxis
{
Categories = _compraBo.ObterCompra().Select(x => x.Compra).ToArray()
})
.SetYAxis(new YAxis
{
Min = 0,
Title = new YAxisTitle { Text = "Total de itens por Compras" }
})
.SetSeries(new Series
{
Name = "Compras",
Data = new Data(objArrayCompra)
});
ViewBag.Compra = graficoCompra;
return View();
}
示例13: chart
public Charts chart(String id)
{
using (db)
{
var reptileType = db.Reptiles.FirstOrDefault(r => r.ReptileId == id);
var weights = (from w in db.Weights where w.ReptileId == id select w.Weights);
var feedings = (from f in db.Feedings where f.ReptileId == id select f.NumItemsFed);
var lengths = (from l in db.Lengths where l.ReptileId == id select l.Lengths);
Object[] AvgForSpecies = new Object[12];
DateTime newDate = DateTime.UtcNow;
DateTime born = reptileType.Born.Value;
TimeSpan ts = newDate - born;
int age = ts.Days;
if (age > 365)
{
AvgForSpecies = new Object[12];
}
else
{
if (reptileType.ScientificName.Equals("Python regius"))
{
AvgForSpecies = new Object[]
{ 61.73,
82.20,
146.47,
230.33,
288.20,
346.40,
377.87,
406.20,
445.20,
476.73,
506.27,
546,
};
}
else if (reptileType.ScientificName.Equals("Eublepharis macularius"))
{
AvgForSpecies = new Object[]
{
2,
4,
5.5,
7.23,
9,
12.43,
15.98,
17,
18.96,
24,
30,
37,
};
}
}
List<int> WeightAmount = new List<int>();
List<int> FeedingsAmount = new List<int>();
List<Double> LengthsAmount = new List<Double>();
foreach (var w in weights)
{
WeightAmount.Add(w);
}
foreach (var f in feedings)
{
FeedingsAmount.Add(f);
}
foreach (var l in lengths)
{
LengthsAmount.Add(l);
}
WeightAmount.ToArray();
object[] newWeightsObj;
newWeightsObj = WeightAmount.Cast<object>().ToArray();
FeedingsAmount.ToArray();
object[] newFeedingsObj;
newFeedingsObj = FeedingsAmount.Cast<object>().ToArray();
LengthsAmount.ToArray();
object[] newLengthsObj;
newLengthsObj = LengthsAmount.Cast<object>().ToArray();
Highcharts g2 = new Highcharts("chart2")
.InitChart(new Chart { Type = ChartTypes.Column })
.SetTitle(new Title { Text = "Feedings" })
.SetCredits(new Credits { Enabled = false })
.SetXAxis(new XAxis { Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } })
.SetYAxis(new YAxis
{
Title = new YAxisTitle { Text = "grams" }
})
.SetTooltip(new Tooltip { Formatter = @"function() { return ''+ this.x +': '+ this.y +' grams'; }" })
//.........这里部分代码省略.........
示例14: Index
//
// GET: /Home/
public ActionResult Index()
{
DbDataContext dt = new DbDataContext();
//Fetching data from db:
var voltageValues = dt.Values.Where(v => v.FieldName == "Voltage").OrderBy(v => v.Datetime).ToList<Value>();
var currentValues = dt.Values.Where(v => v.FieldName == "Current").OrderBy(v => v.Datetime).ToList<Value>();
Highcharts Chart = new Highcharts("Chart");
// Initiizing chart
// Making month and days persian, however it is not accurate at all!
Chart.SetOptions(new GlobalOptions
{
Lang = new DotNet.Highcharts.Helpers.Lang
{
Loading = "در حال بارگذاری",
Months = new string[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند" },
Weekdays = new string[] { "شنبه", "یک شنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنج شنبه", "جمعه" },
ShortMonths = new string[] { "فرور", "اردی", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند" }
}
});
Chart.InitChart(new Chart
{
DefaultSeriesType = ChartTypes.Line,
MarginRight = 130,
MarginBottom = 55,
ClassName = "chart",
ZoomType = ZoomTypes.X
})
.SetTitle(new Title
{
Text = "نمودار تغییرات داده ها "
})
.SetSubtitle(new Subtitle
{
Text = "نمونه استفاده نمودار",
X = -20
})
.SetXAxis(new XAxis
{
Type = AxisTypes.Datetime,
Title = new XAxisTitle
{
Text = "بازه زمانی از ... تا..."
},
MinorTickInterval = 3600 * 1000,
TickLength = 1,
MinRange = 3600 * 1000,
MinTickInterval = 3600 * 1000,
GridLineWidth = 1,
Labels = new XAxisLabels
{
Align = HorizontalAligns.Right,
Rotation = -30,
},
DateTimeLabelFormats = new DateTimeLabel
{
Second = "%H:%M:%S",
Minute = "%H:%M",
Hour = "%H:%M",
Day = "%e %b",
Week = "%e %b",
Month = "%b",
Year = "%Y",
},
ShowEmpty = false,
})
.SetLegend(new Legend
{
Layout = Layouts.Vertical,
Align = HorizontalAligns.Left,
X = 20,
VerticalAlign = VerticalAligns.Top,
Y = 80,
BackgroundColor = new BackColorOrGradient(System.Drawing.ColorTranslator.FromHtml("#FFFFFF"))
});
YAxis[] yAxis = new YAxis[2];
yAxis[0] = (new YAxis
{
Title = new YAxisTitle
{
Text = string.Format("{0} ({1})", "Voltage", "V"),
},
Labels = new YAxisLabels
{
//Align = HorizontalAligns.Right,
Formatter = "function() { return this.value; }",
},
Opposite = true,
GridLineWidth = 0
});
yAxis[1] = (new YAxis
{
Title = new YAxisTitle
{
//.........这里部分代码省略.........
示例15: GetChartPayment
private Highcharts GetChartPayment(List<ChartDataViewModel> data, string name)
{
if (!data.Any()) return null;
var chart = new Highcharts("cart_" + name)
.InitChart(new Chart { DefaultSeriesType = ChartTypes.Bar, Height = null, Width = null })
.SetTitle(new Title { Text = "Кількість проданих товарів по формi оплати" })
.SetXAxis(new XAxis
{
Categories = data.Select(o => o.Name.Replace('\'', '`')).ToArray(),
Labels = new XAxisLabels { Style = " fontSize: '16px'" },
Title = new XAxisTitle { Text = "" }
})
.SetYAxis(new YAxis
{
Title = new YAxisTitle { Text = "Кількість товарів, шт.", Style = " fontSize: '18px'" },
AllowDecimals = false,
Labels = new YAxisLabels { Style = " fontSize: '18px', fontWeight: 'bold'" }
})
.SetTooltip(new Tooltip
{
Enabled = true,
Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': <b>'+ this.y + '</b> шт.'; }"
})
.SetPlotOptions(new PlotOptions
{
Line = new PlotOptionsLine
{
DataLabels = new PlotOptionsLineDataLabels
{
Enabled = true
},
EnableMouseTracking = false
}
})
.SetLegend(new Legend { Enabled = false })
.SetSeries(new[]
{
new Series {Name = "Кількість проданих товарів", Data =
new Data(data: data.Select(o => new object[] { o.Count }).ToArray()), Color =Color.Coral },
});
return chart;
}