Remove white space from Chart

Asked

Viewed 159 times

2

I’m facing a problem I can’t solve. I have a page, and it has 2 Charts, but the problem is that these Charts, are small, with lots of white space around them.
I’ve tried setting up the property Position and InnerPlotPosition, but it gets worse because there’s a whiteboard on top of the graph.

Today the sources I have are as follows:

<div class="col-lg-12">
    <asp:Chart ID="grfStatus" runat="server" PaletteCustomColors="2, 65, 142; 255, 128, 0; Yellow; Red; Lime" Height="400px" Width="600px" BorderlineColor="Transparent">
        <Series>
            <asp:Series Name="Series1" ChartType="Pie">
            </asp:Series>
        </Series>
        <ChartAreas>
            <asp:ChartArea Name="ChartArea1" IsSameFontSizeForAllAxes="True" AlignmentOrientation="All">
                <AxisY MaximumAutoSize="100">
                </AxisY>
                <AxisX MaximumAutoSize="100">
                </AxisX>
            </asp:ChartArea>
        </ChartAreas>
        <Titles>
            <asp:Title Name="Title1" Text="Gráfico de Status" Font="Microsoft Sans Serif, 18pt" ForeColor="White">
            </asp:Title>
        </Titles>
        <Legends>
            <asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="False" Name="Default" LegendStyle="Row" />
        </Legends>
        <BorderSkin BackColor="0, 65, 139" BorderColor="Transparent" SkinStyle="FrameTitle8" />
    </asp:Chart>
</div>
<div class="col-lg-12">
    <asp:Chart ID="grfClientes" runat="server" PaletteCustomColors="2, 65, 142; 255, 128, 0; Yellow; Red; Lime" Height="400px" Width="600px">
        <Series>
            <asp:Series Name="Series1" ChartType="StackedBar" IsVisibleInLegend="False"></asp:Series>
        </Series>
        <ChartAreas>
            <asp:ChartArea Name="ChartArea1" IsSameFontSizeForAllAxes="True" AlignmentOrientation="All">
                <AxisY MaximumAutoSize="100">
                </AxisY>
                <AxisX MaximumAutoSize="100">
                </AxisX>
            </asp:ChartArea>
        </ChartAreas>
        <Titles>
            <asp:Title Name="Title1" Text="Gráfico de Evolução por Empresa" Font="Microsoft Sans Serif, 18pt" ForeColor="White">
            </asp:Title>
        </Titles>
        <Legends>
            <asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="False" Name="Default" LegendStyle="Row" />
        </Legends>
        <BorderSkin BackColor="0, 65, 139" SkinStyle="FrameTitle8" />
    </asp:Chart>
</div>

C#

#region Populo o gráfico de pizza
grfStatus.Series.Clear();
//grfStatus.Legends.Clear();
//grfStatus.Legends.Add(nomeLegenda);
List<GraficoContagemStatus> relacaoStatus = visaoAgendamentoControle.ObterRelacaoGraficoContagemStatus(resultado);

grfStatus.ChartAreas.Add(new ChartArea());
grfStatus.Series.Add(new Series("Data"));
grfStatus.Series["Data"].ChartType = SeriesChartType.Pie;
//grfStatus.Series["Data"]["PieLabelStyle"] = "Outside";
//grfStatus.Series["Data"]["PieLineColor"] = "Black";
grfStatus.Series["Data"].Points.DataBindXY(relacaoStatus.Select(data => data.Status.ToString()).ToArray(),
                                           relacaoStatus.Select(data => data.Contagem).ToArray());
#endregion

#region Populo o gráfico de barras (duplas)
grfClientes.Series.Clear();
//grfClientes.Legends.Clear();
//grfClientes.Legends.Add(nomeLegenda);
List<GraficoContagemClienteUz> relacaoClientes = visaoAgendamentoControle.ObterRelacaoGraficoContagemClienteUz(resultado);

foreach (GraficoContagemClienteUz cliente in relacaoClientes)
{
    grfClientes.ChartAreas.Add(new ChartArea());
    grfClientes.Series.Add(new Series(cliente.CLIENTE));
    grfClientes.Series[cliente.CLIENTE].ChartType = SeriesChartType.Bar;

    List<GraficoContagemClienteUz> rel = relacaoClientes.Where(x => x.CLIENTE == cliente.CLIENTE).ToList();

    grfClientes.Series[cliente.CLIENTE].Points.DataBindXY(rel.Select(data => data.CLIENTE.ToString()).ToArray(),
                                                          rel.Select(data => data.QTD_UZ).ToArray());
}
#endregion

And follow the image of the result of how it is today: inserir a descrição da imagem aqui

1 answer

0


I managed to solve the problem. What happened was, within my repeating structure, I was creating new chartAreas and new Series. I modified the structure so that the loop only populates the information and worked correctly.

  • 1

    If possible, add how it looked if code. This answer may help someone with the same problem in the future. xD

Browser other questions tagged

You are not signed in. Login or sign up in order to post.