Setting the AmCharts colors Globally - amcharts

When using AmCharts let's say Pie chart, there are out of the box colors applied to the items which is not spread correctly and colors of the same family are sequentially applied which makes the charts with large number of items look pretty odd.
The sequence is always "red" first, then dark orange, light orange, yellow, 2 greens, 3 blues, etc.
I'd like to change this pattern a bit, is there a global setting for configuring this in AmCharts 3?

To achieve this use property “colors” of AmCoordinateChart object, as described here: http://docs.amcharts.com/3/javascriptcharts/AmCoordinateChart#colors
AmCoordinateChart is the parent object of AmChart What this means in practice is that when you define your chart (by .makeChart or other means), you add a “color” property with your array of colors to the AmChart object.
If the chart requires more colors than specified in the array, then AmCharts generates extra colors automatically. So you can both change the pattern, as you request, and extend it if needed.

Related

Alignment and Colors of Data Point Outliers of Box Plot

Is it possible to align the data points and outliers of box plot in one straight line like in center of box plot?
Additionally, can I color the data points?
The current and the desired screen shot are attached with it.
You can use
.dataWidthPortion(0)
to not spread the points out at all. Documentation.
General advice on changing the color or style of anything, if there is no accessor for it:
Look for the chart in the chart selectors wiki, or if it's not there, inspect the item you want to change in the developer tools and find out what SVG tag and CSS class the item has. In this case, it's circle.data
Add a pretransition handler which selects the items you want, and changes them:
var cc = d3.scaleOrdinal().range(d3.schemeDark2);
bp02.on('pretransition', chart => {
chart.selectAll('circle.data').attr('fill', function(d) {
const boxDatum = d3.select(this.parentNode).datum();
return cc(boxDatum.value[d]);
})
});
In this case, we're creating an ordinal scale to map the available data to the colors in a color scheme.
The interesting question is here is what data to bind to the color of the dots, and how to get that data.
A box plot's data consists of an array of key/value pairs where each value is a Y value. When the box plot draws it will bind each circle.dot element to the index of the data in the array.
So we need to get the array that is bound to the box. Luckily d3.select(this.parentNode).datum() will give us the key/value pair for the box.
For this example, we are encoding the color based on the Y value, which we get by looking inside boxDatum.value. You don't specify how you want the dots colored but this shows the data that is available.

How to change z-index of amCharts axisGuides

I am trying to visualize a filter in my stock chart by graying out data points which are affected by the filter. I'm using axisGuides on my valueAxis in order to achieve this. However, I also have axisGuides on my categoryAxis and unfortunately, these now disappear beneath my horizontal axisGuides.
Is there any way to change the z-index of those guides? Or does anybody have a different solution?
I have adapted an official amCharts example to show what I mean:
http://jsfiddle.net/wq97ujne/
I'm setting plotAreaFillColors": '#ababab' on my stock panel and fillColor: "#ffffff" on my valueAxisGuide.
I would like for the vertical guides to be drawn in front of and not behind the white area.
You need to set above: true for the categoryAxisGuides.

nvd3 multibar chart show values

I have a stacked multiBarChart created with nvd3: jsfiddle is here: http://jsfiddle.net/e3kxZ/5/
(1) How can I get each region to display its value near its top?
I tried showValues(true) but I don't think that's supported in multiBarChart.
Other concerns I have are:
(2) how to set the text color so that it contrasts enough with the region (dark vs light colors), and
(3) how to keep the text labels from overlapping if any particular region is small.
I found an svg example (doesn't use nvd3) -- it assumes a static size for the chart, but I'd prefer to use something convenient and dynamic like nvd3.
Alternatively, if there is a different js library that supports this out of the box, please let me know and I'll use that instead.
Thanks in advance for any help!

dc.js cap ordinal bar chart

dc.js has a Cap mixin which allows one to limit the number of groups and display the remainder in an "others" group. How does one access this behavior or exclude the remainder in a bar chart?
I am using a bar chart as I want to show a top 5 with stacked data. For example, the top 10 car manufacturers based on the total of fleet and private sales (in separate stacks). I am using a function to dynamically generate 5 ordinals (i.e. car manufacturers) for the x axis in the order that I want, and the graph generates nearly as expected. However, a separate bar containing the values that don't fit into one of the x values is placed at the start of the graph.
I've added a snapshot of the chart below. Note that I've rotated it with renderlet so it's on its side.
How do I remove the extraneous bar (at the top)?
If not possible, I may contemplate using two row charts side by side with one flipped so that the origin is on the right.
Sigh, the bar chart is not capped, and the row chart is not stacked. Hope to fix that.
That extraneous bar looks... not right.
With capped charts, you can eliminate the "others group" by setting the othersGrouper falsy. With the bar chart you would have to implement a "fake group" using the techniques documented here:
https://github.com/dc-js/dc.js/wiki/FAQ#filter-the-data-before-its-charted
... at least for now.

Powerpoint - want to define a color palette that is NOT a color scheme

I import Spotfire graphics into Powerpoint quite frequently. Spotfire has its own specific color palette, which aren't the standard colors used in powerpoint, at least I don't think so.
I often must create my own legend or for other reasons match the spotfire color palette, and I do this by entering the RGB codes for the spotfire colors. I would like to do this one time and have the spotfire color palette always available in powerpoint without having to re-type.
I do not think I want to use a color theme, because I want my colors to stay consistent if I end up using different templates (themes). That is, I don't want to call spotfire default blue "Accent 1", because if I change background templates (themes) I think it will overwrite Accent 1 with the new template's Accent 1.
So I want a color palette that is always available to me regardless of what theme I choose.
Any thoughts?
You're dismissing themes for all the right reasons. They wouldn't work for what you're after. You'd pretty much need to buy or write an add-in to do what you want.
For example, it might install n buttons on the toolbar/ribbon, where n = the number of colors you need on your palette. When the button is clicked it sets the fill, for example, of the currently selected shape/shapes to the appropriate color.
You could have different sets of buttons for fill, outline etc, or have the code figure out whether the user has pressed, eg the CTRL key. Click = set the fill, CTRL+Click = set the outline.
Because I was curious I decided to attempt to create a simple Add-In that will allow you to select a chart, series in the chart, and then apply colors.
You can download from Google Docs (revised link)
https://docs.google.com/file/d/0B1v0s8ldwHRYMFFPZ29FNmI0TkE/edit?usp=sharing
The file is saved as a PPTM to expose the code modules. Save As a PPAM and load the Add-in; it will be available from the Add-Ins command bar. I have tested briefly and seems to be working.
Here's the nuts & bolts of it:
First declared several custom colors as Public Const variables. These can be modified using the long value (converted from RGB) to suit whatever you need.
The macro requires that the selection be a Shape, and further that the Shape .HasChart = True. There is some logic to trap these conditions.
A user form has a ComboBox that populates with a list of Series from the selected chart, and 8 CommandButtons colored for each of the defined colors, will send that color to the chosen series.
You could add additional CommandButtons and colors as needed, or tweak the existing code to suit your specific needs.
Although the slide templates have a default color theme attached to them, you can switch slide templates and still use any XML color scheme at your disposal.

Resources