in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Programmatically Assign ChartData Tooltip text for C1WebChart

Last post 08-14-2008 9:50 AM by lenchase. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-25-2008 3:22 PM

    Programmatically Assign ChartData Tooltip text for C1WebChart

    I'm looking for a way to programmatically assign the tooltip text for each piece of chart data.  For instance, I have a stacked bar chart and I want to have the pieces of the stacked bar to all have the same tooltip display that shows the combined total for the stacked bar.

    Another use for this is for programmatically performing a calculation on the data and using the result as a tooltip for each chart data item.  If you know of a way to accomplish this; will you please share your knowledge?

     --
    tomS.

    --
    tomS.
  • 03-26-2008 12:06 PM In reply to

    Re: Programmatically Assign ChartData Tooltip text for C1WebChart

    Hello Tom,
     

    You can add your own MapArea objects using the collection’s Add method. When you create new MapArea objects, specify their shape (circle, rectangle or polygon) and the coordinates of the area to be created. You can do this at design time, using the collection editor, or using code. For example:

    MapArea a = new MapArea();

    a.Shape = AreaShapeEnum.Rectangle;

    a.Coords = new int[] { 169,225,175,240 };

    a.Tooltip = "My Custom Area";

    _c1wc.ImageAreas.Add(a);

     

    The coordinates are specified as an array of integers. This array corresponds to the ‘coords’ attribute of the <area> tag. The meaning of the array elements depends on the shape of the area:

     

    Shape

    Coords

    Description

    Circle

    "x1,y1,r"

    x1,y2 are the coordinates of the center of the circle, and r is the radius of the circle.

    Polygon

    "x1,y1,x2,y2...xn,yn"

    Each x,y pair contains the coordinates of one vertex of the polygon.

    Rectangle

    "x1,y1,x2,y2"

    x1,y1 are the coordinates of the upper-left corner of the rectangle and x2,y2 are the coordinates of the lower-right coordinates of the rectangle.

    The ImageAreas property is a collection of MapArea objects. Each MapArea object has properties that specify a ToolTip to be displayed when the user moves the mouse over the area, and an action to be performed when the area is clicked.

    The ImageAreas property has a set of built-in areas, created automatically by the control:

    ·      ChartArea, PlotArea

    ·      AxisX, AxisY, AxisY2

    ·      ChartData (one <area> tag per data point or series)

    ·      ChartLabel (one <area> tag per label)

    ·      Header, Footer

    ·      Legend, LegendItem (one <area> tag per item)

    I hope it helps,

    Regards,

    Andrew

     

    <tomshelley> wrote in message news:203205@10.0.1.98...

    I'm looking for a way to programmatically assign the tooltip text for each piece of chart data.  For instance, I have a stacked bar chart and I want to have the pieces of the stacked bar to all have the same tooltip display that shows the combined total for the stacked bar.

    Another use for this is for programmatically performing a calculation on the data and using the result as a tooltip for each chart data item.  If you know of a way to accomplish this; will you please share your knowledge?

     --
    tomS.



    http://helpcentral.componentone.com/cs/forums/p/74744/203205.aspx#203205

  • 03-26-2008 4:06 PM In reply to

    Re: Programmatically Assign ChartData Tooltip text for C1WebChart

    Well that makes sense; and I looked into that a little bit.  But with this approach, how would i get the image coordinates that correspond with a particular bar on the chart?

    I'll look a bit closer at this tonight; but if you know the answer to this, I'd sure appreciate it if you'd share that information here.


    --
    tomS.

    --
    tomS.
  • 04-07-2008 1:20 PM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 500

    Re: Programmatically Assign ChartData Tooltip text for C1WebChart

    well, you can use the built-in mapping "ChartData" which will put a tooltip over each datapoint or bar, so you don't have to generate each point's MapArea yourself.  This code below assigns the tooltip for each datapoint to show the Y-value and the sum of all points (calculated separately - perhaps with C1WebChart1.ChartGroups[x].ChartData[x].PointData.Statistics? if you're not binding to a datasource)

    1. MapArea ma = C1WebChart1.ImageAreas.GetByName("ChartData");
    2. ma.Tooltip = "Y:{#YVAL} Sum: " + sum;

    hope that helps,
    Greg

    Filed under: ,
  • 08-14-2008 9:50 AM In reply to

    Re: Programmatically Assign ChartData Tooltip text for C1WebChart

    Is it possible to add text and backcolor to these new mapareas? 

     thanks

    Len

Page 1 of 1 (5 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.