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>
Related
I am building following chart
https://jsfiddle.net/marialaustsen/x1s9ndm3/11/
I am trying to create a click function for the All button, but instead of hide the other series and show only one serie, I would like to show all series in the chart when clicking the all button. The most scaleable way of doing this is simply to redraw the chart but I cannot figure out how..
This should be super simple...
I have tried to use the redraw method in a click event
$('#all').click(function () {
chart.redraw();
});
All the code here:
`````
<div id="container1"></div>
<button id="All">All</button>
<button id="2017">2017</button>
<button id="2018">2018</button>
<button id="2019">2019</button>
$(function() {
// Apply the grey theme
Highcharts.setOptions( {
colors: ['#2b908f', '#90ee7e', '#f45b5b', '#7798BF', '#aaeeee', '#ff0066', '#eeaaee', '
#55BF3B', '#DF5353', '#7798BF', '#aaeeee'], chart: {
backgroundColor: {
linearGradient: {
x1: 0, y1: 0, x2: 1, y2: 1
}
, stops: [ [0, '#f5f5f5'], [1, '#F0F0F0']]
}
, style: {
fontFamily: 'Montserrat'
}
, plotBorderColor: '#000066'
}
, title: {
style: {
color: '#00BFB3', textTransform: 'uppercase', fontSize: '20px'
}
}
, subtitle: {
style: {
color: '#007396', textTransform: 'uppercase'
}
}
, xAxis: {
gridLineColor: '#B5B5B9', labels: {
style: {
color: '#007396'
}
}
, lineColor: '#B5B5B9', minorGridLineColor: '#505053', tickColor: '#B5B5B9', title: {
style: {
color: '#007396'
}
}
}
, yAxis: {
gridLineColor: '#B5B5B9', labels: {
style: {
color: '#00BFB3'
}
}
, lineColor: '#B5B5B9', minorGridLineColor: '#505053', tickColor: '#B5B5B9', tickWidth: 1, title: {
style: {
color: '#007396'
}
}
}
, tooltip: {
backgroundColor: 'rgba(0, 0, 0, 0.85)', style: {
color: '#F0F0F0'
}
}
, plotOptions: {
series: {
dataLabels: {
color: '#007396', style: {
fontSize: '13px'
}
}
, marker: {
lineColor: '#333'
}
}
, boxplot: {
fillColor: '#505053'
}
, candlestick: {
lineColor: 'white'
}
, errorbar: {
color: 'white'
}
}
, legend: {
backgroundColor: 'rgba(62,62,62,1)', itemStyle: {
color: '#E0E0E3'
}
, itemHoverStyle: {
color: '#FFF'
}
, itemHiddenStyle: {
color: '#606063'
}
, title: {
style: {
color: '#C0C0C0'
}
}
}
, credits: {
style: {
color: '#666'
}
}
, labels: {
style: {
color: '#707073'
}
}
, drilldown: {
activeAxisLabelStyle: {
color: '#007396'
}
, activeDataLabelStyle: {
color: '#007396'
}
}
, navigation: {
buttonOptions: {
symbolStroke: '#DDDDDD', theme: {
fill: '#505053'
}
}
}
, // scroll charts
rangeSelector: {
buttonTheme: {
fill: '#505053', stroke: '#000000', style: {
color: '#CCC'
}
, states: {
hover: {
fill: '#707073', stroke: '#000000', style: {
color: 'white'
}
}
, select: {
fill: '#000003', stroke: '#000000', style: {
color: 'white'
}
}
}
}
, inputBoxBorderColor: '#505053', inputStyle: {
backgroundColor: '#333', color: 'silver'
}
, labelStyle: {
color: 'silver'
}
}
, navigator: {
handles: {
backgroundColor: '#666', borderColor: '#AAA'
}
, outlineColor: '#CCC', maskFill: 'rgba(255,255,255,0.1)', series: {
color: '#7798BF', lineColor: '#A6C7ED'
}
, xAxis: {
gridLineColor: '#505053'
}
}
, scrollbar: {
barBackgroundColor: '#808083', barBorderColor: '#808083', buttonArrowColor: '#CCC',
buttonBackgroundColor: '#606063', buttonBorderColor: '#606063', rifleColor: '#FFF',
trackBackgroundColor: '#404043', trackBorderColor: '#404043'
}
});
// Create the chart
Highcharts.chart('container1', {
chart: {
type: 'column'
},
title: {
text: 'Feedback per quarter grouped by year'
},
subtitle: {
text: 'Source: '
},
xAxis: {
categories: [
'Q1',
'Q2',
'Q3',
'Q4'
],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Total'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y} feedback</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: '2017',
data: [55, 72, 108, 130]
}, {
name: '2018',
data: [80, 65, 100, 40]
}, {
name: '2019',
data: [45, 34, 67, 24]
}]
}, function(chart) {
// the button action
$('#all').click(function () {
chart.redraw()
})
$('#2017').click(function() {
Highcharts.each(chart.series, function(p, i) {
p.name.includes('2017') ? p.show() : p.hide()
})
})
$('#2018').click(function() {
Highcharts.each(chart.series, function(p, i) {
p.name.includes('2018') ? p.show() : p.hide()
})
})
$('#2019').click(function() {
Highcharts.each(chart.series, function(p, i) {
p.name.includes('2019') ? p.show() : p.hide()
})
})
});
});
How do I redraw or reload the chart onclick the All button?
You need to show series and redraw a chart. The most efficient way is to use the setVisible method on each series with redraw argument set to false and call chart.redraw() outside the loop.
$('#All').click(function() {
Highcharts.each(chart.series, function(s, i) {
s.setVisible(true, false);
});
chart.redraw();
});
Live demo: https://jsfiddle.net/BlackLabel/eztvoqa4/
API Reference:
https://api.highcharts.com/class-reference/Highcharts.Chart#redraw
https://api.highcharts.com/class-reference/Highcharts.Series#setVisible
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',
}
};
}
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 },
I have updated FabricJS version 1.5 to 1.6(beta), then the text shadow effects does not work now. Here is my function. How to fix this issue?
$('#text-shadow-set').change(function (){
if(isText()) {
if(this.checked) {
var tmp = $('#text-shadow-offset-slider').slider('option','value');
var shadVal = (tmp==''||tmp==0) ? 20 : tmp;
currentElement.setShadow({
color: '#000',
blur: 5,
offsetX: shadVal,
offsetY: shadVal
});
canvas.renderAll();
} else {
currentElement.setShadow(null);
canvas.renderAll();
}
}
});
Text and shadows seem to work fine. Check the demo below:
var text = new fabric.Text('Text with Shadow', {
left: 50,
top: 150,
fill: 'red',
strokeWidth: 1,
stroke: 'black',
});
text.setShadow({
color: 'black',
blur: 5,
offsetX: 10,
offsetY: 10,
opacity: 0.5,
});
canvas.add(text);
canvas.renderAll();
DEMO
var canvas = new fabric.Canvas('c');
var text = new fabric.Text('Text with Shadow', {
left: 50,
top: 150,
fill: 'red',
strokeWidth: 1,
stroke: 'black',
});
text.setShadow({
color: 'black',
blur: 5,
offsetX: 10,
offsetY: 10,
opacity: 0.5,
});
canvas.add(text);
canvas.renderAll();
canvas {
border: 1px solid #f00;
margin: 0px;
display: block;
}
<script src="https://rawgit.com/fabricjs/fabric.js/master/dist/fabric.min.js"></script>
<canvas id="c" width="400" height="400"></canvas>
i'm using highcharts for genetating graphs, problem is, highcharts is generating space between border and content of Tooltip and labels of the Pie diagram is visible between that generated space.
can any has solving for my problem.
Please check with below example.
$(function () {
var chart;
$(document).ready(function () {
chart = new Highcharts.Chart({
chart: {
renderTo: 'graf1',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
margin: 40,
text: 'Podíl všech potřeb'
},
tooltip: {
borderWidth: 1,
backgroundColor: "rgba(255,255,255,0)",
borderRadius: 0,
shadow: false,
useHTML: true,
percentageDecimals: 2,
backgroundColor: "rgba(255,255,255,1)",
formatter: function () {
return '<div class="tooltop">'+this.point.name + '<br />' + '<b>' + Highcharts.numberFormat(this.y).replace(",", " ") + ' Kč [' + Highcharts.numberFormat(this.percentage, 2) + '%]</b></div>';
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
zIndex: 1,
enabled: true,
color: '#000000',
connectorWidth: 2,
useHTML: true,
formatter: function () {
return '<span style="color:' + this.point.color + '"><b>' + this.point.name + '</b></span>';
}
}
}
},
series: [{
type: 'pie',
name: 'Potřeba',
data: [
['Firefox', 45.0],
['IE', 26.8], {
name: 'Chrome',
y: 12.8,
sliced: true,
selected: true
}, ['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
}]
});
});
});
.label {
z-index: 1!important;
}
.highcharts-tooltip span {
background-color:white;
border:1px solid green;
opacity:1;
z-index:9999!important;
}
.tooltip {
padding:5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="graf1" style="width: 400px; height: 250px; float:left"></div>
tooltip space between order and content highcharts
SVG tooltip elements can be hidden through:
tooltip: {
borderWidth: 0,
backgroundColor: "rgba(255,255,255,0)",
shadow: false,
Example: http://jsfiddle.net/x8Lq0yr9/1/
This will eliminate the space between border and HTML content.
you are using div class="tooltop" where as tooltop class is nowhere. Also, .highcharts-tooltip is used in highcharts at two places . one at datalables and second in tiiptip.
Unless you want specific border color , you can remove that css class from your code and tooltip loks good.
.tooltipSpan {
opacity:1;
z-index:9999!important;
width:100%;
}
See this Fiddle
Highcharts creates these using svg which makes it so the background shows up underneath certain elements. To avoid this undesired behavior the border and background settings have been turned off and all these are controlled, instead, using html in the formatter function. Using HTML makes it so the background does not show up underneath certain elements.
tooltip: {
backgroundColor: undefined,
borderColor: undefined,
borderWidth: 0,
}