Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
700
Captions for data - composite/scatter chart
posted

Hi all,

 I have created a scatter chart in a composite chart and have added a series of data to it.

 I am wondering whether there is any function to define a text against every point in the graph (similar to excel).

Thx in advance 

 

Parents Reply
  • 350
    posted in reply to Teodor Taushanov

    Hi Teodor,

    I am using the version 7.2.20072.61.

    I have the same issue, as i have to show custom labels on a composite chart. I tried using the solution you suggested. But the toString method in the just does not get called.

    The chart is diplayed as below. Please help me out. I am trying to use a scatter chart and am trying to label the points in the scatter chart.

    I have used the following code.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    axisXScatter =

     

    new AxisItem

    ();

    axisXScatter.OrientationType =

     

    AxisNumber

    .X2_Axis;

    axisXScatter.Labels.Orientation =

     

    TextOrientation

    .VerticalLeftFacing;

    axisXScatter.Labels.Font =

     

    new Font("Verdana"

    , 8);

    axisXScatter.RangeMin = 0;

    axisXScatter.TickmarkInterval = 1;

    axisXScatter.TickmarkStyle =

     

    AxisTickStyle

    .DataInterval;

    axisXScatter.Margin.Far.Value = 5;

    axisXScatter.Margin.Far.MarginType =

     

    LocationType

    .Pixels;

    axisXScatter.Labels.Visible =

     

    true

    ;

    axisXScatter.Visible =

     

    true

    ;

    axisXScatter.RangeMin = 0;

    myChartArea.Axes.Add(axisXScatter);

     

     

    ChartLayerAppearance legendScatterLayer = new ChartLayerAppearance

    ();

    legendScatterLayer.ChartType =

     

    ChartType

    .ScatterChart;

    legendScatterLayer.ChartArea = myChartArea;

    legendScatterLayer.AxisY = axisY;

    legendScatterLayer.AxisX = axisXScatter;

    legendScatterLayer.AxisX.Visible =

     

    false

    ;

     

     

    ScatterChartAppearance sca = new ScatterChartAppearance

    ();

    sca.NullHandling =

     

    NullHandling

    .Zero;

    sca.Icon =

     

    SymbolIcon

    .Circle;

    sca.IconSize =

     

    SymbolIconSize

    .Small;

    sca.LineAppearance.Thickness = 1;

    sca.ConnectWithLines =

     

    false

    ;

     

     

    this.resultChart1.CompositeChart.ChartLayers.Add(legendScatterLayer);

    //Add Chart Layer

     

     

     

    ChartTextAppearance

    textApp;

    textApp =

     

    new ChartTextAppearance

    ();

    textApp.Row = -2;

    textApp.Column = -2;

    textApp.Visible =

     

    true

    ;

    textApp.ItemFormatString =

     

    "<MY_VALUE>"

    ;

    sca.ChartText.Add(textApp);

     

     

    Hashtable labelHashTable = new Hashtable

    ();

     

     

    string[] arr = { "^"

    };

     

     

    List<string> stringList = new List<string

    >();

     

     

    foreach (string strKey in

    myDictionary.Keys)

    {

     

     

    if (!stringList.Contains(((strKey.Split(arr, StringSplitOptions

    .None))[0]).Trim()))

    {

    stringList.Add((strKey.Split(arr,

     

    StringSplitOptions

    .None)[0]).Trim());

    }

     

     

    //labelHashTable.Add((strKey.Split(arr, StringSplitOptions.None)[1]) + "^" + (strKey.Split(arr, StringSplitOptions.None)[0]), new MyLabelRenderer(this.resultChart1));

     

    }

     

     

    legendScatterLayer.ChartTypeAppearance = sca;

     

     

    int

    xlength = xstdwidth / noOfMonths;

     

     

    double

    xCount = 0;

     

     

    XYSeries xySeries = new XYSeries

    ();

    xySeries.Visible =

     

    true

    ;

     

     

    foreach (string yearMonthString in

    stringList)

    {

     

     

    foreach (string strKey in

    myDictionary.Keys)

    {

     

     

    if((strKey.Split(arr, StringSplitOptions

    .None)[0]).Trim() == yearMonthString)

    {

    xySeries.Points.Add(

     

    new XYDataPoint(xCount,myDictionary[strKey],yearMonthString,false

    ));

    xySeries.PEs.Add(

     

    new PaintElement(Color

    .Silver));

     

    }

    }

    xCount += xlength;

    }

     

     

    this.resultChart1.Tooltips.Display = TooltipDisplay

    .MouseMove;

     

     

    this

    .resultChart1.Series.Add(xySeries);

    legendScatterLayer.Series.Add(xySeries);

     

     

    foreach (string strKey in

    myDictionary.Keys)

    {

    labelHashTable.Add((strKey.Split(arr,

     

    StringSplitOptions.None)[1]) + "^" + (strKey.Split(arr, StringSplitOptions.None)[0]), new MyLabelRenderer(this

    .resultChart1));

    }

     

     

    this

    .resultChart1.LabelHash = labelHashTable;

     

     

    /////////////////////////////////////////////////////////////////////////////////////

     public class MyLabelRenderer : IRenderLabel

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    {

     

     

    private XYSeries

    xySeries;

     

     

     

     

    public MyLabelRenderer(UltraChart

    ultraChart)

    {

     

     

    this.xySeries = ultraChart.Series[10] as XYSeries

    ;

    }

     

     

    public string ToString(Hashtable

    context)

    {

     

     

    int row = (int)context["DATA_ROW"

    ];

     

     

    XYDataPoint xyPoint = this

    .xySeries.Points[row];

     

     

     

    return

    xyPoint.Label;}}

    Please help me out. I am desperate to get this done now.

Children