現在、チャートを主成分とするツールを開発する必要があります。チャートコントロールも私にとっては新しいものです。私は多くの読書をして、チャートコントロールの全体像を学び理解するために研究しています。ここでC#各積み上げ縦棒グラフに水平線を描く
私はそうやっていること:イメージは下図のように
は、すべての後、私は立ち往生していたと積み上げ縦棒グラフ上の水平線(青&赤の水平線)を描画する方法についての質問はるか:
これは、これまでの私のコードです:
// X-Axis labels settings
chart.ChartAreas[0].AxisX.LabelStyle.Angle = -45;
chart.ChartAreas[0].AxisX.Interval = 1;
// Y-Axis labels settings
//chart.ChartAreas[0].AxisY.Minimum = 100;
chart.ChartAreas[0].AxisY.Minimum = 95;
// Plotting chart
using (YieldEntities context = new YieldEntities())
{
// Extract yield loss list
var yeilds = (
from yeild in context.YeildDatas
group yeild by new { yeild.Loss } into newyeild
select new
{
Loss = newyeild.Key.Loss,
Percentage = newyeild.Sum(p => p.Percentage)
}).OrderByDescending(p => p.Percentage);
//context.YeildDatas.Select(p => new { p.Loss, Percentage = p }).Distinct();
// Create new series
foreach (var yield in yeilds)
{
chart.Series.Add(yield.Loss);
chart.Series[yield.Loss].ChartType = SeriesChartType.StackedColumn100;
}
// Label settings for first series
chart.Series[0].SmartLabelStyle.Enabled = false;
chart.Series[0].LabelAngle = -90;
chart.Series[0].Font = new Font(Font.FontFamily, 15, FontStyle.Bold);
chart.Series[0].IsValueShownAsLabel = true;
var query = context.YeildDatas.ToList();
foreach (var item in query)
{
DataPoint dp = new DataPoint();
dp.SetValueXY(item.DateString, item.Percentage);
chart.Series[item.Loss].Points.Add(dp);
}
// Set empty datapoint for each series
foreach (var yield in yeilds)
{
DataPoint nulldp = new DataPoint();
nulldp.SetValueXY("", 0);
chart.Series[yield.Loss].Points.Insert(1, nulldp);
chart.Series[yield.Loss].Points.Insert(6, nulldp);
chart.Series[yield.Loss].Points.Insert(11, nulldp);
}
chart.Legends["Legend"].IsEquallySpacedItems = true;
chart.Legends["Legend"].IsTextAutoFit = true;
}
私はこの問題を解決するために私を導く専門家を得たいと思っています。これが唯一のサンプルです
、あなたは自分でチャートコントロールを描画していますか?または、完成したチャートコントロールを使用していますか?フィニッシュチャートコントロールを使用している場合は、チャートコントロールでイベントペイントを使用し、そこにDrawLineを試してみてください。 –
Visual Studio 2015で提供されているチャートコントロールを使用しています。 –
あなたの質問は基本的に一連の要件です。表示するコードは? – MickyD