0

従来のasp.netチャートを使用してデータを表示し、それをPDFに配置しています。私が解決できないように見える問題は、凡例をグラフの右側に追加すると、それが押し下げられることです。誰でも理由がわかりますか?

ここに画像の説明を入力

        _chart.Height = _chartHeight;
    _chart.Width = _chartWidth;

    Legend legend = new Legend("Default");
    legend.LegendStyle = LegendStyle.Column;
    legend.IsTextAutoFit = false;
    legend.Docking = Docking.Right;
    legend.Alignment = System.Drawing.StringAlignment.Near;

    _chart.Legends.Add(legend);

    Series series = new Series("Default");
    _chart.Series.Add(series);

    ChartArea chartArea = new ChartArea("ChartArea1");
    //chartArea.Position.Y = 0;
    _chart.ChartAreas.Add(chartArea);
    //-- this data would usually be collected from _travelRepository.TravelModesForTheYear 
    //-- but for speed I've hardcoded as its same for everyone in country 
    _chart.Series["Default"].Points.DataBindXY(xValues, yValues);

    System.Drawing.Color[] colours = new System.Drawing.Color[] { _orange, _yellow, _pink, _red, _green, _purple };

    int i = 0;
    foreach (System.Web.UI.DataVisualization.Charting.DataPoint point in _chart.Series["Default"].Points)
    {
        _chart.Series["Default"].Points[i].Color = colours[i];
        if(showLegends)
            _chart.Series["Default"].Points[i].Label = "#PERCENT";

        i++;
    }

    _chart.Series["Default"].ChartType = SeriesChartType.Pie;

    _chart.Series["Default"]["PieLabelStyle"] = showLegends ? "Inside" : "Disabled";
    _chart.Series["Default"].LabelForeColor = System.Drawing.Color.White;
    _chart.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
    _chart.ChartAreas["ChartArea1"].AlignmentStyle = AreaAlignmentStyles.Position;
    _chart.BorderlineWidth = 0;
    _chart.ChartAreas["ChartArea1"].AxisY.LabelStyle.Enabled = showLegends;
    _chart.ChartAreas["ChartArea1"].AxisX.LabelStyle.Enabled = showLegends;
    _chart.ChartAreas["ChartArea1"].AlignmentOrientation = AreaAlignmentOrientations.Horizontal;
    _chart.Legends[0].Enabled = showLegends;
4

1 に答える 1