|
[JS]
function addNewSeries() {
// Create new secondary y Axis
var newAxis = {
majorGridLines: { visible: false },
orientation: 'Vertical',
opposedPosition: true,
axisLine: { visible: false },
rangePadding: 'normal',
name: 'yAxis',
labelFormat: '${value}',
title: { text: "Total Transactions" }
};
// Getting the chart instance
var chart = $("#container").ejChart("instance");
// Create the new series with data
var newSeries = {
name: "Mango",
dataSource: GetDateTimeData(new Date("1/1/2009"), new Date("10/1/2009")).Open,
xName: "XValue",
type:"line",
fill: "#a0f441",
yName: "YValue",
yAxisName: "yAxis"
}
// Push the new series and axes in chart instance
chart.model.series.push(newSeries);
chart.model.axes.push(newAxis);
// Redrawing the chart once
chart.redraw();
} |
Thank you for the quick response and working example.
I did the same in my code but it didn't work. The reason was that I was also assigning axis name dynamically and it contained space in it. Removing space from axis name and your example, resolved my problem.
Kind regards,
Ivan
Hello,
the problem occurs not when the axis title text has spaces in it but when axis name property has it (in your case it is 'Mango'). Also, I found out that the same problems occurs when name property contains underscores.
If that's the case, and axis name contains any of the before mentioned characters, I'm getting this javascript error in console and the chart is not rendered.
ej.web.all.min.js:10 Uncaught TypeError: Cannot read property '_validCross' of undefined
at ej.EjAxisRenderer._drawYAxisGridLine (ej.web.all.min.js:10)
at ej.EjAxisRenderer._drawGridLines (ej.web.all.min.js:10)
at Object.draw (ej.web.all.min.js:10)
at Object.bindTo (ej.web.all.min.js:10)
at Object.redraw (ej.web.all.min.js:10)
at addFirstSeries (Index:293)
at t.DataManager.<anonymous> (Index:327)
at i (jquery-3.1.1.min.js:2)
at Object.fireWith [as resolveWith] (jquery-3.1.1.min.js:2)
at t.DataManager.<anonymous> (ej.web.all.min.js:10)
Kind regards,
Ivan