secondary axis title in Google chart's comboChart not working - charts

chart.draw(data,{
colors:[self.model.get("color"), '#FF0000'],
height: 600,
title: self.model.get("title"),
chartArea: { width:'80%',height:'80%'},
legend: {position: 'bottom'},
animation:{
startup: true,
duration: 500,
easing: 'inAndOut',
},
vAxis:{
0:{
title:self.model.get("x_axis_label")
},
1:{
title:"Temperature"
}
},
hAxis:{
title:self.model.get("x_axis_label"),
slantedText: false,
slantedTextAngle: 0
},
series:
{
0: {
type:'bars',
targetAxisIndex:0
},
1: {
type:'line',
targetAxisIndex:1
}
}
});
I have two vertical Axis(Temperature and KWh). Every thing works except the title of vertical axis are not shown on the chart. I have defined vAxis in the options and targetAxisIndex inside series. I searched google and could not find anything except that vAxis should have 0:{} and 1:{} for two vertical axis.

when using multiple y-axis, need to use --> vAxes -- with an e -- not vAxis
This property can be either an object {} or an array []
object...
vAxes: {
0: {
title: self.model.get("x_axis_label")
},
1: {
title: "Temperature"
}
},
array...
vAxes: [
{
title: self.model.get("x_axis_label")
},
{
title: "Temperature"
}
],

Related

ECharts Baidu how to display labels in negative value as positive value?

I am using ECharts Baidu to generate charts. I am using a tornado chart to display the force of left and right arm. The force of the left arm is displayed at the left side and right arm at the right side. Is there a way display the negative value of the label and the axis as positive? I can always hide the axis value so as long as the solution can make the graph to display negative as positive label, I will mark it as solution.
https://echarts.baidu.com/echarts2/doc/example/bar5.html#-en
var option= {
title: {
},
grid: {
top: '10%',
bottom: '25%',
left: '20%',
right: '10%',
},
tooltip: { triggerOn: 'click' },
xAxis: [
{
type: 'value',
name: 'Newton',
nameLocation: 'center',
nameTextStyle: {
padding: 10
},
}
],
yAxis: [
{
axisTick: { show: false },
data: ['FEB']
}
],
barWidth: 40,
series: [
{
type: 'bar',
stack: 'feb',
label: {
normal: {
show: true,
position: 'top',
}
},
data: [{ value: Number(data2[0].left) * -1 }], //the value is from the ajax call
itemStyle: { color: 'gray' }
},
{
type: 'bar',
stack: 'feb',
label: {
normal: {
show: true,
position: 'top'
}
},
data: [Number(data2[0].right)],
itemStyle: { color: '#F26718' },
},
],
textStyle: {
fontWeight: 'bold',
color: 'black'
}
}
chart.setOption(option);
})
try with this:
label: {
normal: {
show: true,
position: 'top',
formatter: function (params) {
return Math.abs(params.value[1]);
}
}
}
this example assumes that the data you passed to the chart is an array like [x, y]. if your input data is different, put a breakpoint inside the formatter function e see how "params" is structured.

Kendo chart with normal and Logarithmic scale

I´m trying create a chart with a normal decimal scale on the left and a logarithmic scale on the right side.
the sample shows approximately my result, the only thing missing is that on the scale on the right side I need to present the value of 1000Hz at the exact middle point. (360 line)
function createTympaniHzChart() {
$("#chart5").kendoChart({
title: {
text: "..."
},
series: [{
colorField: "valueColor",
overlay: { gradient: "none" },
border: {
width: 0,
color: ""
},
data: [
{ value: 720, valueColor: "#C60C30" },
{ value: 355, valueColor: "#FFBE25" },
{ value: 340, valueColor: "#2EA1FF" }
]
}],
tooltip: {
visible: true,
format: "{0:0}",
template: "#= value #°"
},
categoryAxis: {
title: {
text: "Lorem Ipsum",
color: "#4D4D4D"
},
majorGridLines: {
visible: false
},
categories: ["A...", "B...", "C..."],
line: {
visible: false
},
axisCrossingValues: [0, 10]
},
valueAxis: [{
title: {
text: "° Insertion Depth",
color: "#4D4D4D"
},
max: 720,
majorUnit: 180,
line: {
visible: false
},
labels: {
format: "{0}°",
position: "start"
}
},
{
title: {
text: "° Pitch (Hz)",
color: "#4D4D4D"
},
max: 10000,
min: 100,
majorUnit:9900,
reverse: true,
line: {
visible: false
},
labels: {
format: "{0}Hz",
position: "end"
}
}
]
});
}
Is there any other way to add this value?
I manage t solve the issue with a custom function for the data and adding type: "log" property to the valueAxis.
Add this to the valueAxis:
data: fibonacciSequence()
The function:
function fibonacciSequence() {
for (i = 100; i <= 10000; i = i * 10) {
var fibAxisValues = [];
fibAxisValues.push(i);
}
return fibAxisValues;
}

How to hide label in markLine of series-line in Echarts?

How to hide label in markLine of series-line in Echarts? Or how to change label style?
I tried label: false, not working.
series: [
markLine: {
silent: true,
symbol: false,
label: false,
data: [{
yAxis: 100
}, {
yAxis: 400
}],
lineStyle: {
normal: {
type: "solid",
color: "red"
}
}
}
]
It should be:
series: [
markLine: {
label: {
normal: {
show: false
}
}
}
]
normal is the style when not mouse over or touch down. Otherwise, it would be emphasis.
Please refer to doc.

jqplot date axis from timestamp

