Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change range on Y axis #1533

Open
mladjan opened this issue Jan 27, 2024 · 11 comments
Open

How to change range on Y axis #1533

mladjan opened this issue Jan 27, 2024 · 11 comments

Comments

@mladjan
Copy link

mladjan commented Jan 27, 2024

CleanShot 2024-01-27 at 21 23 19@2x

I have 2 kind of data. Value2 goes from 0 to 220, so range on X axis is fine.
But on Y axis, it's from 107 to 105, so really small changes.

How to make Y axis more detailed, so changes are more visible?

This is the current code:

AAChartModel *aaChartModel= AAObject(AAChartModel)
    .chartTypeSet(AAChartTypeLine)
    .titleSet(@"")
    .categoriesSet(speedIntArray)
    .yAxisTitleSet(@"")
    .colorsThemeSet(@[@"#15A3FE",@"#FE7620"])
    .seriesSet(@[
            AAObject(AASeriesElement)
            .nameSet(@"Value 1")
            .dataSet(heightArray)
            ,
            AAObject(AASeriesElement)
            .nameSet(@"Value 2")
            .dataSet(speedIntArray)])
    .markerRadiusSet(@1);
    AAItemStyle *aaItemStyle = AAObject(AAItemStyle)
    .colorSet(@"#ffffff")
    .cursorSet(@"pointer")
    .fontSizeSet(@"12px")
    .fontWeightSet(AAChartFontWeightTypeThin);
    AAOptions *aaOptions = [AAOptionsConstructor configureChartOptionsWithAAChartModel:aaChartModel];
    aaOptions.legend.itemStyle = aaItemStyle;
    [_aaChartView aa_drawChartWithOptions:aaOptions];
@AAChartModel
Copy link
Owner

Maybe you need to change the chart to a dual Y-axis chart.

@mladjan
Copy link
Author

mladjan commented Jan 30, 2024

@AAChartModel how? I don't see any AAChartType like this.
Can you help me with some code snippet?

@AAChartModel
Copy link
Owner

@mladjan
Copy link
Author

mladjan commented Feb 5, 2024

I managed to make double `y axis chart, but there is no way to change the background color from White to something else.

Setting background doesn't work on this type of chart.
I tried with:

_aaChartView.isClearBackgroundColor = YES;

Is there any other way to make it another color than white?

@AAChartModel
Copy link
Owner

What effect are you looking for? Can you provide a screenshot of the design draft?

@mladjan
Copy link
Author

mladjan commented Feb 5, 2024

CleanShot 2024-02-05 at 09 19 10@2x
This is how it looks now, I just need the background to be another color :)

@AAChartModel
Copy link
Owner

AAChartModel commented Feb 5, 2024

The code of AAChartView.m file

- (void)configureTheOptionsJsonStringWithAAOptions:(AAOptions *)aaOptions {
    if (_isClearBackgroundColor) {
        aaOptions.chart.backgroundColor = @"rgba(0,0,0,0)";
    }
    
    if (_clickEventEnabled == true) {
        aaOptions.clickEventEnabled = true;
        [self configurePlotOptionsSeriesPointEventsWithAAOptions:aaOptions];
    }
    if (_mouseOverEventEnabled == true) {
        aaOptions.touchEventEnabled = true;
        if (_clickEventEnabled == false) {//避免重复调用配置方法
            [self configurePlotOptionsSeriesPointEventsWithAAOptions:aaOptions];
        }
    }
    
    _optionJson = [AAJsonConverter pureOptionsJsonStringWithOptionsInstance:aaOptions];
}

The key content

   if (_isClearBackgroundColor) {
        aaOptions.chart.backgroundColor = @"rgba(0,0,0,0)"; // set the chart be clear color
    }

So, If you just want to change the chart bacckgroundColor, do not use

_aaChartView.isClearBackgroundColor = YES;

@mladjan
Copy link
Author

mladjan commented Feb 5, 2024

I have removed "isClearBackground" property, and manually set:

aaaOptions.chart.backgroundColor = @"rgba(25,25,35,1)";

But it's still white

@AAChartModel
Copy link
Owner

You can also see the sample in the demo

In this example, the background color is set to @"#191E40".

    AAChart *aaChart = AAChart.new
    .backgroundColorSet(@"#191E40");

@mladjan
Copy link
Author

mladjan commented Feb 5, 2024

It works with this code sample:

 AAChart *aaChart = AAChart.new
    .backgroundColorSet(@"#191923");

    AAOptions *aaaOptions = AAOptions.new
    .chartSet(aaChart)
    .titleSet(aaTitle)
    .xAxisSet(aaXAxis)
    .yAxisSet((id)@[yAxisOne,yAxisTwo])
    .tooltipSet(aaTooltip)
    .seriesSet(aaSeries)
    ;

    
    [_aaChartView aa_drawChartWithOptions:aaaOptions];

@mladjan mladjan closed this as completed Feb 5, 2024
@mladjan
Copy link
Author

mladjan commented Mar 12, 2024

You can also see the sample in the demo

In this example, the background color is set to @"#191E40".

    AAChart *aaChart = AAChart.new
    .backgroundColorSet(@"#191E40");

Is there a possibility to add 3rd Y axis and to set proper scaling on that?
When I added 3rd Y axis parameter, it uses scaling from second Y axis and because of that, resolution is small.

@mladjan mladjan reopened this Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants