Skip to content

Commit

Permalink
Merge pull request #151 from nzzdev/release-3.0.0
Browse files Browse the repository at this point in the history
Release 3.0.0
  • Loading branch information
benib authored Oct 11, 2019
2 parents 25b5af3 + 77b9d83 commit ad09240
Show file tree
Hide file tree
Showing 23 changed files with 618 additions and 1,515 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dist: trusty
dist: xenial
sudo: true
services:
- docker
Expand Down
15 changes: 15 additions & 0 deletions chartTypes/area/mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ module.exports = function getMappings() {
delete spec.axes[1]; // delete the y axis
}
}
},
{
path: "item.options.areaChartOptions.maxValue",
mapToSpec: function(maxValue, spec, mappingData) {
// check if we need to shorten the number labels
const divisor = dataHelpers.getDivisor(mappingData.item.data);

const dataMaxValue = dataHelpers.getMaxValue(mappingData.item.data);
if (dataMaxValue > maxValue) {
maxValue = dataMaxValue;
}

objectPath.set(spec, "scales.1.nice", false);
objectPath.set(spec, "scales.1.domainMax", maxValue / divisor);
}
}
]
.concat(commonMappings.getColumnAreaPrognosisMappings())
Expand Down
2 changes: 1 addition & 1 deletion chartTypes/arrow/vega-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
"grid": true,
"labels": true,
"ticks": false,
"labelPadding": 2,
"labelPadding": 4,
"encode": {
"title": {
"update": {
Expand Down
10 changes: 6 additions & 4 deletions chartTypes/commonMappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ function getLineDateSeriesHandlingMappings() {
mapToSpec: function(itemData, spec, mappingData) {
const item = mappingData.item;
if (
mappingData.dateFormat &&
item.options.lineChartOptions &&
item.options.lineChartOptions.isStockChart !== true
(mappingData.dateFormat &&
(item.options.chartType === "Line" &&
item.options.lineChartOptions &&
item.options.lineChartOptions.isStockChart !== true)) ||
item.options.chartType === "Area"
) {
objectPath.set(spec, "scales.0.type", "time"); // time scale type: https://vega.github.io/vega/docs/scales/#time
objectPath.set(spec, "axes.0.ticks", true); // show ticks if we have a date series
Expand Down Expand Up @@ -371,7 +373,7 @@ function getColumnAxisPositioningMappings() {
// we move the X axis to the top
if (max <= 0) {
objectPath.set(spec, "axes.0.orient", "top");
objectPath.set(spec, "axes.0.labelPadding", -5);
objectPath.set(spec, "axes.0.labelPadding", 4);
// if we still have a title for this axis, move it to the top
const title = objectPath.get(spec, "axes.0.encode.title");
if (title) {
Expand Down
2 changes: 1 addition & 1 deletion chartTypes/dotplot/vega-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"grid": true,
"labels": true,
"ticks": false,
"labelPadding": 2,
"labelPadding": 8,
"encode": {
"title": {
"update": {
Expand Down
5 changes: 0 additions & 5 deletions helpers/chartType.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
function getChartTypeForItemAndWidth(item, width) {
// any custom vegaSpec overrules the chartType setting
if (item.vegaSpec !== undefined && item.vegaSpec !== "") {
return null;
}

if (item.options.chartType === "Line") {
return "line";
}
Expand Down
4 changes: 2 additions & 2 deletions helpers/legend/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const vega = require("vega");
const optionsHelpers = require("../options.js");

async function getLegendModel(item, toolRuntimeConfig, chartType, server) {
// if we do not have a type or we have a vegaSpec that defacto overwrites the chartType, we do not show a legend
if (!chartType || item.vegaSpec) {
// if we do not have a type we do not show a legend
if (!chartType) {
return null;
}
const legendModel = {};
Expand Down
Loading

0 comments on commit ad09240

Please sign in to comment.