How to set zones of values usingOWC10 Chart?

P

Praded

Hi all!

There is a problem with subj. E.g. I want to take values to zones of
values. Perhaps value axis has values from 0 to 100%. I want one zone
0-50%, other 50-75% and other 75-100%. Is there any way to set
different colours of those zones or another mode to make zones
visible? I have tried to set coloured image as background of plot
area. Not supported... I have tried to colour parts of value axis.
Axis has only single colour. I have tried to colour gridlines of value
axis with different colours. Again gridlines have only single colour.
I have tried to add new category with single series as 100% stacked
bar ( all my other series are clustered bars ). After that all the
chart became stacked bar with strange looks etc.

Is there any solution at all?

Thanks!

Best regards,
Maks.
 
S

sjurba

I'm doing a similar thing. You should check out FormatMap!

If you have the Microsoft Office Web Components Visual Basic refference
you should check out the documentation for FormatMap!

Or i can just append it here:
The ChFormatMap object allows formatting to represent a range of data
values. The ChFormatMap object can be used provide visual cues that
highlight certain portions of your data.

Using the ChFormatMap object
The FormatMap property of the ChSeries object returns a
ChFormatMap object.

Format maps contain one or more ChSegment objects, each of which can be
formatted independently.

The following example binds Chartspace1 to the Order Details table in
the SQL Server Northwind database. Then, a format map is created. The
smaller values are displayed in white, then larger values are displayed
in a light shade of blue, and finally the largest values in the chart
are displayed in dark blue.

Sub Window_Onload()

Dim serSeries1
Dim segSegment1
Dim chConstants

Set chConstants = ChartSpace1.Constants

' The following two lines of code bind Chartspace1 to the Order Details table in the
' Northwind SQL Server database.
ChartSpace1.ConnectionString = "Provider=SQLOLEDB.1;persist Security Info=TRUE;User ID=sa;Initial " & _
"Catalog=Northwind;Data Source=ServerName;PASSWORD=;"
ChartSpace1.DataMember = "Order Details"

' The following two lines of code bind Chartspace1 to the Quantity and ProductID fields
' in the Order details table.
ChartSpace1.SetData chConstants.chDimCategories, chConstants.chDataBound, "ProductID"
ChartSpace1.SetData chConstants.chDimValues, chConstants.chDataBound, "Quantity"

' Create a format map.
ChartSpace1.SetData chConstants.chDimFormatValues, chConstants.chDataBound, "Quantity"

' Set a variable to the first series in the first chart in Chartspace1.
Set serSeries1 = ChartSpace1.Charts(0).SeriesCollection(0)

' Add a segment to the format map.
Set segSegment1 = serSeries1.FormatMap.Segments.Add

' Specify that the divisions in formatting be created automatically.
segSegment1.HasAutoDivisions = True

' Measure the segment boundaries based upon a percentage.
segSegment1.Begin.ValueType = chConstants.chBoundaryValuePercent
segSegment1.End.ValueType = chConstants.chBoundaryValuePercent

' Set the beginning value to 0%, and the ending value to 100%.
segSegment1.Begin.Value = 0
segSegment1.End.Value = 1

' Format the interior of the matching values.
segSegment1.Begin.Interior.Color = "White"
segSegment1.End.Interior.Color = "Blue"

End Sub
The following example binds Chartspace1 to the Order Details table in
the Northwind database. Then, two segments are created. The first
segment highlights the lowest 10% of values in the first series in the
chart. The second segment highlights the top 20% of values in the first
series in the chart.

Sub Window_Onload()

Dim serseries1
Dim segBottom10Pct
Dim segTop20Pct
Dim chConstants

Set chConstants = ChartSpace1.Constants

' The following two lines of code bind Chartspace1 to the Order Details table in the
' Northwind SQL Server database.
ChartSpace1.ConnectionString = "Provider=SQLOLEDB.1;persist Security Info=TRUE;User ID=sa;Initial " & _
"Catalog=Northwind;Data Source=ServerName;PASSWORD=;"
ChartSpace1.DataMember = "Order Details"

' The following two lines of code bind Chartspace1 to the Quantity and ProductID fields
' in the Order details table.
ChartSpace1.SetData chConstants.chDimCategories, chConstants.chDataBound, "ProductID"
ChartSpace1.SetData chConstants.chDimValues, chConstants.chDataBound, "Quantity"

' Create a format map.
ChartSpace1.SetData chConstants.chDimFormatValues, chConstants.chDataBound, "Quantity"

' Set a variable to the first series in the first chart in Chartspace1.
Set serseries1 = ChartSpace1.Charts(0).SeriesCollection(0)

' Add a segment to the format map. This segment will
' represent the bottom 10% of values in the chart.
Set segBottom10Pct = serseries1.FormatMap.Segments.Add

' Measure the segment boundaries based upon a percentage.
segBottom10Pct.Begin.ValueType = chConstants.chBoundaryValuePercent
segBottom10Pct.End.ValueType = chConstants.chBoundaryValuePercent

' Set the beginning value to 0%, and the ending value to 10%.

segBottom10Pct.Begin.Value = 0

segBottom10Pct.End.Value = 0.1

' Format the interior of the matching values.
segBottom10Pct.Begin.Interior.Color = "red"
segBottom10Pct.End.Interior.Color = "red"

' Add a segment to the format map. This segment will
' represent the top 20% of values in the chart.
Set segTop20Pct = serseries1.FormatMap.Segments.Add

' Measure the segment boundaries based upon a percentage.
segTop20Pct.Begin.ValueType = chConstants.chBoundaryValuePercent
segTop20Pct.End.ValueType = chConstants.chBoundaryValuePercent

' Set the beginning value to 80%, and the ending value to 100%.
segTop20Pct.Begin.Value = 0.8
segTop20Pct.End.Value = 1

' Format the interior of the matching values.
segTop20Pct.Begin.Interior.Color = "green"
segTop20Pct.End.Interior.Color = "green"

End Sub
 
P

Praded

Thnks a lot, sjurba!

It's not exactly what I want but at least something like that...
I see that all my FormatMap segments are added into legend. I'm trying
to hide them e.g:

addedChart.Legend.LegendEntries[1].Visible = false;

where addedChart is OWC10.ChChart object. But I get error every time
when trying to access addedChart.Legend.LegendEntries collection (
even when try to get addedChart.Legend.LegendEntries.Count )...

Unspecified error
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException:
Unspecified error

Do you know what it means??? What's wrong???

Cheers,
Praded
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top