Package com.invient.vaadin.charts

Examples of com.invient.vaadin.charts.InvientChartsConfig$State


    @Override
    public CompletionContext<State> buildContext(
        SelectionModel selection, DocumentParser parser) {
      JsonArray<Token> tokens = JsonCollections.createArray();
      State state = TestUtils.createMockState();
      tokens.add(new Token(null, NULL, ""));
      ParseResult<State> parseResult = new ParseResult<State>(tokens, state) {};
      return buildContext(
          new ParseUtils.ExtendedParseResult<State>(parseResult, ParseUtils.Context.IN_CODE));
    }
View Full Code Here


   * @param anchorToUpdate the optional anchor that this method will update
   */
  private boolean parseImplCm2(Line line, int lineNumber, int numLinesToProcess,
      @Nullable Anchor anchorToUpdate, ParsedTokensRecipient tokensRecipient) {

    State parserState = loadParserStateForBeginningOfLine(line);
    if (parserState == null) {
      return false;
    }

    Line previousLine = line.getPreviousLine();

    for (int numLinesProcessed = 0; line != null && numLinesProcessed < numLinesToProcess;) {
      State stateToSave = parserState;
      if (line.getText().length() > LINE_LENGTH_LIMIT) {
        // Save the initial state instead of state at the end of line.
        stateToSave = parserState.copy(codeMirrorParser);
      }

View Full Code Here

    parseImplCm2(line, -1, 1, null, tokensRecipient);
    return tokensRecipient.tokens;
  }

  int getIndentation(Line line) {
    State stateBefore = loadParserStateForBeginningOfLine(line);
    String textAfter = line.getText();
    textAfter = textAfter.substring(StringUtils.lengthOfStartingWhitespace(textAfter));
    return codeMirrorParser.indent(stateBefore, textAfter);
  }
View Full Code Here

   *
   * @return copy of corresponding parser state, or {@code null} if the state
   *         if not known yet (previous line wasn't parsed).
   */
  private <T extends State> T loadParserStateForBeginningOfLine(TaggableLine line) {
    State state;
    if (line.isFirstLine()) {
      state = codeMirrorParser.defaultState();
    } else {
      state = line.getPreviousLine().getTag(LINE_TAG_END_OF_LINE_PARSER_STATE_SNAPSHOT);
      state = (state == null) ? null : state.copy(codeMirrorParser);
    }

    @SuppressWarnings("unchecked")
    T result = (T) state;
    return result;
View Full Code Here

   *
   * @see #loadParserStateForBeginningOfLine
   */
  @Nullable
  String getInitialMode(@Nonnull TaggableLine line) {
    State state = loadParserStateForBeginningOfLine(line);
    if (state == null) {
      return null;
    }
    return codeMirrorParser.getName(state);
  }
View Full Code Here

    }
    return codeMirrorParser.getName(state);
  }

  private void saveEndOfLineParserState(Line line, State parserState) {
    State copiedParserState = parserState.copy(codeMirrorParser);
    line.putTag(LINE_TAG_END_OF_LINE_PARSER_STATE_SNAPSHOT, copiedParserState);
  }
View Full Code Here

    addScheduleTable(horizontalLayout);

  }

  private InvientCharts showUTrend() {
    InvientChartsConfig chartConfig = new InvientChartsConfig();
    chartConfig.getGeneralChartConfig().setType(SeriesType.LINE);
    // chartConfig.getGeneralChartConfig().setMargin(new Margin());
    // chartConfig.getGeneralChartConfig().getMargin().setRight(130);
    // chartConfig.getGeneralChartConfig().getMargin().setBottom(30);

    chartConfig.getTitle().setX(-20);
    chartConfig.getTitle().setText("Wartość U w podziale na lata");
    // chartConfig.getSubtitle().setText("Source: WorldClimate.com");

    CategoryAxis categoryAxis = new CategoryAxis();
    categoryAxis.setCategories(Arrays
        .asList("Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec",
            "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"));
    LinkedHashSet<XAxis> xAxesSet = new LinkedHashSet<InvientChartsConfig.XAxis>();
    xAxesSet.add(categoryAxis);
    chartConfig.setXAxes(xAxesSet);

    NumberYAxis numberYAxis = new NumberYAxis();
    numberYAxis.setTitle(new AxisTitle("Wartość U"));
    NumberPlotLine plotLine = new NumberPlotLine("TempAt0");
    plotLine.setValue(new NumberValue(0.0));
    plotLine.setWidth(1);
    plotLine.setZIndex(1);
    // plotLine.setColor(new RGB(128, 128, 128));
    numberYAxis.addPlotLine(plotLine);
    LinkedHashSet<YAxis> yAxesSet = new LinkedHashSet<InvientChartsConfig.YAxis>();
    yAxesSet.add(numberYAxis);
    chartConfig.setYAxes(yAxesSet);

    Legend legend = new Legend();
    legend.setLayout(Layout.VERTICAL);
    Position legendPos = new Position();
    // legendPos.setAlign(HorzAlign.CENTER);
    // legendPos.setVertAlign(VertAlign.BOTTOM);
    // legendPos.setX(-50);
    legendPos.setY(-250);
    legend.setPosition(legendPos);
    // legend.setBorderWidth(0);
    // chartConfig.setLegend(legend);
    chartConfig.setCredit(null);
    chartConfig.setSubtitle(null);

    // Series data label formatter
    LineConfig lineCfg = new LineConfig();
    chartConfig.addSeriesConfig(lineCfg);
    // Tooltip formatter
    chartConfig
        .getTooltip()
        .setFormatterJsFunc(
            "function() { "
                + " return '<b>' + this.series.name + '</b><br/>' +  this.x + ': '+ this.y +' U'"
                + "}");
View Full Code Here

        addChart(chart);

    }

    private void showSplineUpdatingEachSecond() {
        InvientChartsConfig chartConfig = new InvientChartsConfig();
        chartConfig.getGeneralChartConfig().setType(SeriesType.SPLINE);
        chartConfig.getGeneralChartConfig().setMargin(new Margin());
        chartConfig.getGeneralChartConfig().getMargin().setRight(10);

        chartConfig.getTitle().setText("Live random data");

        DateTimeAxis xAxis = new DateTimeAxis();
        xAxis.setTick(new Tick());
        xAxis.getTick().setPixelInterval(150);
        LinkedHashSet<XAxis> xAxes = new LinkedHashSet<InvientChartsConfig.XAxis>();
        xAxes.add(xAxis);
        chartConfig.setXAxes(xAxes);

        NumberYAxis yAxis = new NumberYAxis();
        yAxis.setTitle(new AxisTitle("Value"));
        NumberPlotLine plotLine;
        yAxis.addPlotLine(plotLine = new NumberPlotLine("LineAt0"));
        plotLine.setValue(new NumberValue(0.0));
        plotLine.setWidth(1);
        plotLine.setColor(new RGB(128, 128, 128));
        LinkedHashSet<YAxis> yAxes = new LinkedHashSet<InvientChartsConfig.YAxis>();
        yAxes.add(yAxis);
        chartConfig.setYAxes(yAxes);

        chartConfig
                .getTooltip()
                .setFormatterJsFunc(
                        "function() {"
                                + " return '<b>'+ this.series.name +'</b><br/>'+ "
                                + " $wnd.Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+ "
                                + " $wnd.Highcharts.numberFormat(this.y, 2);"
                                + "}");

        chartConfig.getLegend().setEnabled(false);

        InvientCharts chart = new InvientCharts(chartConfig);

        DateTimeSeries seriesData = new DateTimeSeries("Random Data", true);
        LinkedHashSet<DateTimePoint> points = new LinkedHashSet<InvientCharts.DateTimePoint>();
View Full Code Here

        cal.setTimeInMillis(dt.getTime() + milliseconds);
        return cal.getTime();
    }

    private void showSplineWithPlotBands() {
        InvientChartsConfig chartConfig = new InvientChartsConfig();
        chartConfig.getGeneralChartConfig().setType(SeriesType.SPLINE);

        chartConfig.getTitle().setText("Wind speed during two days");
        chartConfig
                .getSubtitle()
                .setText(
                        "October 6th and 7th 2009 at two locations in Vik i Sogn, Norway");

        //
        chartConfig
                .getTooltip()
                .setFormatterJsFunc(
                        "function() {"
                                + " return '' + $wnd.Highcharts.dateFormat('%e. %b %Y, %H:00', this.x) +': '+ this.y +' m/s'; "
                                + "}");

        DateTimeAxis xAxis = new DateTimeAxis();
        LinkedHashSet<XAxis> xAxesSet = new LinkedHashSet<InvientChartsConfig.XAxis>();
        xAxesSet.add(xAxis);
        chartConfig.setXAxes(xAxesSet);

        NumberYAxis yAxis = new NumberYAxis();
        yAxis.setTitle(new AxisTitle("Wind speed (m/s)"));
        yAxis.setMin(0.0);
        yAxis.setMinorGrid(new MinorGrid());
        yAxis.getMinorGrid().setLineWidth(0);
        yAxis.setGrid(new Grid());
        yAxis.getGrid().setLineWidth(0);
        NumberPlotBand numberBand = new NumberPlotBand("Light air");
        numberBand.setRange(new NumberRange(0.3, 1.5));
        numberBand.setColor(new RGBA(68, 170, 213, 0.1f));
        numberBand.setLabel(new PlotLabel("Light air"));
        numberBand.getLabel().setStyle("{ color: '#606060' }");
        yAxis.getPlotBands().add(numberBand);

        numberBand = new NumberPlotBand("Light breeze");
        numberBand.setRange(new NumberRange(1.5, 3.3));
        numberBand.setColor(new RGBA(0, 0, 0, 0.0f));
        numberBand.setLabel(new PlotLabel("Light breeze"));
        numberBand.getLabel().setStyle("{ color: '#606060' }");
        yAxis.getPlotBands().add(numberBand);

        numberBand = new NumberPlotBand("Gentle breeze");
        numberBand.setRange(new NumberRange(3.3, 5.5));
        numberBand.setColor(new RGBA(68, 170, 213, 0.1f));
        numberBand.setLabel(new PlotLabel("Gentle breeze"));
        numberBand.getLabel().setStyle("{ color: '#606060' }");
        yAxis.getPlotBands().add(numberBand);

        numberBand = new NumberPlotBand("Moderate breeze");
        numberBand.setRange(new NumberRange(5.5, 8.0));
        numberBand.setColor(new RGBA(0, 0, 0, 0.0f));
        numberBand.setLabel(new PlotLabel("Moderate breeze"));
        numberBand.getLabel().setStyle("{ color: '#606060' }");
        yAxis.getPlotBands().add(numberBand);

        numberBand = new NumberPlotBand("Fresh breeze");
        numberBand.setRange(new NumberRange(8.0, 11.0));
        numberBand.setColor(new RGBA(68, 170, 213, 0.1f));
        numberBand.setLabel(new PlotLabel("Fresh breeze"));
        numberBand.getLabel().setStyle("{ color: '#606060' }");
        yAxis.getPlotBands().add(numberBand);

        numberBand = new NumberPlotBand("Strong breeze");
        numberBand.setRange(new NumberRange(11.0, 14.0));
        numberBand.setColor(new RGBA(0, 0, 0, 0.0f));
        numberBand.setLabel(new PlotLabel("Strong breeze"));
        numberBand.getLabel().setStyle("{ color: '#606060' }");
        yAxis.getPlotBands().add(numberBand);

        numberBand = new NumberPlotBand("High wind");
        numberBand.setRange(new NumberRange(14.0, 15.0));
        numberBand.setColor(new RGBA(68, 170, 213, 0.1f));
        numberBand.setLabel(new PlotLabel("High wind"));
        numberBand.getLabel().setStyle("{ color: '#606060' }");
        yAxis.getPlotBands().add(numberBand);

        LinkedHashSet<YAxis> yAxesSet = new LinkedHashSet<InvientChartsConfig.YAxis>();
        yAxesSet.add(yAxis);
        chartConfig.setYAxes(yAxesSet);

        SplineConfig splineCfg = new SplineConfig();
        splineCfg.setLineWidth(4);
        splineCfg.setHoverState(new SeriesState());
        splineCfg.getHoverState().setLineWidth(5);
        //
        SymbolMarker symbolMarker = new SymbolMarker(false);
        splineCfg.setMarker(symbolMarker);
        symbolMarker.setSymbol(Symbol.CIRCLE);
        symbolMarker.setHoverState(new MarkerState());
        symbolMarker.getHoverState().setEnabled(true);
        symbolMarker.getHoverState().setRadius(5);
        symbolMarker.getHoverState().setLineWidth(1);

        splineCfg.setPointStart((double) getPointStartDate(2009, 8, 6));
        splineCfg.setPointInterval(3600000.0);
        chartConfig.addSeriesConfig(splineCfg);

        InvientCharts chart = new InvientCharts(chartConfig);
        DateTimeSeries series = new DateTimeSeries("Hestavollane", splineCfg, true);
        series.setSeriesPoints(getDateTimePoints(series, 4.3, 5.1, 4.3, 5.2,
                5.4, 4.7, 3.5, 4.1, 5.6, 7.4, 6.9, 7.1, 7.9, 7.9, 7.5, 6.7,
View Full Code Here

        addChart(chart);
    }

    private void showCombination() {
        InvientChartsConfig chartConfig = new InvientChartsConfig();
        chartConfig.getTitle().setText("Combination chart");

        Tooltip tooltip = new Tooltip();
        tooltip.setFormatterJsFunc("function() {"
                + " if (this.point.name) { // the pie chart "
                + "   return this.point.name +': '+ this.y +' fruits'; "
                + " } else {" + "   return this.x  +': '+ this.y; " + " } "
                + "}");

        CategoryAxis xAxis = new CategoryAxis();
        xAxis.setCategories(Arrays.asList("Apples", "Oranges", "Pears",
                "Bananas", "Plums"));
        LinkedHashSet<XAxis> xAxesSet = new LinkedHashSet<InvientChartsConfig.XAxis>();
        xAxesSet.add(xAxis);
        chartConfig.setXAxes(xAxesSet);

        NumberYAxis yAxis = new NumberYAxis();
        yAxis.setAllowDecimals(false);
        LinkedHashSet<YAxis> yAxesSet = new LinkedHashSet<InvientChartsConfig.YAxis>();
        yAxesSet.add(yAxis);
        chartConfig.setYAxes(yAxesSet);

        InvientCharts chart = new InvientCharts(chartConfig);

        XYSeries seriesData = new XYSeries("Jane", SeriesType.COLUMN);
        seriesData.setSeriesPoints(getPoints(seriesData, 3, 2, 1, 3, 4));
        chart.addSeries(seriesData);

        seriesData = new XYSeries("John", SeriesType.COLUMN);
        seriesData.setSeriesPoints(getPoints(seriesData, 2, 3, 5, 7, 6));
        chart.addSeries(seriesData);

        seriesData = new XYSeries("Joe", SeriesType.COLUMN);
        seriesData.setSeriesPoints(getPoints(seriesData, 4, 3, 3, 9, 0));
        chart.addSeries(seriesData);

        seriesData = new XYSeries("Average", SeriesType.SPLINE);
        seriesData
                .setSeriesPoints(getPoints(seriesData, 3, 2.67, 3, 6.33, 3.33));
        chart.addSeries(seriesData);

        // Series Total consumption
        PieConfig pieCfg = new PieConfig();
        pieCfg.setCenterX(100);
        pieCfg.setCenterY(80);
        pieCfg.setSize(100);
        pieCfg.setShowInLegend(false);
        pieCfg.setDataLabel(new PieDataLabel());
        pieCfg.getDataLabel().setEnabled(false);

        XYSeries totalConsumpSeriesData = new XYSeries("Total consumption",
                SeriesType.PIE, pieCfg);
        PointConfig config = new PointConfig(new RGB(69, 114, 167));
        DecimalPoint point = new DecimalPoint(totalConsumpSeriesData, "Jane",
                13, config);
        totalConsumpSeriesData.addPoint(point);
        config = new PointConfig(new RGB(170, 70, 67));
        point = new DecimalPoint(totalConsumpSeriesData, "John", 23, config);
        totalConsumpSeriesData.addPoint(point);
        config = new PointConfig(new RGB(137, 165, 78));
        point = new DecimalPoint(totalConsumpSeriesData, "Joe", 19, config);
        totalConsumpSeriesData.addPoint(point);

        ChartLabel chartLabel = new ChartLabel();
        chartLabel.addLabel(new ChartLabelItem("Total fruit consumption",
                "{ left: '40px', top: '8px', color: 'black' }"));
        chartConfig.setChartLabel(chartLabel);
        chart.addSeries(totalConsumpSeriesData);

        addChart(chart);
    }
View Full Code Here

TOP

Related Classes of com.invient.vaadin.charts.InvientChartsConfig$State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.