Select to view content in your preferred language

How to set chart axis base

470
0
01-18-2013 09:08 AM
DonFreeman
Emerging Contributor
My webpage includes a chart to display annual traffic counts in a vertical column format. This all works well except that the vertical axis of the chart likes to start just below the lowest value to be displayed. I would like the axis to always start at zero but have not been able to find a setting to make this happen. Can someone help me out on this? Code below. Thanks

<toolkit:Chart x:Name="MyChart2"
            Title="Average Daily Traffic" 
          esri:GraphicsLayer.MapTipHideDelay="0:0:3" 
          Background="LightGray"  
          LegendStyle="{StaticResource BlankLegendStyle}" 
          TitleStyle="{StaticResource SmallTitleStyle}"          
          Height="225"
          Width="330">
       
       <toolkit:Chart.Series>
        <toolkit:ColumnSeries Title="ADT" IndependentValueBinding="{Binding Attributes[_year]}" 
                                                  DependentValueBinding="{Binding Attributes[adt]}">
         <toolkit:ColumnSeries.DataPointStyle>
          <Style TargetType="toolkit:DataPoint">
           <Setter Property="Template">
            <Setter.Value>
             <ControlTemplate TargetType="toolkit:ColumnDataPoint">
              <Grid Background="#FF51626F">
               <TextBlock Text="{TemplateBinding FormattedDependentValue}" 
                                                                   FontWeight="Bold" FontSize="8" 
                                                                   HorizontalAlignment="Stretch"
                                                                   TextAlignment="Center" />
              </Grid>
             </ControlTemplate>
            </Setter.Value>
           </Setter>
          </Style>
         </toolkit:ColumnSeries.DataPointStyle>
        </toolkit:ColumnSeries>
       </toolkit:Chart.Series>
      </toolkit:Chart>


 void QueryTask_ExecuteRelationshipQueryCompleted(object sender, RelationshipEventArgs e)
        {
   RelationshipResult pr = e.Result;
            if (pr.RelatedRecordsGroup.Count == 0)
            {
                RelatedRowsDataGrid.ItemsSource = null;
            }
            else
            {                
                foreach (var pair in pr.RelatedRecordsGroup)
                {
                    RelatedRowsDataGrid.ItemsSource = pair.Value;

                    // keep this as a member if you want to use it in multiple places
                    CollectionViewSource cvs = new CollectionViewSource();
                    cvs.Source = pair.Value;                   

                    DataGridBoundColumn column = RelatedRowsDataGrid.Columns[1] as DataGridBoundColumn; // year column
                    string bindingPath = column.Binding.Path.Path;
                    cvs.SortDescriptions.Add(new SortDescription(bindingPath, ListSortDirection.Ascending));
                    RelatedRowsDataGrid.ItemsSource = cvs.View;
                   
                    ((ColumnSeries)MyChart2.Series[0]).ItemsSource = cvs.View; //new KeyValuePair<int, int>[] { new KeyValuePair<int, int>(2005, 1200) };
                }
            }
        }
0 Kudos
0 Replies