Showing posts with label legend. Show all posts
Showing posts with label legend. Show all posts

Saturday, February 25, 2012

Chart: legend should not scale with the chart

The legend scales with the Chart. My client would the rectangles in the
legend to be perfect squares. Is this possible?
--
Callidus
Software DesignerYes, this is possible if you turn off the legend on the chart and use a
table instead to "draw" the legend for you. I will post a sample within the
next few days which shows how to do this.
Robert M. Bruckner
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Callidus" <Callidus@.discussions.microsoft.com> wrote in message
news:AE04FCEE-6125-4392-A9D0-FBDB89655532@.microsoft.com...
> The legend scales with the Chart. My client would the rectangles in the
> legend to be perfect squares. Is this possible?
> --
> Callidus
> Software Designer|||The sample RDL is shown at the bottom of this posting. It will require some
careful study to see how it works.
Robert M. Bruckner
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in message
news:e7Fdia%23VFHA.612@.TK2MSFTNGP12.phx.gbl...
> Yes, this is possible if you turn off the legend on the chart and use a
> table instead to "draw" the legend for you. I will post a sample within
> the next few days which shows how to do this.
>
> --
> Robert M. Bruckner
> Microsoft SQL Server Reporting Services
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> "Callidus" <Callidus@.discussions.microsoft.com> wrote in message
> news:AE04FCEE-6125-4392-A9D0-FBDB89655532@.microsoft.com...
>> The legend scales with the Chart. My client would the rectangles in the
>> legend to be perfect squares. Is this possible?
>> --
>> Callidus
>> Software Designer
=========================
<?xml version="1.0" encoding="utf-8"?>
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<RightMargin>1in</RightMargin>
<Author>Robert M. Bruckner</Author>
<Body>
<ReportItems>
<Table Name="table1">
<Height>0.5in</Height>
<ZIndex>1</ZIndex>
<Style />
<Header>
<TableRows>
<TableRow>
<Height>0.25in</Height>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="textbox1">
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingTop>2pt</PaddingTop>
<PaddingRight>2pt</PaddingRight>
</Style>
<ZIndex>3</ZIndex>
<rd:DefaultName>textbox1</rd:DefaultName>
<CanGrow>true</CanGrow>
<Value />
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox2">
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingTop>2pt</PaddingTop>
<PaddingRight>2pt</PaddingRight>
<FontWeight>700</FontWeight>
</Style>
<ZIndex>2</ZIndex>
<rd:DefaultName>textbox2</rd:DefaultName>
<CanGrow>true</CanGrow>
<Value>Legend</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
</TableRow>
</TableRows>
</Header>
<DataSetName>DataSet1</DataSetName>
<Top>0.125in</Top>
<Width>2in</Width>
<TableGroups>
<TableGroup>
<Header>
<TableRows>
<TableRow>
<Height>0.25in</Height>
<TableCells>
<TableCell>
<ReportItems>
<Rectangle Name="rectangle1">
<ZIndex>1</ZIndex>
<Style>
<BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
</Style>
</Rectangle>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="CategoryName">
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingTop>2pt</PaddingTop>
<PaddingRight>2pt</PaddingRight>
</Style>
<rd:DefaultName>CategoryName</rd:DefaultName>
<CanGrow>true</CanGrow>
<Value>=Fields!CategoryName.Value</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
</TableRow>
</TableRows>
</Header>
<Grouping Name="table1_Group1">
<GroupExpressions>
<GroupExpression>=Fields!CategoryName.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<Sorting>
<SortBy>
<SortExpression>=Fields!CategoryName.Value</SortExpression>
<Direction>Ascending</Direction>
</SortBy>
</Sorting>
</TableGroup>
</TableGroups>
<Left>3.25in</Left>
<TableColumns>
<TableColumn>
<Width>0.25in</Width>
</TableColumn>
<TableColumn>
<Width>1.75in</Width>
</TableColumn>
</TableColumns>
</Table>
<Chart Name="chart1">
<ThreeDProperties>
<Rotation>30</Rotation>
<Inclination>30</Inclination>
<Shading>Simple</Shading>
<WallThickness>50</WallThickness>
</ThreeDProperties>
<Style>
<BackgroundColor>White</BackgroundColor>
</Style>
<Legend>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
<Position>BottomCenter</Position>
<Layout>Table</Layout>
</Legend>
<Palette>Default</Palette>
<ChartData>
<ChartSeries>
<DataPoints>
<DataPoint>
<DataValues>
<DataValue>
<Value>=Sum(Fields!UnitsInStock.Value)</Value>
</DataValue>
</DataValues>
<DataLabel />
<Style>
<BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
</Style>
<Marker>
<Size>6pt</Size>
</Marker>
</DataPoint>
</DataPoints>
</ChartSeries>
</ChartData>
<CategoryAxis>
<Axis>
<Title />
<MajorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<Min>0</Min>
</Axis>
</CategoryAxis>
<DataSetName>DataSet1</DataSetName>
<PointWidth>0</PointWidth>
<Type>Bar</Type>
<Top>0.25in</Top>
<Title />
<Width>3in</Width>
<Height>2.5in</Height>
<SeriesGroupings>
<SeriesGrouping>
<DynamicSeries>
<Grouping Name="chart1_SeriesGroup1">
<GroupExpressions>
<GroupExpression>=Fields!CategoryName.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<Sorting>
<SortBy>
<SortExpression>=Fields!CategoryName.Value</SortExpression>
<Direction>Ascending</Direction>
</SortBy>
</Sorting>
<Label>=Fields!CategoryName.Value</Label>
</DynamicSeries>
</SeriesGrouping>
</SeriesGroupings>
<Subtype>Plain</Subtype>
<PlotArea>
<Style>
<BackgroundColor>LightGrey</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</PlotArea>
<Left>0.125in</Left>
<ValueAxis>
<Axis>
<Title />
<MajorGridLines>
<ShowGridLines>true</ShowGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<MajorTickMarks>Outside</MajorTickMarks>
<Min>0</Min>
<Margin>true</Margin>
<Visible>true</Visible>
<Scalar>true</Scalar>
</Axis>
</ValueAxis>
</Chart>
</ReportItems>
<Style />
<Height>3.25in</Height>
</Body>
<TopMargin>1in</TopMargin>
<DataSources>
<DataSource Name="Northwind">
<rd:DataSourceID>f646058b-4784-494d-a09d-27fde13a5679</rd:DataSourceID>
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>data source=(local);initial
catalog=Northwind</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>
<Code> Private Shared colorPalette As String() = {"Green", "Blue",
"Red", "Orange", "Aqua", "Teal", "Gold", "RoyalBlue", "#A59D93", "#B8341B",
"#352F26", "#F1E7D6", "#E16C56", "#CFBA9B"}
Private Shared count As Integer = 0
Private Shared mapping As New System.Collections.Hashtable()
Public Function GetColor(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim c As String = colorPalette(count Mod colorPalette.Length)
count = count + 1
mapping.Add(groupingValue, c)
Return c
End Function
</Code>
<Width>6.5in</Width>
<DataSets>
<DataSet Name="DataSet1">
<Fields>
<Field Name="ProductID">
<DataField>ProductID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="ProductName">
<DataField>ProductName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="SupplierID">
<DataField>SupplierID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="CategoryID">
<DataField>CategoryID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="QuantityPerUnit">
<DataField>QuantityPerUnit</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="UnitPrice">
<DataField>UnitPrice</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="UnitsInStock">
<DataField>UnitsInStock</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="UnitsOnOrder">
<DataField>UnitsOnOrder</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="ReorderLevel">
<DataField>ReorderLevel</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="Discontinued">
<DataField>Discontinued</DataField>
<rd:TypeName>System.Boolean</rd:TypeName>
</Field>
<Field Name="CategoryName">
<DataField>CategoryName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Country">
<DataField>Country</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>Northwind</DataSourceName>
<CommandText>SELECT Products.*, Categories.CategoryName,
Suppliers.Country
FROM Products INNER JOIN
Categories ON Products.CategoryID =Categories.CategoryID INNER JOIN
Suppliers ON Products.SupplierID =Suppliers.SupplierID</CommandText>
</Query>
</DataSet>
</DataSets>
<LeftMargin>1in</LeftMargin>
<rd:SnapToGrid>true</rd:SnapToGrid>
<rd:DrawGrid>true</rd:DrawGrid>
<rd:ReportID>e5564b0f-4fab-4cf7-9cef-bda726589920</rd:ReportID>
<BottomMargin>1in</BottomMargin>
<Language>en-US</Language>
</Report>

Friday, February 24, 2012

Chart legend wrapping

We have very long names for our series that appear in a chart legend so they
appear cut off with an ellipsis (three dots ...) at the end. We noticed
though that if we specify a \n in any one of the series names then they will
all wrap over two lines!
Ideally we would like the series names to all wrap over two lines in the
legend without having to specify \n in one of then - otherwise we would need
to carefully calculate where to add the \n
Is this possible to configure so that the metric names will automatically
wrap over two lines?You could write a function which uses GDI calls to calculate the actual
width of string glyphs based on font name, etc. However, the GDI calls are
usually not 100% accurate.
Another option to consider is to "draw" the legend by using a table report
item, rather using the built-in legend of the chart. Please check this
related newsgroup posting:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=ef87e605-48af-4c87-ac3f-ad43cd5fb1fc&sloc=en-us
Also check this blog posting which includes a link to a sample report.
http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
Robert M. Bruckner
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Matt" <Matt@.discussions.microsoft.com> wrote in message
news:DDB98FDE-3FC8-4926-B318-BD89E7BF0B07@.microsoft.com...
> We have very long names for our series that appear in a chart legend so
> they
> appear cut off with an ellipsis (three dots ...) at the end. We noticed
> though that if we specify a \n in any one of the series names then they
> will
> all wrap over two lines!
> Ideally we would like the series names to all wrap over two lines in the
> legend without having to specify \n in one of then - otherwise we would
> need
> to carefully calculate where to add the \n
> Is this possible to configure so that the metric names will automatically
> wrap over two lines?

Chart Legend Vertical Sizing

I was able to change the chart legend to show the correct information.
However, the words are too long for the column. How do I
1) Increase the width of the column
2) Make it so the Legend Rows can be taller
I cannot increase the size of the chart, as I have 3 charts side by side
with this issue.
Thank you,
msflinxI have the same problem
"msflinx" wrote:
> I was able to change the chart legend to show the correct information.
> However, the words are too long for the column. How do I
> 1) Increase the width of the column
> 2) Make it so the Legend Rows can be taller
> I cannot increase the size of the chart, as I have 3 charts side by side
> with this issue.
> Thank you,
> msflinx

