Google Charts hAxis tooltip - css

I'm using Google Charts.
I'm trying to display 15 stores and the number of clicks on each one.
Now that's is working perfectly.
My issue here is in the hAxis. As you can see the stores' names are incomplete, which is fine, but when i hover on an incomplete name, the tooltip is showing me an empty yellow box as shown in the picture below.
If i select the context of this tooltip, then i can read the full name:
My question is:
Is it possible to change the text color in this tooltip in order to read it?
Thanks.

to modify the axis tooltip, you can modify the following css classes...
.goog-tooltip {
background-color: cyan;
color: magenta;
font-weight: bold;
}
.goog-tooltip > div {
background-color: lime !important;
}
see following working snippet...
google.charts.load('current', {
callback: drawChart,
packages: ['corechart']
});
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Q1');
data.addColumn('number', 'Q2');
data.addColumn('number', 'Q3');
data.addColumn('number', 'Q4');
data.addRow(['January 2016', 500, 100, 1200, 1000]);
data.addRow(['February 2016', 500, 100, 1975, 1000]);
data.addRow(['March 2016', 500, 100, 1200, 1000]);
data.addRow(['April 2016', 500, 100, 1200, 1000]);
// find v-axis max value
var vAxisMax = null;
for (var i = 1; i < data.getNumberOfColumns(); i++) {
var range = data.getColumnRange(i);
vAxisMax = vAxisMax || Math.ceil(range.max / 1000) * 1000;
vAxisMax = Math.max(vAxisMax, Math.ceil(range.max / 1000) * 1000);
}
// add buffer for annotation
vAxisMax += 400;
var options = {
backgroundColor: '#000000',
chartArea: {
top: 12,
bottom: 24,
left: 72
},
legend: {
position: 'none'
},
colors: ['#9427E0'],
hAxis: {
slantedText: true,
textStyle: {
color: '#ffffff'
}
},
vAxis: {
title: 'Amount',
viewWindow: {
max: vAxisMax
}
},
bar: {
groupWidth: '90%'
},
annotations: {
style: 'point',
alwaysOutside: true
},
width: 1100,
height: 300
};
var view = new google.visualization.DataView(data);
view.setColumns([
0,
1, { calc: "stringify", sourceColumn: 1, type: "string", role: "annotation" },
2, { calc: "stringify", sourceColumn: 2, type: "string", role: "annotation" },
3, { calc: "stringify", sourceColumn: 3, type: "string", role: "annotation" },
4, { calc: "stringify", sourceColumn: 4, type: "string", role: "annotation" }
]);
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(view, options);
}
.goog-tooltip {
background-color: cyan;
color: magenta;
font-weight: bold;
}
.goog-tooltip > div {
background-color: lime !important;
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

Try slantedTextAngle
hAxis: {direction:1, slantedText:true, slantedTextAngle:90 },

Related

How can I decrease the height of the PieChart Grid?

PieChart
How can I decrease the height of the PieChart Grid?
I'm using jqplot and javascript. This is what I have:
function skinPie() {
this.cfg.grid = {
background: '#FF0000',
borderColor: '#FF0000',
gridLineColor: '#F5F5F5',
shadow: false
};
this.cfg.axesDefaults = {
rendererOptions: {
textColor:'#0c0c0c',
}
};
this.cfg.seriesDefaults = {
renderer: $.jqplot.PieRenderer,
shadow: false,
lineWidth: 1,
markerOptions: {
shadow: false,
size: 7,
style: 'circle',
}
};
}

Setting individual color for each part of Box Plot in Highchart

I would like to have top of the box and bottom of the box in different colors, and also top of the whisker and bottoom of the whisker in different color for each box (region).
But all of the lines in the box are in the same color (red) and top and bottom of the whisker are in the same color (green)
Live demo with steps to reproduce
Highcharts.chart('container', {
chart: {
type: 'boxplot'
},
title: {
text: 'All Patients'
},
legend: {
enabled: true
},
xAxis: {
categories: ['Asia Pacific', 'Europe', 'Latin America', 'North America', 'SWAC'],
title: {
text: ' '
}
},
yAxis: {
title: {
text: 'Annual Center Volume 2016'
},
tickInterval: 5,
min: 0,
max: 75
//plotLines: [{
// value: 932,
// color: 'red',
// width: 1,
// label: {
// text: 'Theoretical mean: 932',
// align: 'center',
// style: {
// color: 'gray'
// }
// }
//}]
},
plotOptions: {
boxplot: {
fillColor: '#F0F0E0',
lineWidth: 2,
upperQuartileColor: 'green',
lowerQuartileColor: 'green',
medianColor: '#0C5DA5',
medianWidth: 3,
stemColor: '#A63400',
stemDashStyle: 'solid',
stemWidth: 1,
whiskerColor: '#3D9200',
whiskerLength: '20%',
whiskerWidth: 3
}
},
series: [{
name: 'Region Runs',
showInLegend: false,
color: 'red',
data: [
[2, 4, 18, 43, 53],
[5, 9, 16.5, 32, 52],
[1, 3, 6, 11.5, 21],
[3, 9, 20, 38, 73],
[1, 2, 8, 16, 20]
],
tooltip: {
headerFormat: '<em>Experiment No {point.key}</em><br/>'
}
},
{
name: '75th Percentile',
type: 'line',
color: 'red',
marker: {
symbol: 'square'
},
},
{
name: 'Median',
type: 'line',
color:'#0C5DA5',
marker: {
symbol: 'square'
},
},
{
name: '25th Percentile',
type: 'line',
color: 'red',
marker: {
symbol: 'square'
},
},
{
name: '90th percentile',
type: 'line',
color: '#3D9200',
marker: {
symbol: 'square'
},
},{
name: '10th percentile',
type: 'line',
color: '#3D9200',
marker: {
symbol: 'square'
},
}
]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-3d.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
Box Plot Charts -->
<div id="pdfContentHolder" style="margin:auto; width: 720px; height: 800px;">
<div id="container" style="min-width: 310px; height: 400px; max-width: 800px; margin: 0 auto" >
</div>
</div>
https://jsfiddle.net/hew8nq5u/
Thanks in advance guys!
Currently it's not possible in Highcharts to have box bottom and top in different colors. Same with top and bottom whiskers. Here is an explanation and enhancement proposition from github issue (https://github.com/highcharts/highcharts/issues/6796):
Currently each box is a single SVG shape and a border is applied by
stroke parameter which cannot be "separated" for smaller edges. As a
result, you can apply only single color.
Your goal requires a rebuild core of boxplot, so we cannot threat it
as a bug, but feature request.

how to customize vAxis gridlines become dash with google API

I'm trying to customize vAxis gridlines become dash. But, it didn't run very well, everytime I change stroke-dasharray value in css it still blur.
please, is someone know how to change vAxis gridline into dash?
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawBasic);
function drawBasic() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);
var options = {
width:'100%',
focusTarget: 'category',
backgroundColor: 'transparent',
chartArea: {
left: 20,
top: 10,
width: '100%',
height: '70%'
},
bar: {
groupWidth: '70%'
},
hAxis: {
textStyle: {
fontSize: 9,
color:'#929496'
}
},
vAxis: {
baselineColor: '#e6e6e6',
gridlines: {
color: '#e6e6e6',
count: 9
},
textStyle: {
fontSize: 9,
color:'#929496'
}
},
legend: {
position: 'bottom',
textStyle: {
fontSize: 9,
color:'#929496'
}
},
animation: {
duration: 300,
easing: 'out',
startup: true
}
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
#chart_div svg > g:nth-child(3) > g:nth-child(2) > g:first-child rect{
fill: none;
stroke-width: 1;
stroke: #ddd;
stroke-dasharray: 5 5;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

base chart slice color on series value?

Right now I'm using a custom palette to display warning level counts in a pie chart. However, occasionally an alarm comes in with an unexpected severity which messes up the colors. I would like to set up some CSS classes like warningPie, criticalPie or minorPie with orange, red and yellow respectively. Then, I'd like to use the series label text to apply the class.
I don't see anything in the dxchart documentation that would make this possible. Does anyoe have any ideas?
Here is my full chart code if anyone is curious.
dxPieChart: {
dataSource: fieldValueCount(['severity']),
palette: ['#CC3300', '#FF9900', '#FFFF00', '#33CC33', '#0066FF'],
animation: true,
legend: {
backgroundColor: '#FCFCFC',
border: {
color: 'black',
width: .5,
visible: true,
cornerRadius: 10
},
visible: false
},
series: [{
type: 'doughnut',
argumentField: 'severity',
valueField: 'count',
label: {
visible: false,
font: {
size: 12,
color: 'black'
},
radialOffset: -15,
backgroundColor: 'rgba(0,0,0,0)',
connector: {
visible: false,
width: 0.5
},
position: 'inside',
customizeText: function(arg) {
globalTest = arg;
return arg.value + ' (' + arg.percentText + ')';
}
},
border: {
color: 'black',
width: .5,
visible: true
},
hoverStyle: {
border: {
color: 'black',
width: .5,
visible: true
}
}
}],
tooltip: {
enabled: true,
color: 'cornflowerblue',
font: {
size: 14
},
customizeText: function(arg) {
globalTest = arg;
var content = arg.argumentText + '<br>' + arg.value + ' (' + Math.round(arg.percent * 100) + '%)';
return content
}
},
title: {
text: ' ',
font: { size: 14 },
horizontalAlignment: 'center'
}
}
You can use customizePoint and customizeLabel options in the pie chart.

ASP.NET Calendar

I have a problem with calendar,I want to paint special days different color For example
On calendar
03.06.2011 Day--->blue
04.06.2011 day---->red
12.06.2011-04.07.2011 Days ----> yellow
More than one color I want to use selected day
You can use javascript to do that,
Refer to JSFiddle Here
You can add custom special day,
$(document).ready(function () {
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-07-04',
editable: true,
events: [{
title: 'All Day Event',
start: '2014-07-01'
}, {
title: 'Long Event',
start: '2014-07-07',
end: '2014-07-10'
}, {
id: 999,
title: 'Repeating Event',
start: '2014-07-09T16:00:00'
}, {
id: 999,
title: 'Repeating Event',
start: '2014-07-16T16:00:00'
}, {
title: 'Meeting',
start: '2014-07-12T10:30:00',
end: '2014-07-12T12:30:00'
}, {
title: 'Lunch',
start: '2014-07-12T12:00:00'
}, {
title: 'Birthday Party',
start: '2014-07-13T07:00:00'
}, {
title: 'Click for Google',
url: 'http://google.com/',
start: '2014-07-28'
}],
eventAfterAllRender: function (view) {
//Use view.intervalStart and view.intervalEnd to find date range of holidays
//Make ajax call to find holidays in range.
var fourthOfJuly = moment('2014-07-04','YYYY-MM-DD');
var holidays = [fourthOfJuly];
var holidayMoment;
for(var i = 0; i < holidays.length; i++) {
holidayMoment = holidays[i];
if (view.name == 'month') {
$("td[data-date=" + holidayMoment.format('YYYY-MM-DD') + "]").addClass('holiday');
} else if (view.name =='agendaWeek') {
var classNames = $("th:contains(' " + holidayMoment.format('M/D') + "')").attr("class");
if (classNames != null) {
var classNamesArray = classNames.split(" ");
for(var i = 0; i < classNamesArray.length; i++) {
if(classNamesArray[i].indexOf('fc-col') > -1) {
$("td." + classNamesArray[i]).addClass('holiday');
break;
}
}
}
} else if (view.name == 'agendaDay') {
if(holidayMoment.format('YYYY-MM-DD') == $('#calendar').fullCalendar('getDate').format('YYYY-MM-DD')) {
$("td.fc-col0").addClass('holiday');
};
}
}
}
});
});
For changing the colour, you can edit background on .holiday in css file
body {
margin: 0;
padding: 50px 0 0 0;
font-family:"Lucida Grande", Helvetica, Arial, Verdana, sans-serif;
font-size: 14px;
}
#calendar {
width: 100%;
}
.holiday {
background: lightgray;
}
Hope it can help you

Resources