How to use the terriajs-cesium/Source/Core/defaultValue function in terriajs-cesium

To help you get started, we’ve selected a few terriajs-cesium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TerriaJS / terriajs / lib / ReactViews / Custom / Chart / Chart.jsx View on Github external
}

    // for better presentation, we order datasets  so that the ones with units information to
    // display first, so that Yaxis with unit shows up outside yaxis without
    // unit
    if (defined(chartData) && chartData.length > 1) {
      chartData = chartData
        .slice()
        .sort((data1, data2) => defined(data1.units) - defined(data2.units));
    }

    return {
      data: chartData,
      domain: this.props.domain,
      width: "100%",
      height: defaultValue(this.props.height, defaultHeight),
      axisLabel: this.props.axisLabel,
      mini: this.props.styling === "feature-info",
      transitionDuration: this.props.transitionDuration,
      margin: margin,
      tooltipSettings: tooltipSettings,
      titleSettings: titleSettings,
      grid: grid,
      highlightX: this.props.highlightX
    };
  },
github TerriaJS / terriajs / lib / Charts / ChartRenderer.js View on Github external
state.data.filter(data => data.type !== "moment").map(data => data.units)
    );
    const size = Size.calculate(
      container,
      margin,
      state,
      state.mini ? 1 : units.length
    );
    const scales = Scales.calculate(
      size,
      state.domain,
      state.data,
      this.getXpadding(state)
    );

    const transitionDuration = defaultValue(
      state.transitionDuration,
      defaultTransitionDuration
    );

    // The last condition in hasData checks that at least one y-value of one chart is defined.
    const hasData =
      data.length > 0 &&
      data[0].points.length > 0 &&
      data.some(d => d.points.some(p => defined(p.y)));

    const d3Container = d3Select(container);

    // Update SVG
    const chartSVGContainer = d3Container
      .select("svg")
      .attr("width", state.width)
github TerriaJS / terriajs / lib / Map / prettifyCoordinates.js View on Github external
function prettifyCoordinates(longitude, latitude, options) {
  var result = {};

  const optionsDefaulted = defaultValue(options, {});
  const digits = defaultValue(optionsDefaulted.digits, 5);

  result.latitude =
    Math.abs(latitude).toFixed(digits) + "°" + (latitude < 0.0 ? "S" : "N");
  result.longitude =
    Math.abs(longitude).toFixed(digits) + "°" + (longitude < 0.0 ? "W" : "E");

  if (defined(optionsDefaulted.height)) {
    result.elevation =
      Math.round(optionsDefaulted.height) +
      (defined(optionsDefaulted.errorBar)
        ? "±" + Math.round(optionsDefaulted.errorBar)
        : "") +
      "m";
  } else {
    result.elevation = undefined;
github TerriaJS / terriajs / lib / Charts / ChartRenderer.js View on Github external
static render(container, state) {
    if (!defined(state.data)) {
      return;
    }

    initializeChartTypes(state);

    const data = state.data;
    const margin = defaultValue(state.margin, defaultMargin);
    const units = uniq(
      state.data.filter(data => data.type !== "moment").map(data => data.units)
    );
    const size = Size.calculate(
      container,
      margin,
      state,
      state.mini ? 1 : units.length
    );
    const scales = Scales.calculate(
      size,
      state.domain,
      state.data,
      this.getXpadding(state)
    );
github TerriaJS / terriajs / lib / Charts / ChartData.js View on Github external
var ChartData = function(points, parameters) {
  parameters = defaultValue(parameters, defaultValue.EMPTY_OBJECT);
  /**
   * The array of points. Each point should have the format {x: X, y: Y}.
   * @type {Object[]}
   */
  this.points = defaultValue(points, []);

  /**
   * A selected point from the array above. Used internally by charting functions for hover/clicking functionality.
   * @type {Object}
   */
  this.point = undefined;

  /**
   * Unique id for this set of points.
   * @type {String}
   */
  this.id = parameters.id;

  /**
   * Name of the category for this set of points., eg. the source catalog item.
   * @type {String}
github TerriaJS / terriajs / lib / Charts / Size.js View on Github external
calculate(element, margin, state, numberOfYAxes) {
    const xAxisHeight = defaultValue(state.xAxisHeight, defaultXAxisHeight);
    const xAxisLabelHeight = defaultValue(
      state.xAxisLabelHeight,
      defaultXAxisLabelHeight
    );
    const yAxesWidth = numberOfYAxes * yAxisWidth;
    const titleHeight = Title.getHeight(state.titleSettings);
    const width = element.offsetWidth - margin.left - margin.right - yAxesWidth;
    const height =
      element.offsetHeight - margin.top - margin.bottom - titleHeight;
    const heightMinusXAxisLabelHeight =
      height -
      (defined(state.axisLabel) && defined(state.axisLabel.x)
        ? xAxisLabelHeight
        : 0);
    const plotHeight =
      heightMinusXAxisLabelHeight - (state.mini ? 0 : xAxisHeight);
github TerriaJS / terriajs / lib / Charts / ChartData.ts View on Github external
constructor(options: ChartDataOptions) {
    this.points = options.points;
    this.point = undefined;
    this.id = options.id;
    this.categoryName = options.categoryName;
    this.name = options.name;
    this.units = options.units;
    this.getColor = options.getColor;
    this.yAxisMin = options.yAxisMin;
    this.yAxisMax = options.yAxisMax;
    this.type = options.type;
    this.onClick = options.onClick;
    this.showAll = defaultValue(options.showAll, true);
    this.yAxisWidth = 40;
  }
github TerriaJS / terriajs / lib / ReactViews / Custom / Chart / ConceptsSelector.js View on Github external
getFillStyle(concept) {
      return {
        fill: defaultValue(concept.color, '#ffffff')
      };
    },
github TerriaJS / terriajs / lib / Models / SearchResult.ts View on Github external
constructor(options: SearchResultOptions) {
    this.name = defaultValue(options.name, "Unknown");
    this.tooltip = options.tooltip;
    this.isImportant = defaultValue(options.isImportant, false);
    this.clickAction = options.clickAction;
    this.catalogItem = options.catalogItem;
    this.location = options.location;
  }
github TerriaJS / terriajs / lib / ModelMixins / OpacityMixin.ts View on Github external
get opacity(): number {
            return defaultValue(super.opacity, 0.8);
        }
    }

terriajs-cesium

Cesium for TerriaJS.

Apache-2.0
Latest version published 8 months ago

Package Health Score

68 / 100
Full package analysis