Chart Legend Sorting

I have a chart where I need to sort the legend so the colors appear in the
same order as the colors on the chart. It appears the order the legend
labels appear in is fairly random. To get around this we have added a custom
image below the chart with the colors and label order we need to have,
however this does cause some other issues. Is there a method to what order
the legend labels will appear?
ThanksYou might try something along these lines:
http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx.
--
Michael
"Monte" wrote:
> I have a chart where I need to sort the legend so the colors appear in the
> same order as the colors on the chart. It appears the order the legend
> labels appear in is fairly random. To get around this we have added a custom
> image below the chart with the colors and label order we need to have,
> however this does cause some other issues. Is there a method to what order
> the legend labels will appear?
> Thanks

Chart legend has too much data - how to only show 1 legend

I have created a hybrid bar chart / with line. Basically uses the bars to
show sales for each geographic region. A single line is plotted showing the
sales goal to be reached. The x axis is "Region" The y axis value 1 is total
sales $. I added y value 2 to show the sales goal $ and the legend
automatically got populated with series labels. I only want the x axis
labels to be in the legend.
How can I fix this?NP,
This is not a direct answer to your question, but I got tired of the report
legend and what seemed the lack of configuration and used a nice trick from
the Technical Article: Get More Out of SQL Server Reporting Services Charts
(http://msdn2.microsoft.com/en-us/library/aa964128.aspx) to create my own
legend. The document is excellent, five stars.
If you use the Custom Chart Color Palettes and Legends section from the doc
you will see what I mean. You are able to create your own legend and use what
you want and remove what you don't.
Hope this helps.
Reeves
"NP" wrote:
> I have created a hybrid bar chart / with line. Basically uses the bars to
> show sales for each geographic region. A single line is plotted showing the
> sales goal to be reached. The x axis is "Region" The y axis value 1 is total
> sales $. I added y value 2 to show the sales goal $ and the legend
> automatically got populated with series labels. I only want the x axis
> labels to be in the legend.
> How can I fix this?