I created a simple pie chart with around 10 items (using C3.js and D3.js). Now, in a second visualization (a table) I want to know the colors of each of the items, to also represent them in the table.
Is it possible to query the chart to receive the item's name and color?
I know I can manually hardcode colors for items and just use the same colors. However, this is not applicable in my case, as the items in the pie chart vary greatly (and I don't know them yet, as it is dependent on the user), hence my question.
Quick look at the source code reveals that you are correct, it's a category10().
Further it retrieves them by a key of "data id", which appears to be the first "column" in it's data input format:
columns: [
['data1', 30, 200, 100, 400, 150, 250], //<-- data1 is id
['data2', 130, 340, 200, 500, 250, 350]
]
You can inspect which are used by:
> chart.internal.color('data1')
"#1f77b4"
> chart.internal.color('data2')
"#ff7f0e"
Related
PowerBi community - help!
I have a heatmap of product failures based on product characteristics. Right now my matrix is sorting my rows incorrectly. Right now from top to bottom, it is reading 1000, 105, 110, 115, 120, 1200, 1250, 130... and I want it to be in the order of 105, 110, 115, 120, 130, 1000, 1200, 1250. I do have these values as "whole numbers" in my data table. But it seems like it is sorting them alphabetically. Thank you for any tips you have!
Product failure heatmap
Data table
edit: Solved - I had to unpivot my data at one point, and when I made my feild parameters I accidentally used my unpivoted data. Therefore, it was using my unpivoted data type of "text." I was able to re do my feild parameters using my original data - and this solved the issue.
Feild parameters unpivoted -> text
fixed heatmap
I want to keep value labels outside my amChart graph. The problem is that when value label value is over 9999 then I cant display it's all content.
In this example values should be:
25,000
20,000
15,000
10,000
5,000
First digit is missing. I am dealing with this only by setting panel's margin
"panelsSettings": {
"marginLeft": 40,
"marginRight": 20,
},
Is there any more convienient way to be sure that labels are fitting? hardcoding margin seems to be overkill.
This is my example chart: https://jsfiddle.net/29w35txy/1/
As I mentioned in the comments above, it seems that this issue is depending on the default Browser font.
So it is working in Chrome (left), but does not work in Firefox (right) for me:
Beside that you can prevent this by increasing marginLeft of your panelsSettings which you are already using:
"panelsSettings": {
"marginLeft": 60,
// ...
},
Here I forked you fiddle to show the result.
My example: http://dojo.telerik.com/irEQo
Problem: When I go about resizing a column I click on the gap between them and drag, at which point the column widths become messed up (See screenshot and video below).
https://vid.me/TmkP
My Fix:
Instead of using fixed width using pixels values, I set the fixed width using percentages.
Example:
Before
{
field: 'statusId',
title: 'Type',
width: 50,
filterable: true,
attributes: {
"class": "someClass"
}
After
{
field: 'statusId',
title: 'Type',
width: '15%',
filterable: true,
attributes: {
"class": "someClass"
}
This happens when you set a fix width to all columns but the sum of all widths does not match the grid's with. So if you have 3 columns all with width 100px, but your grid is 400px wide, the columns are stretched to e.g.133px each. As soon as you 'grab' column, the original size (100px) is used which makes the column jump.
This is a Kendo problem so there is no real solution for this (at least I haven't found one), but there are possibilities to avoid the 'jumping':
You can either set no with for one column, this column then fills the rest of the space.
Or add an empty column as last column which then fills the space while your real columns all keep the size they are set to.
To add an empty column just add
{
field: ""
}
to your columns list.
I am showing multiple Meter Gauges on a single page, in conjunction with Bootstrap, to provide responsiveness. What is obvious is they are all calculating slightly different sizes, so I hoped to use diameter.
Here is my working code:
s1 = [322];
$.jqplot('spend',[s1],{
seriesDefaults: {
renderer: $.jqplot.MeterGaugeRenderer,
rendererOptions: {
min: 100,
max: 500,
intervals:[200, 300, 400, 500],
intervalColors:['#66cc66', '#93b75f', '#E7E658', '#cc6666'],
intervalOuterRadius: 56,
ringColor: '#222',
padding: 3,
tickColor: '#111',
ringWidth: 4,
needleThickness: 11,
shadowOffset: 10,
label: "£"
}
},
title: 'Spend'
});
If I add
diameter:200,
I get no output, and:
'this._center.0' is null or not an object jqplot.meterGaugeRenderer.js, line 616 character 13
'this._center.0' is null or not an object jqplot.meterGaugeRenderer.js, line 616 character 13
I have also tried
diameter:50,
and
diameter:500,
in case I was not providing adequate space, or too much space, but I rather doubt it, as intervalOuterRadius is set at 56, I have also assumed that
diameter:200
is correct syntax given that
intervalOuterRadius:56
(as well as various other values) is correct. I cannot find anyone else who has had this problem, and have had no response on the jqplot google group.
Oh yeah, and I'm primarily writing for IE8 atm but it will need to be used on ie11 in time.
I'm currently working with highcharts to generate a chart that has several pie charts inside. So basically a data set that has 3 or 4 series, each with their own name and data. The charts render perfectly, and now I would like to place the series name above each pie in the chart. The only way I can see to do this is with the label property. The issue that I'm having is that the series are positioned within the chart with percentages. A series looks like:
series: [
{
name: 'series name',
data: [25, 25, 50],
center: ['33%']
}
]
So now I want to apply a label to that series, but I'm having issues deriving what the "style" property should be set to. using the series center (which I was hoping would position the label directly over the series pie) doesn't seem to work.
Any ideas?