Chart Bar Color
pinbot
Texas
I'm trying to set the Color in a Chart Object.
What is the correct field type? I've tried varchar and setting it to "clblue" (like I used to do with FR Studio) as well as int and setting the field value to 0xC0C0C0.
Each time I get an exception "Specified cast is not valid"
Also, Can I use this to color each bar in the series? I have 1 series but would like to color each bar a separate color.
Comments
Also,
What is the correct "Using" statement to access/cast an MSChartObject in script?
:-)
And this may be a chart question outside the scope of this forum.
How come when I select the "excel" palette, it colors each bar in the series (bottom chart) but when I create my own palette (with 16 colors), and select "none" as the series palette, it only displays the first color (top chart)?
it will color each value in a series.
using System.Windows.Forms.DataVisualization.Charting;
you also need to add the System.Windows.Forms.DataVisualization.dll to your report assembly references.
That's what the documentation says.
But if I select ANY other built-in palette, it DOES color each data point in the series. (see the second graph which is from the same data set). Both graphs only have 1 series. The 1st one I set the palette to "none" and the second one to "excel"
How can I acccess the chart in script to set the colors for the datapoints? (using <what>)
Bryan
You can see this behaviour in FR DEMO.
1. Edit the Microsoft Chart Sample.
2. On the Revenue chart, the default is that all the data points are the same color.
3. Double click on the revenue chart. Select Series1.
4. Select the Fills&Border tab and change the palette from "None" to "Excel"
5. You will see that each data point in the same series has a different color.
This does not work for the CustomPalette.
Success!!!!
You're code for converting the data color from the data field did the trick.
I put this as the expression for the series color:
new ColorConverter().ConvertFromInvariantString([SOP.BarColor])
All I really wanted was the first color to be special. It is the color of the customer's logo. Go Figure.
In the data set, I'm only setting the color of the first record in the dataset to be the color shown. I leave the rest of the color values NULL.
For the first bar it uses the color I pass, for the rest it uses the colors from the Excel palette and colors each data point.
Could not be better!
There are two palettes in MS Chart: one is for series (Chart.Palette and Chart.PaletteCustomColors), second is for values (Chart.Series.Palette). Note that there is no custom palette for values, you need to specify the color for each value manually.
ok.
Thanks for the explanation.
Seems strange that you cannot create a custom palette for values.