我有以下图表我想使用 C# 设置两件事
- 我如何在图表下方设置 x 轴图例而不是在轴下方,因为它与线重叠?
- 我设置的工具提示没有像这样“{0} Sentiment - {1} Volume”?
.
private void FillChart(IEnumerable<EntitySearchResponse> data)
{
SentimentChart.ChartTitle.Text = "Sentemants Per day";
SentimentChart.PlotArea.YAxis.TitleAppearance.Text = "Sentimants %";
SentimentChart.PlotArea.XAxis.LabelsAppearance.RotationAngle = 90;
SentimentChart.PlotArea.XAxis.Step = 10;
SentimentChart.PlotArea.XAxis.Items.Clear();
foreach (var date in data.Select(x => x.Date).Distinct())
{
var axisItem = new AxisItem(date.ToString("ddd dd"));
SentimentChart.PlotArea.XAxis.Items.Add(axisItem);
}
SentimentChart.DataSource = data;
SentimentChart.PlotArea.Series.Clear();
foreach (var entityName in data.Select(x => x.EntityName).Distinct())
{
var series = new ColumnSeries();
series.LabelsAppearance.DataFormatString = "{0} items";
series.TooltipsAppearance.DataFormatString = "{0} {2} items";
series.Name = entityName;
var items = data.Where(x => x.EntityName == entityName).ToList();
foreach (var entitySearchResponse in items)
{
var seriesItem = new SeriesItem(entitySearchResponse.Sentiment);
seriesItem.TooltipValue = string.Format("{0} Sentiment - {1} Volume", entitySearchResponse.Sentiment,
entitySearchResponse.Volume);
series.Items.Add(seriesItem);
}
SentimentChart.PlotArea.Series.Add(series);
}
}