1
BarGraph.Titles.Clear();
BarGraph.Titles.Add(cmbGraphOptions.SelectedItem.ToString());

Series series = new Series(seriesTitle);

series.ChartType = chartType == "Column" ? SeriesChartType.Column : SeriesChartType.Pie;
series.Palette = ChartColorPalette.EarthTones;

foreach (IGraphData t in mGraphVm.Data)
{
    if (t.XAxis != null && t.YAxis > 0)
    {
        series.Points.AddXY(t.XAxis, t.YAxis);
        series.Palette = ChartColorPalette.EarthTones;
        series.IsValueShownAsLabel = true;
        series.ToolTip = t.XAxis;
        series.Legend = "Legend1";
        series.IsVisibleInLegend = true;
    }
}
BarGraph.Series.Add(series);

上面的代码显示了饼图和柱形图。但在柱形图的情况下,它不显示图例......而饼图确实正确显示了图例。

但是,对于柱形图..当我将代码更改为以下代码段时,它确实显示了图例,但这次它开始从中心而不是左侧绘制条形图。

foreach (IGraphData t in mGraphVm.Data)
{
    if (t.XAxis != null && t.YAxis > 0)
    {
        series = this.BarGraph.Series.Add(t.XAxis);
        series.Points.Add(t.YAxis);

        series.ToolTip = t.XAxis;
        series.IsValueShownAsLabel = true;

        //RnD
        //series.Points.AddXY(t.XAxis, t.YAxis);
        //series.Points.AddY(t.YAxis);

        //series.XValueMember = t.XAxis;
        //series.YValueMembers = t.YAxis.ToString();
    }
}

我需要图表来绘制从左侧开始并带有图例的点。

任何帮助将非常感激。

4

0 回答 0