Home Forums WinForms controls Xceed Chart for WinForms Text for each stack along X-axis of Stacked Bar

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18814 |

    hi,
    I’m using a Stacked Bar to display some data and it looks like the bar in the samples here:
    http://demo.xceedsoft.com/XceedChartExplorer/Series/Bar/StackedBar.aspx

    I need to display text instead of the 1,2,3,4… along X-axis and I need to display a text for each stack (hence, 5 labels along x-axis for each stack per the image in the example above)

    I’ve manaed to add the code to display text (by adding labels using chart.Axis(StandardAxis.PrimaryX).Labels.Add). But the labels do not correspond to each stack – they are too close together.

    I think I need to change the scale of the X-Axis to correspond to each stack I’m adding – but not sure what properties to set. Any ideas?

    Thanks.

    Imported from legacy forums. Posted by ApplePie (had 2630 views)

    Xceed Support
    Member
    Post count: 5658

    Each label that you add to the Labels collection corresponds to the point (stack or bar) with the corresponding index. To better display the text, you can use the StaggerTexts property.

    e.g.,
    <code>
    Chart chart = chartControl1.Charts.Add();

    BarSeries barSeries1 = ( BarSeries )chart.Series.Add( SeriesType.Bar );

    barSeries1.Add( 20.3, “MyLabel1” );
    chart.Axis( StandardAxis.PrimaryX ).Labels.Add( “MyLabel1” );
    barSeries1.Add( 19.4, “MyLabel2” );
    chart.Axis( StandardAxis.PrimaryX ).Labels.Add( “MyLabel2” );
    barSeries1.Add( 95.7, “MyLabel3” );
    chart.Axis( StandardAxis.PrimaryX ).Labels.Add( “MyLabel3” );
    barSeries1.Add( 11.9, “MyLabel4” );
    chart.Axis( StandardAxis.PrimaryX ).Labels.Add( “MyLabel4” );
    barSeries1.Add( 55.5, “MyLabel5” );
    chart.Axis( StandardAxis.PrimaryX ).Labels.Add( “MyLabel5” );

    chart.Axis( StandardAxis.PrimaryX ).ScaleMode = AxisScaleMode.Dimension;
    chart.Axis( StandardAxis.PrimaryX ).DimensionScale.AutoLabels = false;
    chart.Axis( StandardAxis.PrimaryX ).StaggerTexts = true;
    </code>

    Imported from legacy forums. Posted by CharlesB (had 3025 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.