I'm trying to get a x-axis with dates on it. The x data is a timestamp. Somehow I can't get it right.
The line has values like:
line = [[1334856823000, 2], [1334856853000, 1], [1334856883000, 0], [1334856913000,4],[1334856914000, 13], [1334856943000, 16], [1334856973000, 23], [1334857003000, 24], [1334857033000, 36], [1334857063000, 14], [1334857093000, 1]]
$.jqplot('container', [line],
{ title: "Snelheidsgrafiek",
axes: {
xaxis: {
rederer: $.jqplot.DateAxisRenderer,
rendererOptions: {tickRenderer: $.jqplot.canvasAxisTickRenderer},
tickOptions: {formatString: '%H:%M'}
},
yaxis: {
min: 0
}
}
});
Now it displays just %H:%M as the label.
I tried many variations, but can't get it going.
Here it goes.
Your problem is that the tickRenderer: $.jqplot.CanvasAxisTickRenderer should be on the same level as renderer, and not inside rendererOptions.
Please see the jsfiddle.
EDIT
Also you are missing an import of CanvasTextRenderer which the CanvasAxisTickRenderer uses and you forget to start with a capital letter C, like so: $.jqplot.CanvasAxisTickRenderer.
give this a try. this is copied in a hurry out of a working code. I stripped out a lot to give you a better overview. Maybe it is missing a bracket here and there but it should give you an idea of what to set up and how the affected variables. This works 100% for sure.
Make sure to include the needed Javascript libraries aswell.
If you need more details, let me know...
<script type="text/javascript">(function($) {
var indizes;
var plot1;
$(document).ready(function() {
$(function() {
$(document).ready(function() {
indizes = [["2011-12-31",0.00],["2012-01-31",6.25],["2012-02-28",12.56],["2012-03-31",17.62],["2012-04-30",18.72],["2012-05-31",12.44],["2012-06-30",15.14],["2012-07-31",20.27],["2012-08-31",20.82],["2012-09-30",24.47],["2012-10-31",25.68],["2012-11-30",26.41],["2012-12-31",28.43],["2013-01-31",32.76],["2013-02-28",36.82],["2013-03-31",42.29],["2013-04-30",43.14],["2013-05-31",45.87],["2013-06-30",40.68],["2013-07-31",50.58],["2013-08-31",46.00],["2013-09-29",56.20],["2013-10-02",55.40]]; ;
draw_first();
function draw_first() {
plot1 = $.jqplot("chartdiv", [indizes], {
seriesColors: ["rgba(0, 189, 255, 1)"],
title: '',
grid: {
background: 'rgba(57,57,57,0.0)',
drawBorder: false,
shadow: false,
gridLineColor: '#333',
gridLineWidth: 1
},
legend: {
show: true,
placement: 'inside',
location: 'nw'
},
seriesDefaults: {
rendererOptions: {
smooth: false,
animation: {
show: true
}
},
showMarker: true,
pointLabels: {show: pointlabels},
markerOptions: {
style: 'filledSquare'
}
},
series: [
{
label: 'Indizes'
}
],
axesDefaults: {
rendererOptions: {
baselineWidth: 2,
baselineColor: '#444444',
drawBaseline: false
}
},
axes: {
xaxis: {
renderer: $.jqplot.DateAxisRenderer,
tickRenderer: $.jqplot.CanvasAxisTickRenderer,
tickOptions: {
formatString: "%b",
angle: 0,
textColor: '#888'
},
min: "2012-10-01",
max: "2013-10-31",
tickInterval: "1 month",
drawMajorGridlines: true
},
yaxis: {
renderer: $.jqplot.LinearAxisRenderer,
pad: 0,
rendererOptions: {
minorTicks: 1
},
drawMajorGridlines: false,
tickOptions: {
formatString: function() {
return '%#.1f %';
}(),
showMark: false,
textColor: '#888'
}
}
}
});
}
})(jQuery);</script>

Extjs chart shadow

I have the following code to contruct a pie chart.
The problem is i don't get a shadow.
Note : If the chart config, theme='Base', then the pie has a shadow
Ext.define('ChartPanel', {
extend: 'Ext.panel.Panel',
//------------------CONSTRUCTOR
, constructor: function(externalConfigs) {
externalConfigs = externalConfigs || {};
var configs = {
title: 'My panel',
items: [
{
xtype: 'chart',
store: myStore,
width: '30%',
series: [{
type: 'pie'
, field: 'persentage'
, shadow: 'sides'
, showInLegend: false
, donut: false
, renderer: function(sprite, record, attributes, index, store) {
if (record.data.description == 'option1') {
sprite.setAttributes({
fill: 'url(#redGradient)',
stroke: '#ffffff'
}, false);
} else if (record.data.description == 'option2') {
sprite.setAttributes({
fill: 'url(#greenGradient)',
stroke: '#ffffff'
}, false);
}
}
}]
, gradients: [{
id: 'redGradient',
angle: 45,
stops: {
0: { color: '#820000' },
100: { color: '#BD1E00' }
}
}, {
id: 'greenGradient',
angle: 0,
stops: {
0: { color: '#89AC10' },
100: { color: '#A1C22D' }
}
}]
}
]
}
Ext.apply(configs, externalConfigs);
this.callParent([configs]); //Call the parent constructor
}
});
Any ideas how to get a shadow?
Thanks
Use shadow: true (see the docs in the previous link to see other possible options) within your chart definition. (Not within the pie definition). There is no shadow config property for Ext.chart.series.Pie. You would need to use shadowAttributes within Ext.chart.series.Pie.
I found that
return attributes;
inside the renderer is essential.