Welcome to the Xceed Community Sign in | Join | Help
Community Search  

Scale trouble

Sort Posts: Previous Next
  •  06-02-2008, 3:28 PM Post no. 12630

    Scale trouble

    Hi there,

    I was looking in Xceed Cart for .NET - WinForm C# Examples for something related to my problem but I was unsuccessfull.
    It is very simple, I have a chart with many bars whose max are 100(%)

     I already have my chart displaying everything, but the problem is the scale... it goes like: 0, 9.3, 18.6 (see image below)

    That is not pretty... the only thing I want to do is to change the scale to something like 0,10,20,30...100... but I'm not being able to do that.
    Can someone please give me any hints?

    Thanks in advance.


    Oscar.

  •  06-03-2008, 3:27 PM Post no. 12644 in reply to 12630

    Re: Scale trouble

    Hi there again,

     Studying more about the chart properties I started using many functions to display what I want... but still unsuccessfull.

    Here is my code to generate the chart

             chtGrafico.Wall(ChartWallType.Left).Visible = true;
             chtGrafico.Wall(ChartWallType.Back).Visible = true;
             chtGrafico.Axis(StandardAxis.PrimaryY).Visible = true;
             chtGrafico.Axis(StandardAxis.PrimaryX).Visible = true;
            
             chtGrafico.Axis(StandardAxis.PrimaryY).ScaleMode = AxisScaleMode.Numeric;
             chtGrafico.Axis(StandardAxis.PrimaryY).NumericScale.AutoMinorTicks = true;
             chtGrafico.Axis(StandardAxis.PrimaryY).NumericScale.MajorTickMode = MajorTickModeNumeric.Auto;
             chtGrafico.Axis(StandardAxis.PrimaryY).Ruler.PagingMode = RulerPagingMode.None;
             chtGrafico.Axis(StandardAxis.PrimaryY).SetMajorShowAtWall(ChartWallType.Back, true);
             chtGrafico.Axis(StandardAxis.PrimaryY).SetMinorShowAtWall(ChartWallType.Back, true);

             //chtGrafico.Axis(StandardAxis.PrimaryY).ValueFormatting.Format = ValueFormat.Percentage;
             chtGrafico.Axis(StandardAxis.Depth).Visible = false;

             bar1= (BarSeries) chtGrafico.Series.Add(SeriesType.Bar);
             bar1.Name = "Risco garantido";
             bar1.MultiBarMode = MultiBarMode.Series;

             bar2= (BarSeries) chtGrafico.Series.Add(SeriesType.Bar);
             bar2.Name = "Risco não garantido";
             bar2.MultiBarMode = MultiBarMode.StackedPercent;

             bar3= (BarSeries) chtGrafico.Series.Add(SeriesType.Bar);
             bar3.Name = "Garantia + Limite";
             bar3.MultiBarMode = MultiBarMode.StackedPercent;

             bar1.DataLabels.Mode = DataLabelsMode.None;
             bar2.DataLabels.Mode = DataLabelsMode.None;
             bar3.DataLabels.Mode = DataLabelsMode.None;

             bar1.Interactivity.TooltipMode = SeriesTooltipMode.Formatted;
             bar1.Interactivity.TooltipFormat = "<label>:\n <value>";
             bar1.Interactivity.Tooltips.Clear();

             bar1.BarFillEffect.SetSolidColor(Color.Green);
             bar2.BarFillEffect.SetSolidColor(Color.Red);
             bar3.BarFillEffect.SetSolidColor(Color.Gray);

             bar1.DataLabels.Format = "<percent>";
             bar2.DataLabels.Format = "<percent>";
             bar3.DataLabels.Format = "<percent>";

             chtGrafico.Axis(StandardAxis.PrimaryX).SetPredefinedTextLayout(PredefinedTextLayout.TiltedAscending);
             chtGrafico.Axis(StandardAxis.PrimaryX).DimensionScale.AutoLabels = false;
             chtGrafico.Axis(StandardAxis.PrimaryX).Text.Font = new Font("Arial", 6, FontStyle.Bold);

    But now there are no ticks on the Y axis... why would that happen?

     

    Thanks again
    Oscar

  •  06-03-2008, 4:57 PM Post no. 12647 in reply to 12644

    Re: Scale trouble

    Try setting the axis major ticks to custom steps.

     e.g. :

    chart.Axis( StandardAxis.PrimaryY ).ScaleMode = AxisScaleMode.Numeric;

    chart.Axis( StandardAxis.PrimaryY ).NumericScale.MajorTickMode = MajorTickModeNumeric.CustomStep;

    chart.Axis( StandardAxis.PrimaryY ).NumericScale.CustomStep = 10;


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  06-04-2008, 9:15 AM Post no. 12664 in reply to 12647

    Re: Scale trouble

    Hi André,

     I tried that just now and it didn't work. I really don't understand.
    The funny thing is (pay attention to the lines signed with {n})

             Xceed.Chart.Core.Chart chtGrafico = agrGrafico.Grafico;
             chtGrafico.Series.Clear();    {1}
             chtGrafico.Axis(StandardAxis.PrimaryY).ScaleMode = AxisScaleMode.Numeric;
             chtGrafico.Axis(StandardAxis.PrimaryY).NumericScale.MajorTickMode = MajorTickModeNumeric.CustomStep;
             chtGrafico.Axis(StandardAxis.PrimaryY).NumericScale.CustomStep = 10;

             bar1= (BarSeries) chtGrafico.Series.Add(SeriesType.Bar); {2}
             bar1.Name = "Risco garantido";
             bar1.MultiBarMode = MultiBarMode.Series;

             bar2= (BarSeries) chtGrafico.Series.Add(SeriesType.Bar);
             bar2.Name = "Risco não garantido";
             bar2.MultiBarMode = MultiBarMode.StackedPercent;

             bar3= (BarSeries) chtGrafico.Series.Add(SeriesType.Bar);
             bar3.Name = "Garantia + Limite";
             bar3.MultiBarMode = MultiBarMode.StackedPercent;

             chtGrafico.Axis(StandardAxis.PrimaryX).SetPredefinedTextLayout(PredefinedTextLayout.TiltedAscending);
             chtGrafico.Axis(StandardAxis.PrimaryX).DimensionScale.AutoLabels = false;
             chtGrafico.Axis(StandardAxis.PrimaryX).Text.Font = new Font("Arial", 6, FontStyle.Bold);


    If I debug the application like this we can see why I use the line {1}. I don't know why but it already has a bar Series added to it. And I didn't do that anywhere before in the code. This way I use Clear() to clear it and then I add every bar series I need.

    To add the values to the bars I use a for loop adding values like this
    bar1.Add(value, label);
    bar2.Add(value, label);
    bar3.Add(value, label);

    When I run that code (with the clear function) after adding the series I have 3 series added (the first is in Series mode and the other two in StackedPercent).

    The result is an empty chart (no bars) WITH Major Ticks on the PrimaryY axis! (!!!!)

    Now, when I remove the Clear() line, the result is an COMPLETE chart with bars displaying correct data information with NO Major Ticks on the PrimaryY Axis! (!!!)

    I even tried to change {2} for
         bar1 = (BarSeries) chtGrafico.Series[0];
    But it didn't work too (empty chart with major ticks is displayed)

    I really don't know what to do... do you have any more ideas André?
    Thanks in advance
    Oscar

     

  •  06-04-2008, 2:43 PM Post no. 12678 in reply to 12664

    Re: Scale trouble

    Finally!

    I did it!
    Since I cought this project long time after it started, I had to figure out a resize event that was adding MajorTicks manually based on the window size...

    I took 3 days to figure that out...
    Well.. at least I'm able to make charts by my self now...

    Thanks for the help André.

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.