There is a new bug that your code exposes, which happens when there is only
a single date value for the domain axis. This is a problem because it
can't tell what the range of the axis should be with only one point, but
you can work around it by adding a minValue or maxValue to define the range
of the axis, like this:
hAxis: { minValue: new Date("2018-07-01T22:26:34.000Z")},
See:
http://jsfiddle.net/dlaliberte/c8v5pu6L/5/
On Wed, Jan 16, 2019 at 9:04 AM 'Uffi Schnuffi' via Google Chart API <
[email protected]> wrote:
> See below example.
>
> Top chart: should draw a single datapoint ('date', 'number')
> Bottom chart: draws two datapoints ('data', 'number')
>
> The top one does not display the datapoints in the chart. Further, the
> option "explorer: { ... }" causes the "a is null" in the top chart.
>
> Any clues on why this is? Why is the single data point not drawn?
> What's up with the "a is null" when "explorer" is used??
>
>
> <!DOCTYPE html>
> <html>
> <head>
> <script type="text/javascript" src="
> https://www.gstatic.com/charts/loader.js"></script>
> </head>
>
>
> <body>
> <div id="chart1" class="chart"></div>
> <div id="chart2" class="chart"></div>
>
> <script type="text/javascript">
> var chartData = {};
> var datapoint = [new Date("2018-07-01T23:26:34.000Z"), 4321];
> var datapoint2 = [new Date("2018-07-01T22:26:34.000Z"), 1234];
>
> google.charts.load('current', {
> packages: ['line', 'corechart'],
> mapsApiKey: "AIzaSyAJmRgAldd-U2y2-8EDlppO4Y5tZnK3D3g"
> });
>
> var options = {
> // Explorer causes "a is null" in chart1
> explorer: { axis: 'horizontal', keepInBounds: true },
> pointSize: 2,
> lineWidth: 1
> }
>
> google.charts.setOnLoadCallback(function() {
> var table1 = new google.visualization.DataTable();
> table1.addColumn('date');
> table1.addColumn('number');
> // This datapoint will not be visible in the chart! Why?
> table1.addRows([datapoint]);
> var chart1 = new google.visualization.LineChart(document.
> getElementById('chart1'));
> chart1.draw(table1, options);
>
> var table2 = new google.visualization.DataTable();
> table2.addColumn('date');
> table2.addColumn('number');
> table2.addRows([datapoint, datapoint2]);
> var chart2 = new google.visualization.LineChart(document.
> getElementById('chart2'));
> chart2.draw(table2, options);
> });
>
>
> </script>
> </body>
>
> </html>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Chart API" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/google-chart-api.
> For more options, visit https://groups.google.com/d/optout.
>
--
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
[email protected] <[email protected]> Cambridge MA
--
You received this message because you are subscribed to the Google Groups
"Google Chart API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-chart-api.
For more options, visit https://groups.google.com/d/optout.